Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Config] Error accessing uninitialized $resolver in Loader #57066

Copy link
Copy link
Closed
@radar3301

Description

@radar3301
Issue body actions

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:

  1. Symfony 6.x / 7.x : $loader = isset($this->resolver) ? $this->resolver->resolve($resource, $type) : false;
  2. Symfony 7.x: protected ?LoaderResolverInterface $resolver and public function getResolver(): ?LoaderResolverInterface

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.