-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed as not planned
Description
Description
Essentially #16793 also exists with PHP native classes as pointed out in #16793 (comment)
The following code:
https://3v4l.org/ZS1MZ#v8.3.13
<?php
$dt = new DateTime("now");
var_dump($dt);
var_dump(property_exists($dt, "timezone"));
var_dump($dt->timezone);
Resulted in this output:
object(DateTime)#1 (3) {
["date"]=>
string(26) "2024-11-18 23:33:30.008856"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
bool(false)
Warning: Undefined property: DateTime::$timezone in /in/ZS1MZ on line 6
NULL
But I expected this output instead:
Either the timezone
property should be marked as private or property_exists
and direct access to it shouldn't fail
I assume this behavior is the result of https://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.debuginfo - however I think this should be marked in the dump, since this is unexpected at least. Since this is applied in PHP Error/Exception stack traces too, this can definitely be misleading.
Possibly there should be a way to disable that for stack traces?
PHP Version
8.3
Operating System
No response