Repository: symfony/symfony
File: src/Symfony/Component/Security/Core/User/ChainUserProvider.php (PHP)

Code before:
    public function getProviders(): array
    {
        if ($this->providers instanceof \Traversable) {
            return iterator_to_array($this->providers);
        }

        return $this->providers;
    }

    /**
     * @internal for compatibility with Symfony 5.4
     */
    public function loadUserByUsername(string $username): UserInterface
    {
        return $this->loadUserByIdentifier($username);
    }

    /**
     * @param array $attributes
     */
    public function loadUserByIdentifier(string $identifier/* , array $attributes = [] */): UserInterface
    {
        $attributes = \func_num_args() > 1 ? func_get_arg(1) : [];
        foreach ($this->providers as $provider) {
            try {
                if ($provider instanceof AttributesBasedUserProviderInterface) {
                    return $provider->loadUserByIdentifier($identifier, $attributes);
                }

                return $provider->loadUserByIdentifier($identifier);
            } catch (UserNotFoundException) {
                // try next one
            }
        }

        $ex = new UserNotFoundException(\sprintf('There is no user with identifier "%s".', $identifier));
        $ex->setUserIdentifier($identifier);
        throw $ex;
    }

    public function refreshUser(UserInterface $user): UserInterface
    {
        $supportedUserFound = false;

        foreach ($this->providers as $provider) {
            try {
                if (!$provider->supportsClass(get_debug_type($user))) {
                    continue;
                }

                return $provider->refreshUser($user);

Review comment (suggestion):
or should it be `static`, since this class is not `final`

Code after:
    public function getProviders(): array
    {
        if ($this->providers instanceof \Traversable) {
            return iterator_to_array($this->providers);
        }

        return $this->providers;
    }

    /**
     * @internal for compatibility with Symfony 5.4
     */
    public function loadUserByUsername(string $username): UserInterface
    {
        return $this->loadUserByIdentifier($username);
    }

    /**
     * @param array $attributes
     */
    public function loadUserByIdentifier(string $identifier/* , array $attributes = [] */): UserInterface
    {
        $attributes = \func_num_args() > 1 ? func_get_arg(1) : [];
        foreach ($this->providers as $provider) {
            try {
                if ($provider instanceof AttributesBasedUserProviderInterface || $provider instanceof self) {
                    return $provider->loadUserByIdentifier($identifier, $attributes);
                }

                return $provider->loadUserByIdentifier($identifier);
            } catch (UserNotFoundException) {
                // try next one
            }
        }

        $ex = new UserNotFoundException(\sprintf('There is no user with identifier "%s".', $identifier));
        $ex->setUserIdentifier($identifier);
        throw $ex;
    }

    public function refreshUser(UserInterface $user): UserInterface
    {
        $supportedUserFound = false;

        foreach ($this->providers as $provider) {
            try {
                if (!$provider->supportsClass(get_debug_type($user))) {
                    continue;
                }

                return $provider->refreshUser($user);