#47380 [NEW]: Ability for a superclass to declare that a class variable is per each subclass.

From: Date: Fri, 13 Feb 2009 12:58:05 +0000
Subject: #47380 [NEW]: Ability for a superclass to declare that a class variable is per each subclass.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133800@lists.php.net to get a copy of this message
From: timlind at iafrica dot com Operating system: PHP version: 5.3.0beta1 PHP Bug Type: Feature/Change Request Bug description: Ability for a superclass to declare that a class variable is per each subclass. Description: ------------ The new static:: keyword (poorly named, wouldn't virtual:: be better?) has introduced the ability for a super-class to execute in the context of the class that specializes it. This has allowed the super-class to access attributes that are (re)declared in the subclass, allowing specialized functions to be called. For this to happen, the sub-class needs to have statically declared and defined the method (if there was such a method in the super-class in the first place). For methods, this is fine, because for a method to be overriden by a subclass, it will of course need to be defined by the subclass. But for attributes, the subclass has no concern with or reason to redeclare the attribute, so it should be possible for the super class to specify that a static attribute be redeclared for the subclass. Reproduce code: --------------- class Super { static self::$variable = 'super'; function __construct() { static::$variable = 'sub'; } } class Sub extends Super { } new Sub(); Super::$variable; # => super Sub::$variable; # => sub Expected result: ---------------- Super::variable should be untouched, and Sub::variable should be affected by the statement in Super::__construct. self::$var makes sense in comparison to the opposite which is Super::$var (what static $var is currently a shorthand for). Actual result: -------------- Invalid syntax. -- Edit bug report at http://bugs.php.net/?id=47380&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47380&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47380&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47380&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47380&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47380&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47380&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47380&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47380&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47380&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47380&r=support Expected behavior: http://bugs.php.net/fix.php?id=47380&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47380&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47380&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47380&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47380&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47380&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47380&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47380&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47380&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47380&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47380&r=mysqlcfg

« previous php.bugs (#133800) next »