Description
The following code:
<?php
class TryMe
{
public function __construct(
protected string $id,
protected string $name = 'default name',
)
{
var_dump(get_class_vars(static::class)); die();
}
}
new TryMe( 'something' );
Resulted in this output:
array(2) {
["id"]=>
NULL
["name"]=>
NULL
}
But I expected this output instead:
array(2) {
["id"]=>
NULL
["name"]=>
string(12) "default name"
}
I thought promoted properties were supposed to be the same as regular properties and just save us some writing for initializations but it introduced breaking changes.
PHP Version
PHP 8.1.30
Operating System
No response