> On Mar 31, 2022, at 11:03, Christoph M. Becker <cmbecker69@gmx.de> wrote:
>
> On 31.03.2022 at 17:45, Ilija Tovilo wrote:
>
>> We've had two bug reports for var_export not working for enums. The
>> reason for that is that var_export does not add a leading backslash to
>> names of enums. This will cause them to be resolved as
>> `\CurrentNamespace\EnumNamespace\EnumName` instead of just
>> `\EnumNamespace\EnumName`.
>>
>> enum A {
>> case B;
>> }
>>
>> echo var_export(A::B, true), "\n";
>>> A::B
>>
>>
>> This is a problem for things like Doctrines ProxyGenerator that embeds
>> the result of var_export in classes with namespaces
>> (https://github.com/doctrine/common/pull/955). The Doctrine team
>> resolved this by adding a `use` of the enum at the top of the file but
>> that really shouldn't be necessary.
>>
>> The same issue already exists for classes.
>>
>> class C {}
>>
>> echo var_export(new C(), true), "\n";
>>> C::__set_state(array(
>>> ))
>>
>> https://bugs.php.net/bug.php?id=64554
>>
>> Marco Pivetta created a PR that adds leading backslash to all class or
>> enum names of var_export. Adding a backslash will make the code work
>> both inside or outside namespaces.
>> https://github.com/php/php-src/pull/8233
>>
>> To avoid disruption, I'm proposing to merge this into PHP 8.2 only.
>> Unless anybody has any objections to this change I will merge it in a
>> few weeks.
>
> It might be worthwhile to point out that this issue already came up
> years ago, and after some discussion[1] the idea was rejected back then.
>
> That said, I'm not against changing this now, but would not want to do
> that for any of the stable PHP versions. Targeting PHP 8.2 is fine for me.
>
> [1] <https://externals.io/message/67008>
>
> --
> Christoph M. Becker
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
Look, just re-enable spacebar overheating, my workflow works for me.
j/k - I'd vote in favor of this. There may well be people relying on it in some way, but it's broken IMO.
FTR; I'd also vote in favor of a ReflectionVariable kind of interface to allow wider control over the output.
-Sara