Closed
Description
Symfony version(s) affected
6.2
Description
When using PhpFilesAdater
it's impossible to restore cached enums because of invalid namespace resolving. I have found that before file export this adapter is replacing VarExporter
component fully qualified class names to namespace declaration:
$value = str_replace('\Symfony\Component\VarExporter\Internal\\', '', $value);
$value = "namespace Symfony\Component\VarExporter\Internal;\n\nreturn \$getExpiry ? {$expiry} : {$value};";
This generates following error on cache restore:
Fatal error: Uncaught Error: Class "Symfony\Component\VarExporter\Internal\Bug\Deep\Enum\Ns\FooEnum" not found in /xxx/M++2dAPuxQXg9Krv80eQ:16
How to reproduce
I have prepared repository with example code which can be used to reproduce this issue:
- clone https://github.com/jasiolpn/symfony-php-files-cache-adapter-enum-bug
- install dependencies via composer
- run
reproduce.php
file twice. First run will generate file with cached content, second one will try to resore this content but it will fail with mentioned error
Possible Solution
No response
Additional Context
No response