Skip to content

feat: parse typed class constants (PHP 8.3 const TYPE NAME = ...)#465

Open
chadmandoo wants to merge 2 commits into
illegalstudio:mainfrom
chadmandoo:upstream-pr/typed-class-constants
Open

feat: parse typed class constants (PHP 8.3 const TYPE NAME = ...)#465
chadmandoo wants to merge 2 commits into
illegalstudio:mainfrom
chadmandoo:upstream-pr/typed-class-constants

Conversation

@chadmandoo

Copy link
Copy Markdown
Contributor

PHP 8.3 typed class constants (private const string X = '…') failed to parse ("Expected '=' after class constant name"). Accept an optional type expression between const and the constant name in class-like bodies; the declared type is validated against the initializer.

Found compiling real-world strict-typed code (a PHP 8.5 codebase with ~42 such constants across 15 files). Byte-parity vs PHP 8.5 + parser regression tests.

chadmandoo added a commit to chadmandoo/elephc that referenced this pull request Jul 10, 2026
… of illegalstudio#465 onto v0.26.1

Speculatively parse+discard a declared type between const and the name at
both the class-body and interface-body sites (ClassConst carries no type;
byte-parity with PHP). Ports our PR illegalstudio#465 onto the v0.26.1 EIR base (the
straight cherry-pick was empty due to parser context drift). Re-port R1 of
elephc epic #589.
chadmandoo added a commit to chadmandoo/elephc that referenced this pull request Jul 10, 2026
… of illegalstudio#465 onto v0.26.1

Speculatively parse+discard a declared type between const and the name at
both the class-body and interface-body sites (ClassConst carries no type;
byte-parity with PHP). Ports our PR illegalstudio#465 onto the v0.26.1 EIR base (the
straight cherry-pick was empty due to parser context drift). Re-port R1 of
elephc epic #589.
chadmandoo added a commit to chadmandoo/elephc that referenced this pull request Jul 11, 2026
… of illegalstudio#465 onto v0.26.1

Speculatively parse+discard a declared type between const and the name at
both the class-body and interface-body sites (ClassConst carries no type;
byte-parity with PHP). Ports our PR illegalstudio#465 onto the v0.26.1 EIR base (the
straight cherry-pick was empty due to parser context drift). Re-port R1 of
elephc epic #589.
@chadmandoo chadmandoo force-pushed the upstream-pr/typed-class-constants branch from ad1203a to d33a047 Compare July 11, 2026 13:45
@chadmandoo chadmandoo force-pushed the upstream-pr/typed-class-constants branch from d33a047 to 6e4beee Compare July 11, 2026 13:54
@github-actions github-actions Bot added area:parser Touches parsing or AST construction. size:xs Very small pull request. type:feature Introduces new user-visible behavior or capabilities. labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:parser Touches parsing or AST construction. size:xs Very small pull request. type:feature Introduces new user-visible behavior or capabilities.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant