Skip to content

fix(translator): reject static/instance property redeclaration mismatch - #57

Open
AlessioGiacobbe wants to merge 1 commit into
swoole:masterfrom
AlessioGiacobbe:split/static-property-override
Open

fix(translator): reject static/instance property redeclaration mismatch#57
AlessioGiacobbe wants to merge 1 commit into
swoole:masterfrom
AlessioGiacobbe:split/static-property-override

Conversation

@AlessioGiacobbe

Copy link
Copy Markdown
Contributor

Redeclaring a static property as non-static (or the reverse) compiled: class A { public static int $x = 1; } class B extends A { public int $x = 2; } — Zend fatals "Cannot redeclare static A::$x as non static B::$x". checkPropertyOverride compared type, visibility, readonly, and final, but never the STATIC flag.

Both directions now rejected with Zend's message.

Part of the split of #39.

checkPropertyOverride() compared type, visibility, set-visibility,
readonly and final between a child property and the parent's, but never
Modifiers::STATIC. Redeclaring `public static int $x` as
`public int $x` (or the reverse) was accepted, while Zend fatals with
"Cannot redeclare static A::$x as non static B::$x" (and "Cannot
redeclare non static ... as static ..." in the other direction):
static and instance properties are different kinds of storage and can
never override one another.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant