I would definitely vote C as well. PHP 7's behavior makes even less sense
than PHP 5 in this case.

On Tue, Mar 14, 2017 at 10:43 PM, Sara Golemon <poll...@php.net> wrote:

> This comes in thanks to my old friend Fred Emmott on the HHVM project:
> https://3v4l.org/vUHq3
>
> class Foo {
>     const A = 1 << 0;
>     const B = self::A | self::C;
>     const C = 1 << 1;
>
> }
>
> class Bar extends Foo {
>     const A = 1 << 2;
>     const C = 1 << 3;
> }
>
> var_dump(decbin(Bar::B));
> // HHVM result: 11
> // PHP5 result: 1100
> // PHP7 result: 1001
>
> HHVM's result is clearly correct as `self::` refers to the defining
> class and so should bind to Foo's values for A and C.
> PHP5's result is at least rationally viable, although it effectively
> redefines `self::` to the semantics of `static::` just for this case.
> PHP7's result is... well, I can imagine how it occurs, but it can't be
> called correct by any measure.
>
> Opinions on the right thing to do here?
> a) Leave it alone because it's been that way since 7.0
> b) Revert to php5 behavior
> c) Match HHVM's behavior
>
> I vote C because that's the semantic meaning of self:: and we should
> respect PHP's own language rules.
> Barring that, I'd be okay with B as it's at least explainable without
> too much mental gymnastics.
> I straight up veto A.  That's just cray-cray.
>
> -Sara
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to