Skip to content

SessionInterface::getFlashBag() error reported by PHP Stan #39222

Closed
@DavidGarciaCat

Description

@DavidGarciaCat

Symfony version(s) affected:

Both 4.x and 5.x

Description

Symfony cannot inject by default the Session service because it's not mapped as a service, so we need to inject the SessionInterface. However, PHP Stan reports an error when calling getFlashBag()

Call to an undefined method Symfony\Component\HttpFoundation\Session\SessionInterface::getFlashBag().

How to reproduce

Inject the SessionInterface and then call the getFlashBag() method. Finally, run vendor/bin/phpstan analyse src -l 2 for a level 2 analysis, where we should get that error message.

Possible Solution

Define the getFlashBag() method into the SessionInterface.

Alternatively, maybe you can give another option to pass this error reported by PHP Stan without adding extra annotations to ignore these lines once after another when they are in use in several services.

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