Skip to content

Language: new readonly class(...) constructor args — curly-brace guard (#17467) - #17474

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-17467-readonly-anonymous-ctor-args
Jul 9, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-17467-readonly-anonymous-ctor-args

Conversation

@PurHur

@PurHur PurHur commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • CurlyBraceOffsetRejector now exempts new readonly class(...) ctor-arg parentheses from the legacy curly-brace offset fatal (same path as new class(...)).
  • Adds maintainer repro and compliance PHPT for PHP 8.4 forward profile.

Closes #17467

php-src reference

  • Zend/zend_compile.c — new readonly class with constructor argument list (PHP 8.4)

PHP implementation

  • lib/CurlyBraceOffsetRejector.php — token scan recognizes T_NEW + T_READONLY + T_CLASS + ( before class body {

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && export PHP_COMPILER_PROFILE=8.4 && php bin/vm.php test/repro/maintainer_gap_readonly_anonymous_ctor_args.php'
# 5

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit test/unit/CurlyBraceOffsetRejectorTest.php --filter CurlyBraceOffsetRejector'
# OK (8 tests)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && export PHP_COMPILER_PROFILE=8.4 && vendor/bin/phpunit test/compliance/VMTest.php --filter readonly_anonymous_ctor_args'
# OK (1 test)

Made with Cursor

)

CurlyBraceOffsetRejector treated `new readonly class(5) {` as legacy
`expr{offset}` syntax because only `new class(...)` was exempted. Recognize
the readonly modifier in the anonymous-class ctor-args path and add repro +
compliance guard.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Language: new readonly class(...) constructor args — parse rejected (Zend/zend_compile.c, PHP 8.4)

1 participant