Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy