Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FrameworkConfig::session() and FrameworkConfig::router() return types seems to be wrong #60763

Open
@danrot

Description

@danrot

Symfony version(s) affected

7.2.3

Description

I tried to use the FrameworkConfig class in a Symfony PHP configuration, but PHPStan complains about it. I am happy to provide a fix, once I know how that should look like.

How to reproduce

When I have a configuration file like the following:

<?php

declare(strict_types=1);

use Symfony\Config\FrameworkConfig;

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

PHPStan complains with an error like the following:

------ --------------------------------------------------------------------------------------------- 
  Line   config/packages/routing.php                                                                  
 ------ --------------------------------------------------------------------------------------------- 
  9      Call to an undefined method                                                                  
         Symfony\Config\Framework\RouterConfig|Symfony\Config\FrameworkConfig::strictRequirements().  
         🪪  method.notFound                                                                          
 ------ ---------------------------------------------------------------------------------------------

A similar thing is happening with $framework->session(). I am not sure why it is only happening for some of the methods though.

Possible Solution

Fix the return type of the generated FrameworkConfig file to work properly with PHPStan.

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