Skip to content

AST->string does not reproduce constructor property promotion correctly #17101

Description

@DanielEScherzer

Description

The following code:

<?php

assert(false && new class (true) {
    public function __construct( public bool $boolVal ) {}
} );

Resulted in this output:

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

See https://3v4l.org/rM9Hi

PHP Version

PHP 8.2+

Operating System

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions