Skip to content

Catch accessing the session in a constructor #292

@ThomasLandauer

Description

@ThomasLandauer

With a constructor like this:

use Symfony\Component\HttpFoundation\RequestStack;

public function __construct(RequestStack $requestStack)
{
    $this->session = $requestStack->getSession();
}

... phpstan is crashing with:

Internal error: Internal error: There is currently no session available. in file ...

It looks like it's not allowed to access the session in a constructor; I opened a PR at symfony-docs: symfony/symfony-docs#16985

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions