From: todd at magnifisites dot com Operating system: Any PHP version: 5.2.5 PHP Bug Type: Class/Object related Bug description: declaring private magic methods should throw error
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 bug report at http://bugs.php.net/?id=44769&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44769&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44769&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44769&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44769&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44769&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44769&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44769&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44769&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44769&r=support Expected behavior: http://bugs.php.net/fix.php?id=44769&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44769&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44769&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44769&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44769&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44769&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44769&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44769&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44769&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44769&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44769&r=mysqlcfg