Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
danrot opened this issue Jun 11, 2025 · 0 comments

Comments

@danrot
Copy link
Contributor

danrot commented Jun 11, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants