Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use stubfile extension for PasswordUpgraderInterface #335

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

Conversation

@VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Feb 19, 2023

I'm trying to solve #333
@kevinpapst can you try this branch ?

Closes #333

Copy link

@VincentLanglet Thank you! Works for SF 4.4. But with SF 6.2 I have other issues now.

Below output is from the SF 4.4 project, Symfony 6.2 follows later:

Below:

$ vendor/bin/phpstan analyse src -c phpstan.neon --level=5
 951/951 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
 Line Security/DoctrineUserProvider.php 
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
 80 Parameter $user of method App\Security\DoctrineUserProvider::upgradePassword() has invalid type Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface. 
 ------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
 Line Security/KimaiUserProvider.php 
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
 87 Parameter $user of method App\Security\KimaiUserProvider::upgradePassword() has invalid type Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface. 
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
 
 [ERROR] Found 2 errors 
Script vendor/bin/phpstan analyse src -c phpstan.neon --level=5 handling the phpstan event returned with error code 1

Composer update:

$ composer update 
Loading composer repositories with package information Restricting packages listed in "symfony/symfony" to "4.4.*"
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
 - Upgrading phpstan/phpstan-symfony (1.2.23 => dev-PasswordAuthenticatedUserStubFilesExtension d879c1a)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
 - Downloading phpstan/phpstan-symfony (dev-PasswordAuthenticatedUserStubFilesExtension d879c1a)
 - Upgrading phpstan/phpstan-symfony (1.2.23 => dev-PasswordAuthenticatedUserStubFilesExtension d879c1a): Extracting archive
Package sensio/framework-extra-bundle is abandoned, you should avoid using it. Use Symfony instead.
Package symfony/debug is abandoned, you should avoid using it. Use symfony/error-handler instead.
Package symfony/inflector is abandoned, you should avoid using it. Use EnglishInflector from the String component instead.
Package php-cs-fixer/diff is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
139 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Afterwards:

$ vendor/bin/phpstan analyse src -c phpstan.neon --level=5
 951/951 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
 
 [OK] No errors 

@VincentLanglet VincentLanglet force-pushed the PasswordAuthenticatedUserStubFilesExtension branch from 20a2e46 to 4243db4 Compare February 19, 2023 17:04
Copy link
Contributor Author

@VincentLanglet Thank you! Works for SF 4.4.

Great

But with SF 6.2 I have other issues now.

Certainly because I used class_exists on an interface so the stub wasn't loaded anymore.
I added a commit to fix it.

Copy link

kevinpapst commented Feb 19, 2023
edited
Loading

Yep 👍 The lastest commit fixed the SF 6.2 issues. And SF 4.4 still works.

I assume your branch is behind 1.2.23, right?

Because I get PHPDoc tag @extends contains generic type Symfony\Component\Security\Core\Authorization\Voter\Voter<string, App\Entity\Activity> but class Symfony\Component\Security\Core\Authorization\Voter\Voter is not generic. in SF 6.2, which worked in 1.2.23.

@VincentLanglet VincentLanglet force-pushed the PasswordAuthenticatedUserStubFilesExtension branch from 4243db4 to f961a75 Compare February 19, 2023 17:12
Copy link
Contributor Author

Yep 👍 The lastest commit fixed the SF 6.2 issues. And SF 4.4 still works.

Great !

I assume your branch is behind 1.2.23, right?

Because I get PHPDoc tag @extends contains generic type Symfony\Component\Security\Core\Authorization\Voter\Voter<string, App\Entity\Activity> but class Symfony\Component\Security\Core\Authorization\Voter\Voter is not generic. in SF 6.2, which worked in 1.2.23.

Certainly. I rebased my branch ;)

Copy link

@kevinpapst kevinpapst left a comment
edited
Loading

Choose a reason for hiding this comment

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

Alright, now SF 6.2 is green as well. Fixed 👍

Thank you for your quick support, very much appreciated!


public function getFiles(): array
{
if (!interface_exists('Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface')) {
Copy link
Member

@ondrejmirtes ondrejmirtes Feb 19, 2023

Choose a reason for hiding this comment

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

Runtime concerns are irrelevant for PHPStan, you need to ask ReflectionProvider. If ReflectionProvider cannot be injected, then ask Reflector, as phpstan-doctrine does: https://github.com/phpstan/phpstan-doctrine/blob/1.3.x/src/Stubs/Doctrine/StubFilesExtensionLoader.php

Copy link

@kevinpapst kevinpapst Feb 19, 2023

Choose a reason for hiding this comment

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

Not that I understand anything about PHPStan internals, but isn't that the "same" as in : https://github.com/phpstan/phpstan-symfony/blob/1.2.x/src/Symfony/InputBagStubFilesExtension.php#L13 ?

Copy link
Member

@ondrejmirtes ondrejmirtes Feb 19, 2023

Choose a reason for hiding this comment

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

That is reaaaaaally old and should be fixed too.

kevinpapst reacted with eyes emoji
Copy link
Contributor Author

@VincentLanglet VincentLanglet Feb 20, 2023

Choose a reason for hiding this comment

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

Done for both StubFilesExtension.

Copy link
Contributor Author

Friendly ping @ondrejmirtes, is this PR ok to you ?
Thanks.

@ondrejmirtes ondrejmirtes merged commit db81b18 into phpstan:1.2.x Mar 30, 2023
Copy link
Member

Thank you.

VincentLanglet reacted with thumbs up emoji

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

Reviewers

@ondrejmirtes ondrejmirtes ondrejmirtes approved these changes

+1 more reviewer

@kevinpapst kevinpapst kevinpapst approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Generics for PasswordUpgraderInterface fail with SF < 5.3

AltStyle によって変換されたページ (->オリジナル) /