Closed
Description
Symfony version(s) affected
6.x, 7.x
Description
I am receiving the following error:
Error {#2549
#message: "Typed property Symfony\Component\Config\Loader\Loader::$resolver must not be accessed before initialization"
#code: 0
#file: "D:\inetroot\websites\demo\vendor\symfony\config\Loader\Loader.php"
#line: 60
}
The line in question is: $loader = null === $this->resolver ? false : $this->resolver->resolve($resource, $type);
, however, the defined property is protected LoaderResolverInterface $resolver;
(line 35).
How to reproduce
class MyBundle extends AbstractBundle
{
public function configure(DefinitionConfigurator $definition): void
{
$definition->import(dirname(__DIR__) . '/config/*.yaml', 'yaml');
}
}
Please disregard the fact that I'm attempting to load YAML in the below reproduction code. Apparently there isn't built-in support for loading YAML configuration in bundles...
Possible Solution
I suggest the either of the following changes:
- Symfony 6.x / 7.x :
$loader = isset($this->resolver) ? $this->resolver->resolve($resource, $type) : false;
- Symfony 7.x:
protected ?LoaderResolverInterface $resolver
andpublic function getResolver(): ?LoaderResolverInterface
Additional Context
No response