#44769 [Asn->Csd]: declaring private magic methods should throw error
| From: | felipe@php.net | Date: | Tue, 03 Jun 2008 14:08:48 +0000 |
| Subject: | #44769 [Asn->Csd]: declaring private magic methods should throw error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-125458@lists.php.net to get a copy of this message | ||
ID: 44769
Updated by: felipe@php.net
Reported By: todd at magnifisites dot com
-Status: Assigned
+Status: Closed
Bug Type: Scripting Engine problem
Operating System: *
PHP Version: 5.2.5
Assigned To: felipe
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Fixed in 5_3 and HEAD.
Previous Comments:
------------------------------------------------------------------------
[2008-05-25 14:27:15] danielc at analysisandsolutions dot com
Marcus feels this is a bug and should be addressed
(http://news.php.net/php.internals/37857).
Once this is fixed, the documentation bug should be updated
(http://bugs.php.net/bug.php?id=43924).
Here are earlier bug reports covering this issue...
Documentation bugs that have been closed:
http://bugs.php.net/bug.php?id=31806
http://bugs.php.net/bug.php?id=40103
Illia marked this bogus saying it is the expected behavior.
http://bugs.php.net/bug.php?id=40056
------------------------------------------------------------------------
[2008-04-17 23:15:57] todd at magnifisites dot com
Description:
------------
When using object overloading I thought I might receive at the very
least a warning error if I attempted to declare any of the magic methods
as private in a class definition as per the documentation:
"All overloading methods must be defined as public."
http://php.net/language.oop5.overloading.php
Also tested in PHP 6CVS-2008-04-17 (snap)
Reproduce code:
---------------
class MemberTest {
/** Location for overloaded data. */
private $data = array();
private function __set($name, $value) {
echo "Setting '$name' to '$value'\n";
$this->data[$name] = $value;
}
private function __get($name) {
echo "Getting '$name'\n";
if (array_key_exists($name, $this->data)) {
return $this->data[$name];
}
}
}
echo "<pre>\n";
$obj = new MemberTest;
$obj->a = 1;
echo $obj->a . "\n";
exit;
Expected result:
----------------
A FATAL error or at the very least a WARNING error with
error_reporting = E_ALL | E_STRICT
Actual result:
--------------
<pre>
Setting 'a' to '1'
Getting 'a'
1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44769&edit=1