#44769 [Com]: declaring private magic methods should throw error
| From: | danielc at analysisandsolutions dot com | Date: | Sun, 25 May 2008 14:27:15 +0000 |
| Subject: | #44769 [Com]: declaring private magic methods should throw error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-125236@lists.php.net to get a copy of this message | ||
ID: 44769
Comment by: danielc at analysisandsolutions dot com
Reported By: todd at magnifisites dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: *
PHP Version: 5.2.5
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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