Skip to content

[Security][SecurityBundle] Backport type fixes #43899

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
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ExpressionCacheWarmer implements CacheWarmerInterface
private $expressionLanguage;

/**
* @param iterable<int, Expression> $expressions
* @param iterable<mixed, Expression> $expressions
*/
public function __construct(iterable $expressions, ExpressionLanguage $expressionLanguage)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
class RoleHierarchy implements RoleHierarchyInterface
{
private $hierarchy;
/** @var array<string, list<string>> */
protected $map;

/**
* @param array $hierarchy An array defining the hierarchy
* @param array<string, list<string>> $hierarchy
*/
public function __construct(array $hierarchy)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ChainUserProvider implements UserProviderInterface, PasswordUpgraderInterf
private $providers;

/**
* @param iterable<int, UserProviderInterface> $providers
* @param iterable<array-key, UserProviderInterface> $providers
*/
public function __construct(iterable $providers)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
*/
class InMemoryUserProvider implements UserProviderInterface
{
/**
* @var array<string, UserInterface>
*/
private $users;

/**
* The user array is a hash where the keys are usernames and the values are
* an array of attributes: 'password', 'enabled', and 'roles'.
*
* @param array $users An array of users
* @param array<string, array{password?: string, enabled?: bool, roles?: list<string>}> $users An array of users
*/
public function __construct(array $users = [])
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AuthenticatorManager implements AuthenticatorManagerInterface, UserAuthent
private $requiredBadges;

/**
* @param AuthenticatorInterface[] $authenticators
* @param iterable<mixed, AuthenticatorInterface> $authenticators
*/
public function __construct(iterable $authenticators, TokenStorageInterface $tokenStorage, EventDispatcherInterface $eventDispatcher, string $firewallName, LoggerInterface $logger = null, bool $eraseCredentials = true, bool $hideUserNotFoundExceptions = true, array $requiredBadges = [])
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class LogoutUrlGenerator
private $router;
private $tokenStorage;
private $listeners = [];
private $currentFirewall;
/** @var string|null */
private $currentFirewallName;
/** @var string|null */
private $currentFirewallContext;

public function __construct(RequestStack $requestStack = null, UrlGeneratorInterface $router = null, TokenStorageInterface $tokenStorage = null)
{
Expand Down Expand Up @@ -74,7 +77,8 @@ public function getLogoutUrl(string $key = null)

public function setCurrentFirewall(?string $key, string $context = null)
{
$this->currentFirewall = [$key, $context];
$this->currentFirewallName = $key;
$this->currentFirewallContext = $context;
}

/**
Expand Down Expand Up @@ -130,7 +134,7 @@ private function getListener(?string $key): array
if (null !== $this->tokenStorage) {
$token = $this->tokenStorage->getToken();

// @deprecated since 5.4
// @deprecated since Symfony 5.4
if ($token instanceof AnonymousToken) {
throw new \InvalidArgumentException('Unable to generate a logout url for an anonymous token.');
}
Expand All @@ -151,14 +155,12 @@ private function getListener(?string $key): array
}

// Fetch from injected current firewall information, if possible
[$key, $context] = $this->currentFirewall;

if (isset($this->listeners[$key])) {
return $this->listeners[$key];
if (isset($this->listeners[$this->currentFirewallName])) {
return $this->listeners[$this->currentFirewallName];
}

foreach ($this->listeners as $listener) {
if (isset($listener[4]) && $context === $listener[4]) {
if (isset($listener[4]) && $this->currentFirewallContext === $listener[4]) {
return $listener;
}
}
Expand Down