You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AST->string does not reproduce constructor property promotion correctly #17101
Fatal error: Uncaught AssertionError: assert(false && new class(true) {
public function __construct(bool $boolVal) {
}
}) in /in/rM9Hi:3
Stack trace:
#0 /in/rM9Hi(3): assert(false, 'assert(false &&...')
#1 {main}
thrown in /in/rM9Hi on line 3
But I expected this output instead (note the public in the constructor property)
Fatal error: Uncaught AssertionError: assert(false && new class(true) {
public function __construct(public bool $boolVal) {
}
}) in /in/rM9Hi:3
Stack trace:
#0 /in/rM9Hi(3): assert(false, 'assert(false &&...')
#1 {main}
thrown in /in/rM9Hi on line 3
Yeah this is definitely a bug, likely overlooked because anonymous classes are the only way you can print a function that has a promoted property as argument.
Activity
DanielEScherzer commentedon Dec 9, 2024
Discovered via the
zend_test_compile_to_ast()function I'm adding as part of #16952 but exists in the current functionalityAlso fails with other promoted modifiers, like asymmetric visibility
ndossche commentedon Dec 9, 2024
Yeah this is definitely a bug, likely overlooked because anonymous classes are the only way you can print a function that has a promoted property as argument.
ndossche commentedon Dec 12, 2024
The fix for the visibility is simple, but the hooks are also not outputted so I'll try to tackle that too.
ndossche commentedon Dec 12, 2024
Another bug: the hook type is incorrect in AST printing for the following case:
Add test for phpGH-17101
Add test for GH-17101
[ci skip] News for GH-17101
Merge branch 'PHP-8.4'
ndossche commentedon Dec 17, 2024
Fixed via 6f41bfd..97f44b7