From: atrauzzi at gmail dot com Operating system: Linux PHP version: 5.3.0 PHP Bug Type: Class/Object related Bug description: Subclass property behaviour of questionable use...
Description: ------------ Subclass properties should be duplicated from the parent class, not passed through to the parent class. The current behaviour is redundant and possibly misleading. Especially with the great selection of scopes in PHP (parent::, static::, self::). The current workaround is to dump everything into an array on the parent, keyed by subclass. This knocks out cohesive design and restricts the potential for some fairly neat designs. At the very least - to prevent accidental misuse - a subclass should be throwing an error when trying to access a property that doesn't exist, but does exist on a parent. Really what should be happening though, is a child should be getting its own copy of each property defined in the parent. Reproduce code: --------------- abstract class Parent { protected static $message = "UNTOUCHED"; public static function yeah() { static::$message = "YEAH"; } public static function nope() { static::$message = "NOPE"; } public static function lateStaticDebug() { return(static::$message); } } class Child extends Parent { } Expected result: ---------------- Parent::yeah(); Parent::lateStaticDebug(); // Return "YEAH" Child::nope(); Child::lateStaticDebug(); // Return "NOPE" Parent::yeah(); Child::lateStaticDebug() // Return "NOPE" Actual result: -------------- Parent::yeah(); Parent::lateStaticDebug(); // Returns "YEAH" Child::nope(); Child::lateStaticDebug(); // Returns "NOPE" Parent::yeah(); Child::lateStaticDebug() // Returns "YEAH" -- Edit bug report at http://bugs.php.net/?id=49105&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49105&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49105&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49105&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=49105&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49105&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=49105&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=49105&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=49105&r=needscript Try newer version: http://bugs.php.net/fix.php?id=49105&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=49105&r=support Expected behavior: http://bugs.php.net/fix.php?id=49105&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=49105&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=49105&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=49105&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49105&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=49105&r=dst IIS Stability: http://bugs.php.net/fix.php?id=49105&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=49105&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=49105&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=49105&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=49105&r=mysqlcfg