-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] add union types #41911
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
[Security] add union types #41911
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
|
||
namespace Symfony\Component\Security\Core\Authentication\Token; | ||
|
||
use Symfony\Component\Security\Core\User\UserInterface; | ||
|
||
/** | ||
* Token representing a user who temporarily impersonates another one. | ||
* | ||
|
@@ -22,13 +24,13 @@ class SwitchUserToken extends UsernamePasswordToken | |
private $originatedFromUri; | ||
|
||
/** | ||
* @param string|object $user The username (like a nickname, email address, etc.), or a UserInterface instance or an object implementing a __toString method | ||
* @param mixed $credentials This usually is the password of the user | ||
* @param string|null $originatedFromUri The URI where was the user at the switch | ||
* @param $user The username (like a nickname, email address, etc.), or a UserInterface instance or an object implementing a __toString method | ||
* @param $credentials This usually is the password of the user | ||
* @param $originatedFromUri The URI where was the user at the switch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it valid to omit the type? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for phpstorm at least it is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://docs.phpdoc.org/3.0/guide/references/phpdoc/tags/param.html
[…]
Yes, the type is optional. But I had to look it up myself as well and I'm not yet sure if I like that notation. Maybe we just need to get used to it. 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If popular IDEs support it, I'm fine with it personally. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once you start using PHP attributes for everything ... you want to use it even to describe arguments. I wish this worked: #[Param('user', 'The username (like a nickname, email address, etc.), or a ...')]
#[Param('credentials', 'This usually is the password of the user')]
#[Param('originatedFromUri', 'The URI where was the user at the switch')]
public function __construct(string|\Stringable|UserInterface $user, mixed $credentials, /* ... */, string $originatedFromUri = null)
{
// ...
} Or even better, this: public function __construct(
#[Param('The username (like a nickname, email address, etc.), or a ...')]
private string|\Stringable|UserInterface $user,
#[Param('This usually is the password of the user')]
private mixed $credentials,
// ...
#[Param('The URI where was the user at the switch')]
private string $originatedFromUri = null)
{
} But support for attributes in PhpDocumentor doesn't seem a priority: phpDocumentor/Reflection#185 |
||
* | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function __construct($user, $credentials, string $firewallName, array $roles, TokenInterface $originalToken, string $originatedFromUri = null) | ||
public function __construct(string|\Stringable|UserInterface $user, mixed $credentials, string $firewallName, array $roles, TokenInterface $originalToken, string $originatedFromUri = null) | ||
{ | ||
parent::__construct($user, $credentials, $firewallName, $roles); | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.