Skip to content

Commit

Permalink
ci: Resolve linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims committed Dec 19, 2023
1 parent ee9946d commit d0147e4
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 35 deletions.
31 changes: 14 additions & 17 deletions src/Auth0Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@
use Auth0\Symfony\Controllers\AuthenticationController;
use Auth0\Symfony\Security\{Authenticator, Authorizer, UserProvider};
use Auth0\Symfony\Stores\SessionStore;
use LogicException;
use OpenSSLAsymmetricKey;
use Psr\Cache\CacheItemPoolInterface;
use Psr\EventDispatcher\ListenerProviderInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\{RequestFactoryInterface, ResponseFactoryInterface, StreamFactoryInterface};
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
use Symfony\Component\DependencyInjection\{ContainerBuilder, Reference};
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\{ContainerBuilder, Reference};
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;

final class Auth0Bundle extends AbstractBundle implements BundleInterface
Expand All @@ -31,45 +29,44 @@ public function configure(DefinitionConfigurator $definition): void
}

/**
* @param array<mixed> $config The configuration array.
* @param array<mixed> $config The configuration array.
* @param ContainerConfigurator $container The container configurator.
* @param ContainerBuilder $builder The container builder.
* @param ContainerBuilder $builder The container builder.
*/
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
{
$sdkConfig = $config['sdk'] ?? [];

/**
* @var array{strategy: string, domain: ?string, custom_domain: ?string, client_id: ?string, redirect_uri: ?string, client_secret: ?string, audiences: null|array<string>, organizations: array<string>|null, use_pkce: bool, scopes: array<string>|null, response_mode: string, response_type: string, token_algorithm: ?string, token_jwks_uri: ?string, token_max_age: ?int, token_leeway: ?int, token_cache: ?CacheItemPoolInterface, token_cache_ttl: int, http_client: null|string|ClientInterface, http_max_retries: int, http_request_factory: null|string|RequestFactoryInterface, http_response_factory: null|string|ResponseFactoryInterface, http_stream_factory: null|string|StreamFactoryInterface, http_telemetry: bool, session_storage: ?StoreInterface, session_storage_prefix: ?string, cookie_secret: ?string, cookie_domain: ?string, cookie_expires: int, cookie_path: string, cookie_secure: bool, cookie_same_site: ?string, persist_user: bool, persist_id_token: bool, persist_access_token: bool, persist_refresh_token: bool, transient_storage: ?StoreInterface, transient_storage_prefix: ?string, query_user_info: bool, management_token: ?string, management_token_cache: ?CacheItemPoolInterface, event_listener_provider: null|string|ListenerProviderInterface, client_assertion_signing_key: null|OpenSSLAsymmetricKey|string, client_assertion_signing_algorithm: string, pushed_authorization_request: bool, backchannel_logout_cache: ?CacheItemPoolInterface, backchannel_logout_expires: int} $sdkConfig
* @var array{strategy: string, domain: ?string, custom_domain: ?string, client_id: ?string, redirect_uri: ?string, client_secret: ?string, audiences: null|array<string>, organizations: null|array<string>, use_pkce: bool, scopes: null|array<string>, response_mode: string, response_type: string, token_algorithm: ?string, token_jwks_uri: ?string, token_max_age: ?int, token_leeway: ?int, token_cache: ?CacheItemPoolInterface, token_cache_ttl: int, http_client: null|ClientInterface|string, http_max_retries: int, http_request_factory: null|RequestFactoryInterface|string, http_response_factory: null|ResponseFactoryInterface|string, http_stream_factory: null|StreamFactoryInterface|string, http_telemetry: bool, session_storage: ?StoreInterface, session_storage_prefix: ?string, cookie_secret: ?string, cookie_domain: ?string, cookie_expires: int, cookie_path: string, cookie_secure: bool, cookie_same_site: ?string, persist_user: bool, persist_id_token: bool, persist_access_token: bool, persist_refresh_token: bool, transient_storage: ?StoreInterface, transient_storage_prefix: ?string, query_user_info: bool, management_token: ?string, management_token_cache: ?CacheItemPoolInterface, event_listener_provider: null|ListenerProviderInterface|string, client_assertion_signing_key: null|OpenSSLAsymmetricKey|string, client_assertion_signing_algorithm: string, pushed_authorization_request: bool, backchannel_logout_cache: ?CacheItemPoolInterface, backchannel_logout_expires: int} $sdkConfig
*/

$tokenCache = $sdkConfig['token_cache'] ?? 'cache.app';

if (! $tokenCache instanceOf CacheItemPoolInterface) {
if (! $tokenCache instanceof CacheItemPoolInterface) {
$tokenCache = new Reference($tokenCache);
}

$managementTokenCache = $sdkConfig['management_token_cache'] ?? 'cache.app';

if (! $managementTokenCache instanceOf CacheItemPoolInterface) {
if (! $managementTokenCache instanceof CacheItemPoolInterface) {
$managementTokenCache = new Reference($managementTokenCache);
}

$backchannelLogoutCache = $sdkConfig['backchannel_logout_cache'] ?? 'cache.app';

if (! $backchannelLogoutCache instanceOf CacheItemPoolInterface) {
if (! $backchannelLogoutCache instanceof CacheItemPoolInterface) {
$backchannelLogoutCache = new Reference($backchannelLogoutCache);
}

$transientStorage = $sdkConfig['transient_storage'] ?? 'auth0.store_transient';

if (! $transientStorage instanceOf StoreInterface) {
if (! $transientStorage instanceof StoreInterface) {
$transientStorage = new Reference($transientStorage);
}

$sessionStorage = $sdkConfig['session_storage'] ?? 'auth0.store_session';

if (! $sessionStorage instanceOf StoreInterface) {
if (! $sessionStorage instanceof StoreInterface) {
$sessionStorage = new Reference($sessionStorage);
}

Expand All @@ -78,31 +75,31 @@ public function loadExtension(array $config, ContainerConfigurator $container, C

$eventListenerProvider = $sdkConfig['event_listener_provider'] ?? null;

if (! $eventListenerProvider instanceOf ListenerProviderInterface && $eventListenerProvider !== '' && $eventListenerProvider !== null) {
if (! $eventListenerProvider instanceof ListenerProviderInterface && '' !== $eventListenerProvider && null !== $eventListenerProvider) {
$eventListenerProvider = new Reference($eventListenerProvider);
}

$httpClient = $sdkConfig['http_client'] ?? null;

if (! $httpClient instanceOf ClientInterface && $httpClient !== '' && $httpClient !== null) {
if (! $httpClient instanceof ClientInterface && '' !== $httpClient && null !== $httpClient) {
$httpClient = new Reference($httpClient);
}

$httpRequestFactory = $sdkConfig['http_request_factory'] ?? null;

if (! $httpRequestFactory instanceOf RequestFactoryInterface && $httpRequestFactory !== '' && $httpRequestFactory !== null) {
if (! $httpRequestFactory instanceof RequestFactoryInterface && '' !== $httpRequestFactory && null !== $httpRequestFactory) {
$httpRequestFactory = new Reference($httpRequestFactory);
}

$httpResponseFactory = $sdkConfig['http_response_factory'] ?? null;

if (! $httpResponseFactory instanceOf ResponseFactoryInterface && $httpResponseFactory !== '' && $httpResponseFactory !== null) {
if (! $httpResponseFactory instanceof ResponseFactoryInterface && '' !== $httpResponseFactory && null !== $httpResponseFactory) {
$httpResponseFactory = new Reference($httpResponseFactory);
}

$httpStreamFactory = $sdkConfig['http_stream_factory'] ?? null;

if (! $httpStreamFactory instanceOf StreamFactoryInterface && $httpStreamFactory !== '' && $httpStreamFactory !== null) {
if (! $httpStreamFactory instanceof StreamFactoryInterface && '' !== $httpStreamFactory && null !== $httpStreamFactory) {
$httpStreamFactory = new Reference($httpStreamFactory);
}

Expand Down
11 changes: 6 additions & 5 deletions src/Controllers/AuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
use Auth0\SDK\Auth0;
use Auth0\Symfony\Contracts\Controllers\AuthenticationControllerInterface;
use Auth0\Symfony\Security\Authenticator;
use Psr\Cache\InvalidArgumentException;
use LogicException;
use Psr\Container\ContainerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Exception\{BadRequestException, ConflictingHeadersException, SuspiciousOperationException};
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
use Symfony\Component\Routing\RouterInterface;
use Throwable;

use function is_array;
use function is_string;

final class AuthenticationController extends AbstractController implements AuthenticationControllerInterface
{
public function __construct(
Expand All @@ -29,6 +28,8 @@ public function __construct(

/**
* @psalm-suppress InternalMethod
*
* @param Request $request
*/
public function callback(Request $request): Response
{
Expand Down
2 changes: 2 additions & 0 deletions src/Controllers/BackchannelLogoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public function __construct(

/**
* @psalm-suppress InternalMethod
*
* @param Request $request
*/
public function handle(Request $request): Response
{
Expand Down
9 changes: 6 additions & 3 deletions src/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Symfony\Component\Security\Core\User\UserInterface as SymfonyUserInterface;

use function array_key_exists;
use function is_array;
use function is_bool;
use function is_int;
use function is_string;

class User implements SymfonyUserInterface, UserInterface
Expand Down Expand Up @@ -37,7 +40,7 @@ public function eraseCredentials(): void

/**
* @param string $name
* @param mixed $default
* @param mixed $default
*
* @return mixed
*/
Expand Down Expand Up @@ -163,7 +166,7 @@ public function getLastLoginAt(): ?DateTimeInterface

public function getLastPasswordResetAt(): ?DateTimeInterface
{
$lastPasswordResetAt =$this->data['last_password_reset'];
$lastPasswordResetAt = $this->data['last_password_reset'];

if (! is_string($lastPasswordResetAt)) {
return null;
Expand Down Expand Up @@ -305,7 +308,7 @@ public function getUserIdentifier(): string

/**
* @param string $name
* @param mixed $default
* @param mixed $default
*
* @return mixed
*/
Expand Down
8 changes: 5 additions & 3 deletions src/Security/Authenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
use Symfony\Component\Security\Http\Authenticator\Passport\{Passport, SelfValidatingPassport};
use Throwable;

use function is_array;
use function is_string;

final class Authenticator extends AbstractAuthenticator implements AuthenticatorInterface
{
/**
* @param array<mixed> $configuration
* @param Service $service
* @param array<mixed> $configuration
* @param Service $service
* @param RouterInterface $router
* @param LoggerInterface $logger
* @return void
*/
public function __construct(
public array $configuration,
Expand Down
12 changes: 8 additions & 4 deletions src/Security/Authorizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\{Passport, SelfValidatingPassport};

use function is_string;

final class Authorizer extends AbstractAuthenticator implements AuthorizerInterface
{
/**
* @param array<mixed> $configuration
* @param Service $service
* @param array<mixed> $configuration
* @param Service $service
* @param LoggerInterface $logger
*
* @return void
*/
public function __construct(
private array $configuration,
Expand All @@ -32,6 +32,8 @@ public function __construct(

/**
* @psalm-suppress InternalMethod
*
* @param Request $request
*/
public function authenticate(Request $request): Passport
{
Expand Down Expand Up @@ -100,6 +102,8 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,

/**
* @psalm-suppress InternalMethod
*
* @param Request $request
*/
public function supports(Request $request): ?bool
{
Expand Down
4 changes: 3 additions & 1 deletion src/Security/UserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\{UserInterface as SymfonyUserInterface, UserProviderInterface as SymfonyUserProviderInterface};

use function is_array;

/**
* @template-implements SymfonyUserProviderInterface<SymfonyUserInterface>
*/
Expand Down Expand Up @@ -59,7 +61,7 @@ public function refreshUser(SymfonyUserInterface $user): SymfonyUserInterface
}

/**
* @param UserInterface|string $class
* @param string|UserInterface $class
*/
public function supportsClass($class): bool
{
Expand Down
8 changes: 6 additions & 2 deletions src/Stores/SessionStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
use Symfony\Component\HttpFoundation\{Request, RequestStack};
use Throwable;

use function gettype;
use function is_array;
use function is_string;

final class SessionStore implements StoreInterface
{
/**
* @param string $namespace
* @param RequestStack $requestStack
* @param string $namespace
* @param RequestStack $requestStack
* @param LoggerInterface $logger
*
* @psalm-suppress DocblockTypeContradiction
Expand Down

0 comments on commit d0147e4

Please sign in to comment.