Closed
Description
Symfony version(s) affected: 4.4.0
Description & How to reproduce
I'm running PHP 7.4 RC6 on CircleCI and discovered a weird error.
I'm using DoctrineDataFixturesExtension
that defines it's extension using an anonymous class:
https://github.com/BehatExtension/DoctrineDataFixturesExtension/blob/0304b9df7037993cde56dbe38eef31b8d2717854/src/Bundle/BehatDoctrineDataFixturesExtensionBundle.php#L21-L26
When I run a unit test that uses KernelTestCase
I get the following error:
ReflectionException: Class "Configuration" not found while loading "\Configuration".
vendor/symfony/config/Resource/ClassExistenceResource.php:150
vendor/symfony/config/Resource/ClassExistenceResource.php:78
vendor/symfony/dependency-injection/ContainerBuilder.php:353
vendor/symfony/dependency-injection/Extension/Extension.php:86
vendor/symfony/dependency-injection/Compiler/MergeExtensionConfigurationPass.php:68
vendor/symfony/http-kernel/DependencyInjection/MergeExtensionConfigurationPass.php:39
vendor/symfony/dependency-injection/Compiler/Compiler.php:94
vendor/symfony/dependency-injection/ContainerBuilder.php:762
vendor/symfony/http-kernel/Kernel.php:625
vendor/symfony/http-kernel/Kernel.php:136
vendor/symfony/framework-bundle/Test/KernelTestCase.php:79
tests/Domain/Command/DeserializableCommand.php:41
I think the problem is here:
I added some var_dump
calls:
// line 83
string(161) "class@anonymous�vendor/behat-extension/doctrine-data-fixtures-extension/src/Bundle/BehatDoctrineDataFixturesExtensionBundle.php0x7f4f3938801a"
// line 84
string(14) "\Configuration"
I think this must be related to the anonymous class.
Is this even supported? And if it is, how should we handle this case properly?
Possible Solution
Would an early return like this help?
$reflection = new \ReflectionClass($this);
if ($reflection->isAnonymous()) {
return null;
}