diff --git a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php index 64515fac71840..7a6c8327b5d1a 100644 --- a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php @@ -48,7 +48,7 @@ public function __construct(Connection $conn) /** * {@inheritdoc} */ - public function loadTokenBySeries($series) + public function loadTokenBySeries(string $series) { // the alias for lastUsed works around case insensitivity in PostgreSQL $sql = 'SELECT class, username, value, lastUsed AS last_used' @@ -68,7 +68,7 @@ public function loadTokenBySeries($series) /** * {@inheritdoc} */ - public function deleteTokenBySeries($series) + public function deleteTokenBySeries(string $series) { $sql = 'DELETE FROM rememberme_token WHERE series=:series'; $paramValues = ['series' => $series]; @@ -79,7 +79,7 @@ public function deleteTokenBySeries($series) /** * {@inheritdoc} */ - public function updateToken($series, $tokenValue, \DateTime $lastUsed) + public function updateToken(string $series, string $tokenValue, \DateTime $lastUsed) { $sql = 'UPDATE rememberme_token SET value=:value, lastUsed=:lastUsed' .' WHERE series=:series'; diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 648a5190cb7ed..301cb7ff43d69 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -33,7 +33,7 @@ "symfony/property-access": "^4.4|^5.0", "symfony/property-info": "^4.4|^5.0", "symfony/proxy-manager-bridge": "^4.4|^5.0", - "symfony/security-core": "^4.4|^5.0", + "symfony/security-core": "^5.0", "symfony/expression-language": "^4.4|^5.0", "symfony/validator": "^4.4|^5.0", "symfony/translation": "^4.4|^5.0", @@ -49,7 +49,8 @@ "phpunit/phpunit": "<5.4.3", "symfony/dependency-injection": "<4.4", "symfony/form": "<4.4", - "symfony/messenger": "<4.4" + "symfony/messenger": "<4.4", + "symfony/security-core": "<5" }, "suggest": { "symfony/form": "", diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php index f8a101972368f..f6fa66bc9269f 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php @@ -63,7 +63,7 @@ protected function checkAuthentication(UserInterface $user, UsernamePasswordToke /** * {@inheritdoc} */ - protected function retrieveUser($username, UsernamePasswordToken $token) + protected function retrieveUser(string $username, UsernamePasswordToken $token) { $user = $token->getUser(); if ($user instanceof UserInterface) { diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php index 2dadc05012e16..652e6a713e9bc 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php @@ -46,10 +46,8 @@ public function __construct(UserProviderInterface $userProvider, UserCheckerInte /** * Set a query string to use in order to find a DN for the username. - * - * @param string $queryString */ - public function setQueryString($queryString) + public function setQueryString(string $queryString) { $this->queryString = $queryString; } @@ -57,7 +55,7 @@ public function setQueryString($queryString) /** * {@inheritdoc} */ - protected function retrieveUser($username, UsernamePasswordToken $token) + protected function retrieveUser(string $username, UsernamePasswordToken $token) { if (AuthenticationProviderInterface::USERNAME_NONE_PROVIDED === $username) { throw new UsernameNotFoundException('Username can not be null'); diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php index 32f53d5a0e7f4..b1d9705efb67e 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php @@ -109,14 +109,11 @@ public function supports(TokenInterface $token) /** * Retrieves the user from an implementation-specific location. * - * @param string $username The username to retrieve - * @param UsernamePasswordToken $token The Token - * * @return UserInterface The user * * @throws AuthenticationException if the credentials could not be validated */ - abstract protected function retrieveUser($username, UsernamePasswordToken $token); + abstract protected function retrieveUser(string $username, UsernamePasswordToken $token); /** * Does additional checks on the user and token (like validating the diff --git a/src/Symfony/Component/Security/Core/Authentication/RememberMe/InMemoryTokenProvider.php b/src/Symfony/Component/Security/Core/Authentication/RememberMe/InMemoryTokenProvider.php index 71e3b6a8afe54..a1b30443f3573 100644 --- a/src/Symfony/Component/Security/Core/Authentication/RememberMe/InMemoryTokenProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/RememberMe/InMemoryTokenProvider.php @@ -25,7 +25,7 @@ class InMemoryTokenProvider implements TokenProviderInterface /** * {@inheritdoc} */ - public function loadTokenBySeries($series) + public function loadTokenBySeries(string $series) { if (!isset($this->tokens[$series])) { throw new TokenNotFoundException('No token found.'); @@ -37,7 +37,7 @@ public function loadTokenBySeries($series) /** * {@inheritdoc} */ - public function updateToken($series, $tokenValue, \DateTime $lastUsed) + public function updateToken(string $series, string $tokenValue, \DateTime $lastUsed) { if (!isset($this->tokens[$series])) { throw new TokenNotFoundException('No token found.'); @@ -56,7 +56,7 @@ public function updateToken($series, $tokenValue, \DateTime $lastUsed) /** * {@inheritdoc} */ - public function deleteTokenBySeries($series) + public function deleteTokenBySeries(string $series) { unset($this->tokens[$series]); } diff --git a/src/Symfony/Component/Security/Core/Authentication/RememberMe/TokenProviderInterface.php b/src/Symfony/Component/Security/Core/Authentication/RememberMe/TokenProviderInterface.php index 58ac22c2ec2bc..eda4730004414 100644 --- a/src/Symfony/Component/Security/Core/Authentication/RememberMe/TokenProviderInterface.php +++ b/src/Symfony/Component/Security/Core/Authentication/RememberMe/TokenProviderInterface.php @@ -23,31 +23,23 @@ interface TokenProviderInterface /** * Loads the active token for the given series. * - * @param string $series - * * @return PersistentTokenInterface * * @throws TokenNotFoundException if the token is not found */ - public function loadTokenBySeries($series); + public function loadTokenBySeries(string $series); /** * Deletes all tokens belonging to series. - * - * @param string $series */ - public function deleteTokenBySeries($series); + public function deleteTokenBySeries(string $series); /** * Updates the token according to this data. * - * @param string $series - * @param string $tokenValue - * @param \DateTime $lastUsed - * * @throws TokenNotFoundException if the token is not found */ - public function updateToken($series, $tokenValue, \DateTime $lastUsed); + public function updateToken(string $series, string $tokenValue, \DateTime $lastUsed); /** * Creates a new token. diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php index 1e9dbe82df2c4..b18d8152d264e 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php @@ -108,9 +108,9 @@ public function isAuthenticated() /** * {@inheritdoc} */ - public function setAuthenticated($authenticated) + public function setAuthenticated(bool $authenticated) { - $this->authenticated = (bool) $authenticated; + $this->authenticated = $authenticated; } /** @@ -187,11 +187,9 @@ public function setAttributes(array $attributes) /** * Returns true if the attribute exists. * - * @param string $name The attribute name - * * @return bool true if the attribute exists, false otherwise */ - public function hasAttribute($name) + public function hasAttribute(string $name) { return \array_key_exists($name, $this->attributes); } @@ -199,13 +197,11 @@ public function hasAttribute($name) /** * Returns an attribute value. * - * @param string $name The attribute name - * * @return mixed The attribute value * * @throws \InvalidArgumentException When attribute doesn't exist for this token */ - public function getAttribute($name) + public function getAttribute(string $name) { if (!\array_key_exists($name, $this->attributes)) { throw new \InvalidArgumentException(sprintf('This token has no "%s" attribute.', $name)); @@ -217,10 +213,9 @@ public function getAttribute($name) /** * Sets an attribute. * - * @param string $name The attribute name - * @param mixed $value The attribute value + * @param mixed $value The attribute value */ - public function setAttribute($name, $value) + public function setAttribute(string $name, $value) { $this->attributes[$name] = $value; } diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php index 766201ecf14e0..3695cae7c06bb 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php @@ -52,7 +52,7 @@ public function __construct(UserInterface $user, string $providerKey, string $se /** * {@inheritdoc} */ - public function setAuthenticated($authenticated) + public function setAuthenticated(bool $authenticated) { if ($authenticated) { throw new \LogicException('You cannot set this token to authenticated after creation.'); diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php b/src/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php index bb94de31329c9..0c4f50fd2e201 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php @@ -80,10 +80,8 @@ public function isAuthenticated(); /** * Sets the authenticated flag. - * - * @param bool $isAuthenticated The authenticated flag */ - public function setAuthenticated($isAuthenticated); + public function setAuthenticated(bool $isAuthenticated); /** * Removes sensitive information from the token. @@ -107,30 +105,25 @@ public function setAttributes(array $attributes); /** * Returns true if the attribute exists. * - * @param string $name The attribute name - * * @return bool true if the attribute exists, false otherwise */ - public function hasAttribute($name); + public function hasAttribute(string $name); /** * Returns an attribute value. * - * @param string $name The attribute name - * * @return mixed The attribute value * * @throws \InvalidArgumentException When attribute doesn't exist for this token */ - public function getAttribute($name); + public function getAttribute(string $name); /** * Sets an attribute. * - * @param string $name The attribute name - * @param mixed $value The attribute value + * @param mixed $value The attribute value */ - public function setAttribute($name, $value); + public function setAttribute(string $name, $value); /** * Returns all the necessary state of the object for serialization purposes. diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php index 4c4773578373e..ca4cc047029e2 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php @@ -47,7 +47,7 @@ public function __construct($user, $credentials, string $providerKey, array $rol /** * {@inheritdoc} */ - public function setAuthenticated($isAuthenticated) + public function setAuthenticated(bool $isAuthenticated) { if ($isAuthenticated) { throw new \LogicException('Cannot set this token to trusted after instantiation.'); diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php b/src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php index 0641486b7a13b..915cf3282bc84 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php @@ -54,7 +54,7 @@ public function vote(TokenInterface $token, $subject, array $attributes) * * @return bool True if the attribute and subject are supported, false otherwise */ - abstract protected function supports($attribute, $subject); + abstract protected function supports(string $attribute, $subject); /** * Perform a single access check operation on a given attribute, subject and token. @@ -66,5 +66,5 @@ abstract protected function supports($attribute, $subject); * * @return bool */ - abstract protected function voteOnAttribute($attribute, $subject, TokenInterface $token); + abstract protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php index bb8df147c1414..ae0ebace7f678 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php @@ -159,7 +159,7 @@ public function isAuthenticated() { } - public function setAuthenticated($isAuthenticated) + public function setAuthenticated(bool $isAuthenticated) { } @@ -175,15 +175,15 @@ public function setAttributes(array $attributes) { } - public function hasAttribute($name) + public function hasAttribute(string $name) { } - public function getAttribute($name) + public function getAttribute(string $name) { } - public function setAttribute($name, $value) + public function setAttribute(string $name, $value) { } } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php index 53ff170554222..eb26edd06132a 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php @@ -83,7 +83,7 @@ public function testRetrieveUserReturnsUserFromTokenOnReauthentication() $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); $reflection = new \ReflectionMethod($provider, 'retrieveUser'); $reflection->setAccessible(true); - $result = $reflection->invoke($provider, null, $token); + $result = $reflection->invoke($provider, 'someUser', $token); $this->assertSame($user, $result); } diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php index 50dc84e435a90..5989c00d72feb 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/VoterTest.php @@ -59,12 +59,12 @@ public function testVote(array $attributes, $expectedVote, $object, $message) class VoterTest_Voter extends Voter { - protected function voteOnAttribute($attribute, $object, TokenInterface $token) + protected function voteOnAttribute(string $attribute, $object, TokenInterface $token) { return 'EDIT' === $attribute; } - protected function supports($attribute, $object) + protected function supports(string $attribute, $object) { return $object instanceof \stdClass && \in_array($attribute, ['EDIT', 'CREATE']); } diff --git a/src/Symfony/Component/Security/Guard/Token/PreAuthenticationGuardToken.php b/src/Symfony/Component/Security/Guard/Token/PreAuthenticationGuardToken.php index 49e08882b8c6c..451d96c6eeb2d 100644 --- a/src/Symfony/Component/Security/Guard/Token/PreAuthenticationGuardToken.php +++ b/src/Symfony/Component/Security/Guard/Token/PreAuthenticationGuardToken.php @@ -58,7 +58,7 @@ public function getCredentials() return $this->credentials; } - public function setAuthenticated($authenticated) + public function setAuthenticated(bool $authenticated) { throw new \LogicException('The PreAuthenticationGuardToken is *never* authenticated.'); } diff --git a/src/Symfony/Component/Security/Guard/composer.json b/src/Symfony/Component/Security/Guard/composer.json index 3c0c7ba41a7cb..b36db0dbd32a1 100644 --- a/src/Symfony/Component/Security/Guard/composer.json +++ b/src/Symfony/Component/Security/Guard/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": "^7.2.9", - "symfony/security-core": "^4.4|^5.0", + "symfony/security-core": "^5.0", "symfony/security-http": "^4.4|^5.0" }, "require-dev": {