Skip to content

Enable dereferencable new on default 8.4.0-dev profile (#24755) - #24761

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-24755-new-without-parens
Jul 29, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-24755-new-without-parens

Conversation

@PurHur

@PurHur PurHur commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Switch CompilerVersion::supportsDereferencableNewWithoutOuterParens() from version_compare(languageProfileVersion(), '8.4.0') to isForwardProfileAtLeast('8.4.0') so PHP 8.4 new Class()->method() works on the default 8.4.0-dev build without setting PHP_COMPILER_PROFILE=8.4.
  • Existing desugar/rejector pipeline unchanged; PHP_COMPILER_PROFILE=8.2 still rejects like Zend ≤8.3.
  • Add issue repro + compliance guard for default-profile success.

Closes #24755

php-src reference

Zend/zend_language_parser.y — RFC new_without_parentheses

Verification

# Issue repro (no PROFILE env)
php bin/vm.php test/repro/issue_24755_new_without_parens.php
# built

php bin/vm.php -r 'class Builder { public function build(): string { return "built"; } } echo new Builder()->build(), "\n";'
# built

# Unit tests
vendor/bin/phpunit test/unit/NewDereferenceableSyntaxRejectorTest.php test/unit/CompilerVersionGateTest.php --filter "DereferencableNew|NewDereferenceable"
# OK (7 tests)

# Compliance
vendor/bin/phpunit --filter new_without_parens_default_profile test/compliance/VMTest.php
# OK (1 test)

./script/ci-fast.sh
# OK

Not run: full ci-local.sh, differential sweep (language gate only; no lowering change).

Made with Cursor

).

Switch supportsDereferencableNewWithoutOuterParens() to isForwardProfileAtLeast('8.4.0')
so `new Class()->method()` parses without PHP_COMPILER_PROFILE=8.4; PROFILE=8.2 still rejects.

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: PHP 8.4 "new" in expressions without parentheses — parse error (Zend/zend_language_parser.y)

1 participant