-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Labels
Description
Description
The following code: (see https://3v4l.org/jnJJe#v8.4.4)
<?php
final class SomeAction
{
public function __construct(
public ?string $powerOfAttorneyDate = null {
set => $value === '' ? null : $value;
},
) {
}
}
$data = new SomeAction('2025-01-01');
echo "powerOfAttorneyDate is included when printing the obj:\n";
echo print_r($data, true);
echo "powerOfAttorneyDate is missing (bug) when using get_object_vars:\n";
echo print_r(get_object_vars($data), true);
echo "powerOfAttorneyDate is included when using foreach on the object:\n";
foreach ($data as $name => $value) {
echo $name . ' => ' . $value;
}
Resulted in this output:
powerOfAttorneyDate is included when printing the obj:
SomeAction Object
(
[powerOfAttorneyDate] => 2025-01-01
)
powerOfAttorneyDate is missing (bug) when using get_object_vars:
Array
(
)
powerOfAttorneyDate is included when using foreach on the object:
powerOfAttorneyDate => 2025-01-01
But I expected this output instead:
powerOfAttorneyDate is included when printing the obj:
SomeAction Object
(
[powerOfAttorneyDate] => 2025-01-01
)
powerOfAttorneyDate is missing (bug) when using get_object_vars:
Array
(
[powerOfAttorneyDate] => 2025-01-01
)
powerOfAttorneyDate is included when using foreach on the object:
powerOfAttorneyDate => 2025-01-01
PHP Version
PHP 8.4.4
Operating System
No response