Code improvements (#1649)
* use global namespace for faster lookups * phpstan level 5
This commit is contained in:
@@ -54,7 +54,7 @@ final class DoctrineUserProvider implements UserProviderInterface
|
||||
public function refreshUser(SecurityUserInterface $user)
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
throw new UnsupportedUserException(sprintf('Expected an instance of %s, but got "%s".', User::class, get_class($user)));
|
||||
throw new UnsupportedUserException(sprintf('Expected an instance of %s, but got "%s".', User::class, \get_class($user)));
|
||||
}
|
||||
|
||||
/** @var User|null $reloadedUser */
|
||||
|
||||
@@ -39,18 +39,18 @@ final class RolePermissionManager
|
||||
$isAllowed = $item['allowed'];
|
||||
|
||||
// see permissions.html.twig for this special case
|
||||
if ($role === User::ROLE_SUPER_ADMIN && in_array($perm, ['role_permissions', 'view_user'])) {
|
||||
if ($role === User::ROLE_SUPER_ADMIN && \in_array($perm, ['role_permissions', 'view_user'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$isAllowed) {
|
||||
if (array_key_exists($role, $this->permissions)) {
|
||||
if (\array_key_exists($role, $this->permissions)) {
|
||||
if (($key = array_search($perm, $this->permissions[$role])) !== false) {
|
||||
unset($this->permissions[$role][$key]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!array_key_exists($role, $this->permissions)) {
|
||||
if (!\array_key_exists($role, $this->permissions)) {
|
||||
$this->permissions[$role] = [];
|
||||
}
|
||||
$this->permissions[$role][] = $perm;
|
||||
@@ -66,7 +66,7 @@ final class RolePermissionManager
|
||||
*/
|
||||
public function isRegisteredPermission(string $permission): bool
|
||||
{
|
||||
return in_array($permission, $this->knownPermissions);
|
||||
return \in_array($permission, $this->knownPermissions);
|
||||
}
|
||||
|
||||
public function hasPermission(string $role, string $permission): bool
|
||||
@@ -77,7 +77,7 @@ final class RolePermissionManager
|
||||
return false;
|
||||
}
|
||||
|
||||
return in_array($permission, $this->permissions[$role]);
|
||||
return \in_array($permission, $this->permissions[$role]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,7 @@ final class RoleService
|
||||
$roles = [];
|
||||
foreach ($this->roles as $key => $value) {
|
||||
$roles[] = $key;
|
||||
if (is_array($value)) {
|
||||
if (\is_array($value)) {
|
||||
foreach ($value as $name) {
|
||||
$roles[] = $name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user