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

Appearance settings

Commit b163a95

Browse filesBrowse files
committed
minor #32353 [Security] Added type-hints to user providers (derrabus)
This PR was merged into the 5.0-dev branch. Discussion ---------- [Security] Added type-hints to user providers | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32179 | License | MIT | Doc PR | N/A This PR adds type declarations to user provider classes. Commits ------- 62abb70 [Security] Added type-hints to user providers.
2 parents cc9778e + 62abb70 commit b163a95
Copy full SHA for b163a95

File tree

7 files changed

+18
-27
lines changed
Filter options

7 files changed

+18
-27
lines changed

‎src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(ManagerRegistry $registry, string $classOrAlias, str
4444
/**
4545
* {@inheritdoc}
4646
*/
47-
public function loadUserByUsername($username)
47+
public function loadUserByUsername(string $username)
4848
{
4949
$repository = $this->getRepository();
5050
if (null !== $this->property) {
@@ -102,7 +102,7 @@ public function refreshUser(UserInterface $user)
102102
/**
103103
* {@inheritdoc}
104104
*/
105-
public function supportsClass($class)
105+
public function supportsClass(string $class)
106106
{
107107
return $class === $this->getClass() || is_subclass_of($class, $this->getClass());
108108
}

‎src/Symfony/Bridge/Doctrine/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/composer.json
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"symfony/property-access": "^4.4|^5.0",
3434
"symfony/property-info": "^4.4|^5.0",
3535
"symfony/proxy-manager-bridge": "^4.4|^5.0",
36-
"symfony/security-core": "^4.4|^5.0",
36+
"symfony/security-core": "^5.0",
3737
"symfony/expression-language": "^4.4|^5.0",
3838
"symfony/validator": "^4.4|^5.0",
3939
"symfony/translation": "^4.4|^5.0",
@@ -49,7 +49,8 @@
4949
"phpunit/phpunit": "<5.4.3",
5050
"symfony/dependency-injection": "<4.4",
5151
"symfony/form": "<4.4",
52-
"symfony/messenger": "<4.4"
52+
"symfony/messenger": "<4.4",
53+
"symfony/security-core": "<5"
5354
},
5455
"suggest": {
5556
"symfony/form": "",

‎src/Symfony/Component/Security/Core/User/ChainUserProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/User/ChainUserProvider.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getProviders()
4949
/**
5050
* {@inheritdoc}
5151
*/
52-
public function loadUserByUsername($username)
52+
public function loadUserByUsername(string $username)
5353
{
5454
foreach ($this->providers as $provider) {
5555
try {
@@ -94,7 +94,7 @@ public function refreshUser(UserInterface $user)
9494
/**
9595
* {@inheritdoc}
9696
*/
97-
public function supportsClass($class)
97+
public function supportsClass(string $class)
9898
{
9999
foreach ($this->providers as $provider) {
100100
if ($provider->supportsClass($class)) {

‎src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function createUser(UserInterface $user)
6161
/**
6262
* {@inheritdoc}
6363
*/
64-
public function loadUserByUsername($username)
64+
public function loadUserByUsername(string $username)
6565
{
6666
$user = $this->getUser($username);
6767

@@ -85,7 +85,7 @@ public function refreshUser(UserInterface $user)
8585
/**
8686
* {@inheritdoc}
8787
*/
88-
public function supportsClass($class)
88+
public function supportsClass(string $class)
8989
{
9090
return 'Symfony\Component\Security\Core\User\User' === $class;
9191
}
@@ -99,7 +99,7 @@ public function supportsClass($class)
9999
*
100100
* @throws UsernameNotFoundException if user whose given username does not exist
101101
*/
102-
private function getUser($username)
102+
private function getUser(string $username)
103103
{
104104
if (!isset($this->users[strtolower($username)])) {
105105
$ex = new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));

‎src/Symfony/Component/Security/Core/User/LdapUserProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/User/LdapUserProvider.php
+4-10Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(LdapInterface $ldap, string $baseDn, string $searchD
6060
/**
6161
* {@inheritdoc}
6262
*/
63-
public function loadUserByUsername($username)
63+
public function loadUserByUsername(string $username)
6464
{
6565
try {
6666
$this->ldap->bind($this->searchDn, $this->searchPassword);
@@ -109,20 +109,17 @@ public function refreshUser(UserInterface $user)
109109
/**
110110
* {@inheritdoc}
111111
*/
112-
public function supportsClass($class)
112+
public function supportsClass(string $class)
113113
{
114114
return 'Symfony\Component\Security\Core\User\User' === $class;
115115
}
116116

117117
/**
118118
* Loads a user from an LDAP entry.
119119
*
120-
* @param string $username
121-
* @param Entry $entry
122-
*
123120
* @return User
124121
*/
125-
protected function loadUser($username, Entry $entry)
122+
protected function loadUser(string $username, Entry $entry)
126123
{
127124
$password = null;
128125
$extraFields = [];
@@ -140,11 +137,8 @@ protected function loadUser($username, Entry $entry)
140137

141138
/**
142139
* Fetches a required unique attribute value from an LDAP entry.
143-
*
144-
* @param Entry|null $entry
145-
* @param string $attribute
146140
*/
147-
private function getAttributeValue(Entry $entry, $attribute)
141+
private function getAttributeValue(Entry $entry, string $attribute)
148142
{
149143
if (!$entry->hasAttribute($attribute)) {
150144
throw new InvalidArgumentException(sprintf('Missing attribute "%s" for user "%s".', $attribute, $entry->getDn()));

‎src/Symfony/Component/Security/Core/User/MissingUserProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/User/MissingUserProvider.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(string $firewall)
3232
/**
3333
* {@inheritdoc}
3434
*/
35-
public function loadUserByUsername($username)
35+
public function loadUserByUsername(string $username)
3636
{
3737
throw new \BadMethodCallException();
3838
}
@@ -48,7 +48,7 @@ public function refreshUser(UserInterface $user)
4848
/**
4949
* {@inheritdoc}
5050
*/
51-
public function supportsClass($class)
51+
public function supportsClass(string $class)
5252
{
5353
throw new \BadMethodCallException();
5454
}

‎src/Symfony/Component/Security/Core/User/UserProviderInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/User/UserProviderInterface.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ interface UserProviderInterface
3939
* This method must throw UsernameNotFoundException if the user is not
4040
* found.
4141
*
42-
* @param string $username The username
43-
*
4442
* @return UserInterface
4543
*
4644
* @throws UsernameNotFoundException if the user is not found
4745
*/
48-
public function loadUserByUsername($username);
46+
public function loadUserByUsername(string $username);
4947

5048
/**
5149
* Refreshes the user.
@@ -65,9 +63,7 @@ public function refreshUser(UserInterface $user);
6563
/**
6664
* Whether this provider supports the given user class.
6765
*
68-
* @param string $class
69-
*
7066
* @return bool
7167
*/
72-
public function supportsClass($class);
68+
public function supportsClass(string $class);
7369
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.