Skip to content

Improve security factory signatures #49783

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

Merged
merged 1 commit into from
Mar 25, 2023

Conversation

yguedidi
Copy link
Contributor

Q A
Branch? 6.3
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

Adds key type to the config parameter of security factories

@carsonbot carsonbot added this to the 6.3 milestone Mar 23, 2023
@yguedidi yguedidi changed the title Improve security factory signatures [SecurityBundle] Improve security factory signatures Mar 23, 2023
@@ -38,6 +38,8 @@ public function addConfiguration(NodeDefinition $builder);
/**
* Creates the authenticator service(s) for the provided configuration.
*
* @param array<string, mixed> $config
Copy link
Member

Choose a reason for hiding this comment

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

Is it valuable? It may not help our users. Or maybe it is for static analysis tools?
We try to only add phpdocs when they bring value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my bad, missed adding a precise context! thanks for asking!

Or maybe it is for static analysis tools?

Yes it's for static analysis (in my case PHPStan). We implement this interface, and with PHPStan at level 6 with strict-rules, especially the reportMaybesInMethodSignatures: true parameter, we get these errors:

 ------ ------------------------------------------------------------------------------------------------------------------------- 
  Line   src/App/DependencyInjection/Security/Factory/MyFactory.php                                      
 ------ ------------------------------------------------------------------------------------------------------------------------- 
  17     Parameter #3 $config (array<string, mixed>) of method                                                                    
         App\DependencyInjection\Security\Factory\MyFactory::createAuthenticator()                       
         should be contravariant with parameter $config (array) of method                                                         
         Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface::createAuthenticator()  
  25     Parameter #3 $config (array<string, mixed>) of method                                                                    
         App\DependencyInjection\Security\Factory\MyFactory::createListeners()                           
         should be contravariant with parameter $config (array) of method                                                         
         Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FirewallListenerFactoryInterface::createListeners()   
 ------ ------------------------------------------------------------------------------------------------------------------------- 

@carsonbot carsonbot changed the title [SecurityBundle] Improve security factory signatures Improve security factory signatures Mar 25, 2023
@fabpot
Copy link
Member

fabpot commented Mar 25, 2023

Thank you @yguedidi.

@fabpot fabpot merged commit 1cea7c6 into symfony:6.3 Mar 25, 2023
@yguedidi yguedidi deleted the improve-security-factory-signatures branch March 26, 2023 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants