Re: Protected static props redeclared as public share value across classes
| From: | Robin Fernandes | Date: | Tue, 26 Feb 2008 17:34:49 +0000 |
| Subject: | Re: Protected static props redeclared as public share value across classes | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-35807@lists.php.net to get a copy of this message | ||
Hi Marcus,
On 28/01/2008, Marcus Boerger <helly@php.net> wrote:
> >
> > I checked it out in more detail and it is indeed broken as in it is not
> > consistent
If possible, I'd like to revive this discussion. Patch included. :)
History: http://thread.gmane.org/gmane.comp.php.devel/47956/focus=47956
To summarize, we agree that there is an inconsistency related to
static property inheritance, because:
--> In the following case, A::$p and B::$p share the same value:
class A { protected static $p; } class B extends A { public static $p; }
--> Yet in the following cases, A::$p and B::$p have two separate values:
class A { protected static $p; } class B extends A { protected static $p; }
class A { public static $p; } class B extends A { public static $p; }
You originally suggested fixing the inconsistency by changing the last
2 cases, so that A::$p and B::$p always share the same value. However,
that approach raised some concerns described by myself and Jochem, for
example:
--> Inconsistency with overridden methods
--> Inconsistency with shadowed class constants.
Consequently, I'd like to propose resolving this by changing the first
case, so that A::$p and B::$p always have separate values.
Here's a patch that implements this. It includes relevant changes to
existing tests, plus some supplementary tests to address Jochem's
concern about the impact on LSB.
Patch against snap php6.0-200802251530: http://pastebin.ca/919094
Disclaimer: I am not an internals expert - patch might overlook some
cases, feedback welcome. :)
Let me know what you think.
Regards,
Robin