Skip to content
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

Add getSession stub #242

Merged
merged 4 commits into from
Jan 30, 2022
Merged

Add getSession stub #242

merged 4 commits into from
Jan 30, 2022

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Jan 29, 2022

Hi @seferov

There was the following discussion on phpstan-symfony phpstan/phpstan-symfony#233.

For 99% of the symfony users, $request->getSession() is returning a Session with the getFlashbag method which is not in SessionInterface. In the commit phpstan/phpstan-symfony@012305d, phpstan update the stub to make people life easier and avoiding the extract check instanceof Session.

I recommend psalm plugin to do the same because using both plugin gives the following issue.
-> without the check assert($session instanceof Session), psalm say the getFlashbag method doesn't exists
-> with the check, phpstan say the assert($session instanceof Session) check is always true.

@VincentLanglet VincentLanglet marked this pull request as ready for review January 29, 2022 10:32
@@ -92,6 +97,8 @@ jobs:
symfony-version: 6
- php-version: 8.0
symfony-version: 3
- php-version: 8.0
symfony-version: 6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VincentLanglet Why exclude Symfony6 with PHP8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's currently a big failure because codeception doesn't support symfony 6.
https://github.com/Codeception/Codeception/blob/4.1/composer.json#L24

I can add back if you prefer, it will just mean the ci will always fail.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no problem, once codeception dependency is fixed, we can remove the ignore

@seferov
Copy link
Member

seferov commented Jan 30, 2022

For 99% of the symfony users, $request->getSession() is returning a Session with the getFlashbag method which is not in SessionInterface. In the commit phpstan/phpstan-symfony@012305d, phpstan update the stub to make people life easier and avoiding the extract check instanceof Session.

I recommend psalm plugin to do the same because using both plugin gives the following issue. -> without the check assert($session instanceof Session), psalm say the getFlashbag method doesn't exists -> with the check, phpstan say the assert($session instanceof Session) check is always true.

Thanks, looks good 👍

@VincentLanglet VincentLanglet mentioned this pull request Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants