Skip to content

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

Merged
matyhtf merged 1 commit into
swoole:masterfrom
AlessioGiacobbe:split/static-property-override
Sep 2, 2026
Merged

fix(translator): reject static/instance property redeclaration mismatch#57
matyhtf merged 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.

@matyhtf matyhtf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The static/instance storage-kind check is correctly placed in the existing property override path, rejects both mismatch directions with stable diagnostics, and leaves matching redeclarations unchanged. No blocking issue found.

@matyhtf
matyhtf merged commit 0f1efb5 into swoole:master Sep 2, 2026
14 checks passed
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.

2 participants