-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mark nonexistent properties from __debugInfo() in var_dump #16852
Comments
Hi @kkmuffme! Yeah, still would still not consider this a bug.
As mentioned, there is no such property.
We can treat this part as a feature request. However, it's worth noting that the output of |
The "bug" is that it's currently not possible to distinguish between public properties and properties set with
This is something completely different - these are not in var dump now either and that doesn't need to be changed. Tangentially related: (how) is the asymmetric visibility in PHP 8.4 marked in var_dump? |
You might have misunderstood what I meant. The feature request is that properties that don't exist should be marked accordingly, e.g. through some symbol. But what you're likely implying is that any property that cannot be accessed must be marked. It's possible to access properties without them being explicitly declared, e.g. through
Assuming you mean asymmetric(ly visible) properties, The same as symmetric properties. |
I'm not implying anything :-) I literally mean: for properties currently output in var_dump the visibility should be correctly reported.
Yes, I was working in another language while writing that issue. I guess this would also need improving so the asymmetric visibility is reported correctly? |
I see your point, but as mentioned, once you're using class C {
protected $prop = 'prop';
public function __debugInfo() {
return ['prop' => strtoupper($this->prop)];
}
}
var_dump(new C()); This outputs:
Without the
Marking I think at this point it makes more sense to move the discussion to a more public medium. If you like, you may send an e-mail to the internals mailing list to propose a concrete change, and ask for opinions on it. |
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
Resulted in this output:
But I expected this output instead:
Either the
timezone
property should be marked as private orproperty_exists
and direct access to it shouldn't failI 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
The text was updated successfully, but these errors were encountered: