[php-src] Issue #8232: `var_export()` combined with `enum` produces code unsuitable for inclusion in namespaces

From: Date: Mon, 21 Mar 2022 12:33:50 +0000
Subject: [php-src] Issue #8232: `var_export()` combined with `enum` produces code unsuitable for inclusion in namespaces
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240433@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8232 Author: Ocramius ### Description Following code: https://3v4l.org/MKPpJ ```php <?php namespace A; enum Foo { case BAR; } $bar = var_export(Foo::BAR, true); echo <<<PHP <?php namespace Generated\Code; echo $bar; PHP; ``` Resulted in this output: ``` <?php namespace Generated\Code; echo A\Foo::BAR; ``` But I expected this output instead: ``` <?php namespace Generated\Code; echo \A\Foo::BAR; ``` To be more specific: ```diff <?php namespace Generated\Code; -echo A\Foo::BAR; +echo \A\Foo::BAR; ``` This allows for generated PHP expressions (primary use-case of var_export()) to contain enums. Ref: https://github.com/Ocramius/ProxyManager/issues/754#issuecomment-1073828730 ### PHP Version 8.0.4 ### Operating System _No response_

« previous php.bugs (#240433) next »