8000 FrameworkConfig::router()::strictRequirements(null): final value is true · Issue #45782 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
FrameworkConfig::router()::strictRequirements(null): final value is true #45782
Closed
@steevanb

Description

@steevanb

Symfony version(s) affected

6.0.5

Description

When i change yaml configuration file format to PHP in config/packages directory, i have this code for routing.php:

return static function (FrameworkConfig $config): void {
    $config
        ->router()
        ->strictRequirements(null);
};

But when i see var/cache/devSymfony/Framework/RouterConfig.php, i have this code in toArray():

        if (null !== $this->strictRequirements) {
            $output['strict_requirements'] = $this->strictRequirements;
        }

Problem: final value will not be null as configured and expected, but true, because it's the default value.
I can configure it in yaml, it works, and it's the default configuration when we create a project:

framework:
    router:
        strict_requirements: null

How to reproduce

Create a new project, then add in src/Kernel.php to read PHP configuration files:

    private function configureContainer(
        ContainerConfigurator $container,
        LoaderInterface $loader,
        ContainerBuilder $builder
    ): void {
        $configDir = $this->getConfigDir();

        $container->import($configDir.'/{packages}/*.yaml');
        $container->import($configDir.'/{packages}/'.$this->environment.'/*.yaml');

        $container->import($configDir.'/{packages}/*.php');
        $container->import($configDir.'/{packages}/'.$this->environment.'/*.php');

        if (is_file($configDir.'/services.yaml')) {
            $container->import($configDir.'/services.yaml');
            $container->import($configDir.'/{services}_'.$this->environment.'.yaml');
        } else {
            $container->import($configDir.'/{services}.php');
        }
    }

Another little problem: in the documentation (https://symfony.com/doc/current/configuration.html#using-php-configbuilders) we may think PHP configuration files are always readed, but that's not the case, we need to modify the Kernel to take this files into account.

Possible Solution

Allow passing null when configuration allow this value?

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned
    3D90

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0