From aff1df32f205010b604735e0daacfe5f3c2a72af Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 1 Aug 2019 19:49:54 +0200 Subject: [PATCH] Updated to coding-standard library v1.2.2 --- CHANGELOG.md | 4 ++-- composer.json | 2 +- .../Exception/GeolocationDbUpdateFailedException.php | 4 ++-- module/CLI/src/Factory/ApplicationFactory.php | 2 +- .../Command/ShortUrl/DeleteShortUrlCommandTest.php | 4 ++-- module/Common/functions/functions.php | 4 ++-- module/Common/src/Exception/WrongIpException.php | 2 +- module/Common/src/Factory/CacheFactory.php | 2 +- .../src/Factory/DottedAccessConfigAbstractFactory.php | 2 +- .../EmptyResponseImplicitOptionsMiddlewareFactory.php | 2 +- module/Common/src/Factory/EntityManagerFactory.php | 2 +- module/Common/src/Factory/LoggerFactory.php | 2 +- module/Common/src/Factory/TranslatorFactory.php | 2 +- module/Common/src/Image/ImageBuilderFactory.php | 2 +- module/Common/src/Image/ImageFactory.php | 2 +- module/Common/src/IpGeolocation/GeoLite2/DbUpdater.php | 4 ++-- .../src/IpGeolocation/GeoLite2/DbUpdaterInterface.php | 2 +- .../Logger/Processor/ExceptionWithNewLineProcessor.php | 4 ++-- .../src/Middleware/IpAddressMiddlewareFactory.php | 2 +- .../src/Repository/PaginableRepositoryInterface.php | 8 ++++---- .../Processor/ExceptionWithNewLineProcessorTest.php | 4 ++-- module/Common/test/Util/TestUtils.php | 2 +- .../Shlinkio.Shlink.Core.Entity.ShortUrl.php | 1 - .../Shlinkio.Shlink.Core.Entity.Tag.php | 1 - .../Shlinkio.Shlink.Core.Entity.Visit.php | 1 - .../Shlinkio.Shlink.Core.Entity.VisitLocation.php | 1 - module/Core/src/Action/AbstractTrackingAction.php | 2 +- module/Core/src/Action/PreviewAction.php | 2 +- module/Core/src/Action/QrCodeAction.php | 2 +- module/Core/src/Action/RedirectAction.php | 2 +- module/Core/src/Entity/ShortUrl.php | 2 +- module/Core/src/Exception/DeleteShortUrlException.php | 2 +- module/Core/src/Exception/InvalidUrlException.php | 2 +- module/Core/src/Exception/ValidationException.php | 10 +++++----- module/Core/src/Repository/ShortUrlRepository.php | 8 ++++---- module/Core/src/Service/ShortUrlService.php | 2 +- module/Core/src/Service/ShortUrlServiceInterface.php | 2 +- module/Core/test/Action/PreviewActionTest.php | 4 ++-- .../EventDispatcher/src/Async/TaskRunnerDelegator.php | 2 +- module/EventDispatcher/src/Async/TaskRunnerFactory.php | 2 +- .../src/Listener/ListenerProviderFactory.php | 2 +- .../Shlinkio.Shlink.Rest.Entity.ApiKey.php | 1 - module/Rest/src/Action/AbstractRestAction.php | 2 +- module/Rest/src/Action/AuthenticateAction.php | 2 +- module/Rest/src/Action/HealthAction.php | 2 +- .../Action/ShortUrl/AbstractCreateShortUrlAction.php | 2 +- .../Rest/src/Action/ShortUrl/DeleteShortUrlAction.php | 2 +- module/Rest/src/Action/ShortUrl/EditShortUrlAction.php | 2 +- .../src/Action/ShortUrl/EditShortUrlTagsAction.php | 2 +- .../Rest/src/Action/ShortUrl/ListShortUrlsAction.php | 2 +- .../Rest/src/Action/ShortUrl/ResolveShortUrlAction.php | 2 +- .../Action/ShortUrl/SingleStepCreateShortUrlAction.php | 2 +- module/Rest/src/Action/Tag/CreateTagsAction.php | 2 +- module/Rest/src/Action/Tag/DeleteTagsAction.php | 2 +- module/Rest/src/Action/Tag/ListTagsAction.php | 2 +- module/Rest/src/Action/Tag/UpdateTagAction.php | 2 +- module/Rest/src/Action/Visit/GetVisitsAction.php | 2 +- .../AuthenticationPluginManagerFactory.php | 2 +- module/Rest/src/Authentication/JWTServiceInterface.php | 4 ++-- .../Plugin/AuthorizationHeaderPlugin.php | 2 +- .../src/Exception/VerifyAuthenticationException.php | 4 ++-- .../Rest/src/Middleware/AuthenticationMiddleware.php | 2 +- module/Rest/test-api/Fixtures/ApiKeyFixture.php | 2 +- 63 files changed, 78 insertions(+), 83 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f7cd6f5..c2853c00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this #### Changed -* *Nothing* +* [#430](https://github.com/shlinkio/shlink/issues/430) Updated to [shlinkio/php-coding-standard](https://github.com/shlinkio/php-coding-standard) 1.2.2 ### Deprecated @@ -56,7 +56,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this #### Fixed * [#416](https://github.com/shlinkio/shlink/issues/416) Fixed error thrown when trying to locate visits after the GeoLite2 DB is downloaded for the first time. -* [#424](https://github.com/shlinkio/shlink/issues/424) Update wkhtmltoimage to version 0.12.5 +* [#424](https://github.com/shlinkio/shlink/issues/424) Updated wkhtmltoimage to version 0.12.5 * [#427](https://github.com/shlinkio/shlink/issues/427) Fixed shlink being unusable after a database error on swoole contexts. diff --git a/composer.json b/composer.json index 90f35945..0d9d5c76 100644 --- a/composer.json +++ b/composer.json @@ -61,7 +61,7 @@ "phpunit/phpcov": "^6.0", "phpunit/phpunit": "^8.0", "roave/security-advisories": "dev-master", - "shlinkio/php-coding-standard": "~1.1.0", + "shlinkio/php-coding-standard": "~1.2.2", "symfony/dotenv": "^4.2", "symfony/var-dumper": "^4.2", "zendframework/zend-component-installer": "^2.1", diff --git a/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php b/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php index bbf1644e..777d7e1a 100644 --- a/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php +++ b/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php @@ -11,13 +11,13 @@ class GeolocationDbUpdateFailedException extends RuntimeException implements Exc /** @var bool */ private $olderDbExists; - public function __construct(bool $olderDbExists, string $message = '', int $code = 0, Throwable $previous = null) + public function __construct(bool $olderDbExists, string $message = '', int $code = 0, ?Throwable $previous = null) { $this->olderDbExists = $olderDbExists; parent::__construct($message, $code, $previous); } - public static function create(bool $olderDbExists, Throwable $prev = null): self + public static function create(bool $olderDbExists, ?Throwable $prev = null): self { return new self( $olderDbExists, diff --git a/module/CLI/src/Factory/ApplicationFactory.php b/module/CLI/src/Factory/ApplicationFactory.php index 4bc867c3..7acfc815 100644 --- a/module/CLI/src/Factory/ApplicationFactory.php +++ b/module/CLI/src/Factory/ApplicationFactory.php @@ -29,7 +29,7 @@ class ApplicationFactory implements FactoryInterface * @throws ServiceNotCreatedException if an exception is raised when creating a service. * @throws ContainerException if any other error occurs */ - public function __invoke(ContainerInterface $container, $requestedName, array $options = null): CliApp + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): CliApp { $config = $container->get('config')['cli']; $appOptions = $container->get(AppOptions::class); diff --git a/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php b/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php index 8414ab6e..28de423f 100644 --- a/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php +++ b/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php @@ -12,11 +12,11 @@ use Shlinkio\Shlink\Core\Service\ShortUrl\DeleteShortUrlServiceInterface; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; -use const PHP_EOL; - use function array_pop; use function sprintf; +use const PHP_EOL; + class DeleteShortUrlCommandTest extends TestCase { /** @var CommandTester */ diff --git a/module/Common/functions/functions.php b/module/Common/functions/functions.php index 485df607..e07603ce 100644 --- a/module/Common/functions/functions.php +++ b/module/Common/functions/functions.php @@ -3,8 +3,6 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Common; -use const JSON_ERROR_NONE; - use function getenv; use function json_decode as spl_json_decode; use function json_last_error; @@ -13,6 +11,8 @@ use function sprintf; use function strtolower; use function trim; +use const JSON_ERROR_NONE; + /** * Gets the value of an environment variable. Supports boolean, empty and null. * This is basically Laravel's env helper diff --git a/module/Common/src/Exception/WrongIpException.php b/module/Common/src/Exception/WrongIpException.php index fb6589e7..8b536b3d 100644 --- a/module/Common/src/Exception/WrongIpException.php +++ b/module/Common/src/Exception/WrongIpException.php @@ -9,7 +9,7 @@ use function sprintf; class WrongIpException extends RuntimeException { - public static function fromIpAddress($ipAddress, Throwable $prev = null): self + public static function fromIpAddress($ipAddress, ?Throwable $prev = null): self { return new self(sprintf('Provided IP "%s" is invalid', $ipAddress), 0, $prev); } diff --git a/module/Common/src/Factory/CacheFactory.php b/module/Common/src/Factory/CacheFactory.php index 5a810c68..68628af0 100644 --- a/module/Common/src/Factory/CacheFactory.php +++ b/module/Common/src/Factory/CacheFactory.php @@ -12,7 +12,7 @@ use function Shlinkio\Shlink\Common\env; class CacheFactory implements FactoryInterface { - public function __invoke(ContainerInterface $container, $requestedName, array $options = null): Cache\Cache + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): Cache\Cache { $appOptions = $container->get(AppOptions::class); $adapter = env('APP_ENV', 'pro') === 'pro' ? new Cache\ApcuCache() : new Cache\ArrayCache(); diff --git a/module/Common/src/Factory/DottedAccessConfigAbstractFactory.php b/module/Common/src/Factory/DottedAccessConfigAbstractFactory.php index 64f1adf9..cfe01eef 100644 --- a/module/Common/src/Factory/DottedAccessConfigAbstractFactory.php +++ b/module/Common/src/Factory/DottedAccessConfigAbstractFactory.php @@ -44,7 +44,7 @@ class DottedAccessConfigAbstractFactory implements AbstractFactoryInterface * creating a service. * @throws ContainerException if any other error occurs */ - public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) { $parts = explode('.', $requestedName); $serviceName = array_shift($parts); diff --git a/module/Common/src/Factory/EmptyResponseImplicitOptionsMiddlewareFactory.php b/module/Common/src/Factory/EmptyResponseImplicitOptionsMiddlewareFactory.php index 4371bb6b..793a2699 100644 --- a/module/Common/src/Factory/EmptyResponseImplicitOptionsMiddlewareFactory.php +++ b/module/Common/src/Factory/EmptyResponseImplicitOptionsMiddlewareFactory.php @@ -25,7 +25,7 @@ class EmptyResponseImplicitOptionsMiddlewareFactory implements FactoryInterface * creating a service. * @throws ContainerException if any other error occurs */ - public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) { return new ImplicitOptionsMiddleware(function () { return new EmptyResponse(); diff --git a/module/Common/src/Factory/EntityManagerFactory.php b/module/Common/src/Factory/EntityManagerFactory.php index 13580a44..b1de186b 100644 --- a/module/Common/src/Factory/EntityManagerFactory.php +++ b/module/Common/src/Factory/EntityManagerFactory.php @@ -25,7 +25,7 @@ class EntityManagerFactory implements FactoryInterface * @throws ORMException * @throws DBALException */ - public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) { $globalConfig = $container->get('config'); $isDevMode = isset($globalConfig['debug']) ? ((bool) $globalConfig['debug']) : false; diff --git a/module/Common/src/Factory/LoggerFactory.php b/module/Common/src/Factory/LoggerFactory.php index 89859ace..72c396e2 100644 --- a/module/Common/src/Factory/LoggerFactory.php +++ b/module/Common/src/Factory/LoggerFactory.php @@ -27,7 +27,7 @@ class LoggerFactory implements FactoryInterface * creating a service. * @throws ContainerException if any other error occurs */ - public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) { $config = $container->has('config') ? $container->get('config') : []; Cascade::fileConfig($config['logger'] ?? ['loggers' => []]); diff --git a/module/Common/src/Factory/TranslatorFactory.php b/module/Common/src/Factory/TranslatorFactory.php index 50c939cc..f9b75569 100644 --- a/module/Common/src/Factory/TranslatorFactory.php +++ b/module/Common/src/Factory/TranslatorFactory.php @@ -24,7 +24,7 @@ class TranslatorFactory implements FactoryInterface * creating a service. * @throws ContainerException if any other error occurs */ - public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) { $config = $container->get('config'); return Translator::factory($config['translator'] ?? []); diff --git a/module/Common/src/Image/ImageBuilderFactory.php b/module/Common/src/Image/ImageBuilderFactory.php index f6119011..a330666f 100644 --- a/module/Common/src/Image/ImageBuilderFactory.php +++ b/module/Common/src/Image/ImageBuilderFactory.php @@ -24,7 +24,7 @@ class ImageBuilderFactory implements FactoryInterface * creating a service. * @throws ContainerException if any other error occurs */ - public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) { return new ImageBuilder($container, ['factories' => [ Image::class => ImageFactory::class, diff --git a/module/Common/src/Image/ImageFactory.php b/module/Common/src/Image/ImageFactory.php index ed1c5d4d..1305d16d 100644 --- a/module/Common/src/Image/ImageFactory.php +++ b/module/Common/src/Image/ImageFactory.php @@ -24,7 +24,7 @@ class ImageFactory implements FactoryInterface * creating a service. * @throws ContainerException if any other error occurs */ - public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) { $config = $container->get('config')['wkhtmltopdf']; $image = new Image($config['images'] ?? null); diff --git a/module/Common/src/IpGeolocation/GeoLite2/DbUpdater.php b/module/Common/src/IpGeolocation/GeoLite2/DbUpdater.php index 4efebdbe..47794020 100644 --- a/module/Common/src/IpGeolocation/GeoLite2/DbUpdater.php +++ b/module/Common/src/IpGeolocation/GeoLite2/DbUpdater.php @@ -37,7 +37,7 @@ class DbUpdater implements DbUpdaterInterface /** * @throws RuntimeException */ - public function downloadFreshCopy(callable $handleProgress = null): void + public function downloadFreshCopy(?callable $handleProgress = null): void { $tempDir = $this->options->getTempDir(); $compressedFile = sprintf('%s/%s', $tempDir, self::DB_COMPRESSED_FILE); @@ -48,7 +48,7 @@ class DbUpdater implements DbUpdaterInterface $this->deleteTempFiles([$compressedFile, $tempFullPath]); } - private function downloadDbFile(string $dest, callable $handleProgress = null): void + private function downloadDbFile(string $dest, ?callable $handleProgress = null): void { try { $this->httpClient->request(RequestMethod::METHOD_GET, $this->options->getDownloadFrom(), [ diff --git a/module/Common/src/IpGeolocation/GeoLite2/DbUpdaterInterface.php b/module/Common/src/IpGeolocation/GeoLite2/DbUpdaterInterface.php index e5694aeb..38f8e53a 100644 --- a/module/Common/src/IpGeolocation/GeoLite2/DbUpdaterInterface.php +++ b/module/Common/src/IpGeolocation/GeoLite2/DbUpdaterInterface.php @@ -12,5 +12,5 @@ interface DbUpdaterInterface /** * @throws RuntimeException */ - public function downloadFreshCopy(callable $handleProgress = null): void; + public function downloadFreshCopy(?callable $handleProgress = null): void; } diff --git a/module/Common/src/Logger/Processor/ExceptionWithNewLineProcessor.php b/module/Common/src/Logger/Processor/ExceptionWithNewLineProcessor.php index 9085150b..91c0a657 100644 --- a/module/Common/src/Logger/Processor/ExceptionWithNewLineProcessor.php +++ b/module/Common/src/Logger/Processor/ExceptionWithNewLineProcessor.php @@ -3,11 +3,11 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Common\Logger\Processor; -use const PHP_EOL; - use function str_replace; use function strpos; +use const PHP_EOL; + final class ExceptionWithNewLineProcessor { private const EXCEPTION_PLACEHOLDER = '{e}'; diff --git a/module/Common/src/Middleware/IpAddressMiddlewareFactory.php b/module/Common/src/Middleware/IpAddressMiddlewareFactory.php index 2116d231..67063c28 100644 --- a/module/Common/src/Middleware/IpAddressMiddlewareFactory.php +++ b/module/Common/src/Middleware/IpAddressMiddlewareFactory.php @@ -21,7 +21,7 @@ class IpAddressMiddlewareFactory implements FactoryInterface * @throws ServiceNotFoundException if unable to resolve the service. * @throws ServiceNotCreatedException if an exception is raised when creating a service. */ - public function __invoke(ContainerInterface $container, $requestedName, array $options = null): IpAddress + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): IpAddress { $config = $container->get('config'); $headersToInspect = $config['ip_address_resolution']['headers_to_inspect'] ?? []; diff --git a/module/Common/src/Repository/PaginableRepositoryInterface.php b/module/Common/src/Repository/PaginableRepositoryInterface.php index 31808ee1..7de324e9 100644 --- a/module/Common/src/Repository/PaginableRepositoryInterface.php +++ b/module/Common/src/Repository/PaginableRepositoryInterface.php @@ -16,9 +16,9 @@ interface PaginableRepositoryInterface * @return array */ public function findList( - int $limit = null, - int $offset = null, - string $searchTerm = null, + ?int $limit = null, + ?int $offset = null, + ?string $searchTerm = null, array $tags = [], $orderBy = null ): array; @@ -30,5 +30,5 @@ interface PaginableRepositoryInterface * @param array $tags * @return int */ - public function countList(string $searchTerm = null, array $tags = []): int; + public function countList(?string $searchTerm = null, array $tags = []): int; } diff --git a/module/Common/test/Logger/Processor/ExceptionWithNewLineProcessorTest.php b/module/Common/test/Logger/Processor/ExceptionWithNewLineProcessorTest.php index 6fe088fb..60b30ce8 100644 --- a/module/Common/test/Logger/Processor/ExceptionWithNewLineProcessorTest.php +++ b/module/Common/test/Logger/Processor/ExceptionWithNewLineProcessorTest.php @@ -7,11 +7,11 @@ use PHPUnit\Framework\TestCase; use Shlinkio\Shlink\Common\Logger\Processor\ExceptionWithNewLineProcessor; use Shlinkio\Shlink\Common\Util\StringUtilsTrait; -use const PHP_EOL; - use function Functional\map; use function range; +use const PHP_EOL; + class ExceptionWithNewLineProcessorTest extends TestCase { use StringUtilsTrait; diff --git a/module/Common/test/Util/TestUtils.php b/module/Common/test/Util/TestUtils.php index 64ed655a..aa1e0450 100644 --- a/module/Common/test/Util/TestUtils.php +++ b/module/Common/test/Util/TestUtils.php @@ -14,7 +14,7 @@ class TestUtils { private static $prophet; - public static function createReqHandlerMock(ResponseInterface $response = null, RequestInterface $request = null) + public static function createReqHandlerMock(?ResponseInterface $response = null, ?RequestInterface $request = null) { $argument = $request ?: Argument::any(); $delegate = static::getProphet()->prophesize(RequestHandlerInterface::class); diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.ShortUrl.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.ShortUrl.php index 8012ea56..05988210 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.ShortUrl.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.ShortUrl.php @@ -5,7 +5,6 @@ namespace Shlinkio\Shlink\Core; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; -use Doctrine\ORM\Mapping\ClassMetadata; use Shlinkio\Shlink\Common\Type\ChronosDateTimeType; /** @var $metadata ClassMetadata */ diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Tag.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Tag.php index e78ead58..f1d58474 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Tag.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Tag.php @@ -5,7 +5,6 @@ namespace Shlinkio\Shlink\Core; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; -use Doctrine\ORM\Mapping\ClassMetadata; /** @var $metadata ClassMetadata */ $builder = new ClassMetadataBuilder($metadata); diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Visit.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Visit.php index bf0b921a..28f32470 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Visit.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Visit.php @@ -5,7 +5,6 @@ namespace Shlinkio\Shlink\Core; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; -use Doctrine\ORM\Mapping\ClassMetadata; use Shlinkio\Shlink\Common\Type\ChronosDateTimeType; /** @var $metadata ClassMetadata */ diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php index ced3b393..f6eff3f8 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php @@ -5,7 +5,6 @@ namespace Shlinkio\Shlink\Core; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; -use Doctrine\ORM\Mapping\ClassMetadata; /** @var $metadata ClassMetadata */ $builder = new ClassMetadataBuilder($metadata); diff --git a/module/Core/src/Action/AbstractTrackingAction.php b/module/Core/src/Action/AbstractTrackingAction.php index 796fefce..6bd3995a 100644 --- a/module/Core/src/Action/AbstractTrackingAction.php +++ b/module/Core/src/Action/AbstractTrackingAction.php @@ -33,7 +33,7 @@ abstract class AbstractTrackingAction implements MiddlewareInterface UrlShortenerInterface $urlShortener, VisitsTrackerInterface $visitTracker, AppOptions $appOptions, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { $this->urlShortener = $urlShortener; $this->visitTracker = $visitTracker; diff --git a/module/Core/src/Action/PreviewAction.php b/module/Core/src/Action/PreviewAction.php index 18423f5f..3a8b05bc 100644 --- a/module/Core/src/Action/PreviewAction.php +++ b/module/Core/src/Action/PreviewAction.php @@ -32,7 +32,7 @@ class PreviewAction implements MiddlewareInterface public function __construct( PreviewGeneratorInterface $previewGenerator, UrlShortenerInterface $urlShortener, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { $this->previewGenerator = $previewGenerator; $this->urlShortener = $urlShortener; diff --git a/module/Core/src/Action/QrCodeAction.php b/module/Core/src/Action/QrCodeAction.php index 5cfb3b9d..24a6a67f 100644 --- a/module/Core/src/Action/QrCodeAction.php +++ b/module/Core/src/Action/QrCodeAction.php @@ -36,7 +36,7 @@ class QrCodeAction implements MiddlewareInterface public function __construct( RouterInterface $router, UrlShortenerInterface $urlShortener, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { $this->router = $router; $this->urlShortener = $urlShortener; diff --git a/module/Core/src/Action/RedirectAction.php b/module/Core/src/Action/RedirectAction.php index 1f622543..81ca6fd8 100644 --- a/module/Core/src/Action/RedirectAction.php +++ b/module/Core/src/Action/RedirectAction.php @@ -25,7 +25,7 @@ class RedirectAction extends AbstractTrackingAction VisitsTrackerInterface $visitTracker, Options\AppOptions $appOptions, Options\NotFoundShortUrlOptions $notFoundOptions, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { parent::__construct($urlShortener, $visitTracker, $appOptions, $logger); $this->notFoundOptions = $notFoundOptions; diff --git a/module/Core/src/Entity/ShortUrl.php b/module/Core/src/Entity/ShortUrl.php index 5a906de6..0f5cf088 100644 --- a/module/Core/src/Entity/ShortUrl.php +++ b/module/Core/src/Entity/ShortUrl.php @@ -30,7 +30,7 @@ class ShortUrl extends AbstractEntity /** @var integer|null */ private $maxVisits; - public function __construct(string $longUrl, ShortUrlMeta $meta = null) + public function __construct(string $longUrl, ?ShortUrlMeta $meta = null) { $meta = $meta ?? ShortUrlMeta::createEmpty(); diff --git a/module/Core/src/Exception/DeleteShortUrlException.php b/module/Core/src/Exception/DeleteShortUrlException.php index d787290c..1acb48f2 100644 --- a/module/Core/src/Exception/DeleteShortUrlException.php +++ b/module/Core/src/Exception/DeleteShortUrlException.php @@ -12,7 +12,7 @@ class DeleteShortUrlException extends RuntimeException /** @var int */ private $visitsThreshold; - public function __construct(int $visitsThreshold, string $message = '', int $code = 0, Throwable $previous = null) + public function __construct(int $visitsThreshold, string $message = '', int $code = 0, ?Throwable $previous = null) { $this->visitsThreshold = $visitsThreshold; parent::__construct($message, $code, $previous); diff --git a/module/Core/src/Exception/InvalidUrlException.php b/module/Core/src/Exception/InvalidUrlException.php index 26d6cd99..1f5f9ac5 100644 --- a/module/Core/src/Exception/InvalidUrlException.php +++ b/module/Core/src/Exception/InvalidUrlException.php @@ -9,7 +9,7 @@ use function sprintf; class InvalidUrlException extends RuntimeException { - public static function fromUrl(string $url, Throwable $previous = null): self + public static function fromUrl(string $url, ?Throwable $previous = null): self { $code = $previous !== null ? $previous->getCode() : -1; return new static(sprintf('Provided URL "%s" is not an existing and valid URL', $url), $code, $previous); diff --git a/module/Core/src/Exception/ValidationException.php b/module/Core/src/Exception/ValidationException.php index 0e0d6d9e..6058c6a6 100644 --- a/module/Core/src/Exception/ValidationException.php +++ b/module/Core/src/Exception/ValidationException.php @@ -6,12 +6,12 @@ namespace Shlinkio\Shlink\Core\Exception; use Throwable; use Zend\InputFilter\InputFilterInterface; -use const PHP_EOL; - use function is_array; use function print_r; use function sprintf; +use const PHP_EOL; + class ValidationException extends RuntimeException { /** @var array */ @@ -21,7 +21,7 @@ class ValidationException extends RuntimeException string $message = '', array $invalidElements = [], int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ) { $this->invalidElements = $invalidElements; parent::__construct($message, $code, $previous); @@ -32,7 +32,7 @@ class ValidationException extends RuntimeException * @param \Throwable|null $prev * @return ValidationException */ - public static function fromInputFilter(InputFilterInterface $inputFilter, Throwable $prev = null): self + public static function fromInputFilter(InputFilterInterface $inputFilter, ?Throwable $prev = null): self { return static::fromArray($inputFilter->getMessages(), $prev); } @@ -42,7 +42,7 @@ class ValidationException extends RuntimeException * @param \Throwable|null $prev * @return ValidationException */ - private static function fromArray(array $invalidData, Throwable $prev = null): self + private static function fromArray(array $invalidData, ?Throwable $prev = null): self { return new self( sprintf( diff --git a/module/Core/src/Repository/ShortUrlRepository.php b/module/Core/src/Repository/ShortUrlRepository.php index 33119e89..b1d22b08 100644 --- a/module/Core/src/Repository/ShortUrlRepository.php +++ b/module/Core/src/Repository/ShortUrlRepository.php @@ -22,9 +22,9 @@ class ShortUrlRepository extends EntityRepository implements ShortUrlRepositoryI * @return ShortUrl[] */ public function findList( - int $limit = null, - int $offset = null, - string $searchTerm = null, + ?int $limit = null, + ?int $offset = null, + ?string $searchTerm = null, array $tags = [], $orderBy = null ): array { @@ -76,7 +76,7 @@ class ShortUrlRepository extends EntityRepository implements ShortUrlRepositoryI return $qb->getQuery()->getResult(); } - public function countList(string $searchTerm = null, array $tags = []): int + public function countList(?string $searchTerm = null, array $tags = []): int { $qb = $this->createListQueryBuilder($searchTerm, $tags); $qb->select('COUNT(DISTINCT s)'); diff --git a/module/Core/src/Service/ShortUrlService.php b/module/Core/src/Service/ShortUrlService.php index 17f0a2b2..1b95ea34 100644 --- a/module/Core/src/Service/ShortUrlService.php +++ b/module/Core/src/Service/ShortUrlService.php @@ -31,7 +31,7 @@ class ShortUrlService implements ShortUrlServiceInterface * @param array|string|null $orderBy * @return ShortUrl[]|Paginator */ - public function listShortUrls(int $page = 1, string $searchQuery = null, array $tags = [], $orderBy = null) + public function listShortUrls(int $page = 1, ?string $searchQuery = null, array $tags = [], $orderBy = null) { /** @var ShortUrlRepository $repo */ $repo = $this->em->getRepository(ShortUrl::class); diff --git a/module/Core/src/Service/ShortUrlServiceInterface.php b/module/Core/src/Service/ShortUrlServiceInterface.php index 820b1fe1..19b7b341 100644 --- a/module/Core/src/Service/ShortUrlServiceInterface.php +++ b/module/Core/src/Service/ShortUrlServiceInterface.php @@ -15,7 +15,7 @@ interface ShortUrlServiceInterface * @param array|string|null $orderBy * @return ShortUrl[]|Paginator */ - public function listShortUrls(int $page = 1, string $searchQuery = null, array $tags = [], $orderBy = null); + public function listShortUrls(int $page = 1, ?string $searchQuery = null, array $tags = [], $orderBy = null); /** * @param string[] $tags diff --git a/module/Core/test/Action/PreviewActionTest.php b/module/Core/test/Action/PreviewActionTest.php index de9d9af6..3fba9948 100644 --- a/module/Core/test/Action/PreviewActionTest.php +++ b/module/Core/test/Action/PreviewActionTest.php @@ -18,10 +18,10 @@ use ShlinkioTest\Shlink\Common\Util\TestUtils; use Zend\Diactoros\Response; use Zend\Diactoros\ServerRequest; -use const FILEINFO_MIME; - use function filesize; +use const FILEINFO_MIME; + class PreviewActionTest extends TestCase { /** @var PreviewAction */ diff --git a/module/EventDispatcher/src/Async/TaskRunnerDelegator.php b/module/EventDispatcher/src/Async/TaskRunnerDelegator.php index 887313df..8c0be644 100644 --- a/module/EventDispatcher/src/Async/TaskRunnerDelegator.php +++ b/module/EventDispatcher/src/Async/TaskRunnerDelegator.php @@ -14,7 +14,7 @@ class TaskRunnerDelegator implements DelegatorFactoryInterface ContainerInterface $container, $name, callable $callback, - array $options = null + ?array $options = null ): HttpServer { $server = $callback(); $logger = $container->get(LoggerInterface::class); diff --git a/module/EventDispatcher/src/Async/TaskRunnerFactory.php b/module/EventDispatcher/src/Async/TaskRunnerFactory.php index b50ee791..935b6d61 100644 --- a/module/EventDispatcher/src/Async/TaskRunnerFactory.php +++ b/module/EventDispatcher/src/Async/TaskRunnerFactory.php @@ -9,7 +9,7 @@ use Zend\ServiceManager\Factory\FactoryInterface; class TaskRunnerFactory implements FactoryInterface { - public function __invoke(ContainerInterface $container, $requestedName, array $options = null): TaskRunner + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): TaskRunner { $logger = $container->get(LoggerInterface::class); return new TaskRunner($logger, $container); diff --git a/module/EventDispatcher/src/Listener/ListenerProviderFactory.php b/module/EventDispatcher/src/Listener/ListenerProviderFactory.php index 1fb629f2..d40687b9 100644 --- a/module/EventDispatcher/src/Listener/ListenerProviderFactory.php +++ b/module/EventDispatcher/src/Listener/ListenerProviderFactory.php @@ -13,7 +13,7 @@ use function Shlinkio\Shlink\EventDispatcher\asyncListener; class ListenerProviderFactory implements FactoryInterface { - public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) { $config = $container->has('config') ? $container->get('config') : []; $events = $config['events'] ?? []; diff --git a/module/Rest/config/entities-mappings/Shlinkio.Shlink.Rest.Entity.ApiKey.php b/module/Rest/config/entities-mappings/Shlinkio.Shlink.Rest.Entity.ApiKey.php index f790d925..edb80dcf 100644 --- a/module/Rest/config/entities-mappings/Shlinkio.Shlink.Rest.Entity.ApiKey.php +++ b/module/Rest/config/entities-mappings/Shlinkio.Shlink.Rest.Entity.ApiKey.php @@ -5,7 +5,6 @@ namespace Shlinkio\Shlink\Rest; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; -use Doctrine\ORM\Mapping\ClassMetadata; use Shlinkio\Shlink\Common\Type\ChronosDateTimeType; /** @var $metadata ClassMetadata */ diff --git a/module/Rest/src/Action/AbstractRestAction.php b/module/Rest/src/Action/AbstractRestAction.php index 7996902d..a7aa4c5b 100644 --- a/module/Rest/src/Action/AbstractRestAction.php +++ b/module/Rest/src/Action/AbstractRestAction.php @@ -19,7 +19,7 @@ abstract class AbstractRestAction implements RequestHandlerInterface, RequestMet /** @var LoggerInterface */ protected $logger; - public function __construct(LoggerInterface $logger = null) + public function __construct(?LoggerInterface $logger = null) { $this->logger = $logger ?: new NullLogger(); } diff --git a/module/Rest/src/Action/AuthenticateAction.php b/module/Rest/src/Action/AuthenticateAction.php index e310e48f..6fbc26b0 100644 --- a/module/Rest/src/Action/AuthenticateAction.php +++ b/module/Rest/src/Action/AuthenticateAction.php @@ -26,7 +26,7 @@ class AuthenticateAction extends AbstractRestAction public function __construct( ApiKeyServiceInterface $apiKeyService, JWTServiceInterface $jwtService, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { parent::__construct($logger); $this->apiKeyService = $apiKeyService; diff --git a/module/Rest/src/Action/HealthAction.php b/module/Rest/src/Action/HealthAction.php index 2cb08030..b056862f 100644 --- a/module/Rest/src/Action/HealthAction.php +++ b/module/Rest/src/Action/HealthAction.php @@ -25,7 +25,7 @@ class HealthAction extends AbstractRestAction /** @var Connection */ private $conn; - public function __construct(Connection $conn, AppOptions $options, LoggerInterface $logger = null) + public function __construct(Connection $conn, AppOptions $options, ?LoggerInterface $logger = null) { parent::__construct($logger); $this->conn = $conn; diff --git a/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php b/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php index bd242bcc..41c456c2 100644 --- a/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php +++ b/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php @@ -29,7 +29,7 @@ abstract class AbstractCreateShortUrlAction extends AbstractRestAction public function __construct( UrlShortenerInterface $urlShortener, array $domainConfig, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { parent::__construct($logger); $this->urlShortener = $urlShortener; diff --git a/module/Rest/src/Action/ShortUrl/DeleteShortUrlAction.php b/module/Rest/src/Action/ShortUrl/DeleteShortUrlAction.php index df12c549..4f9c3d1b 100644 --- a/module/Rest/src/Action/ShortUrl/DeleteShortUrlAction.php +++ b/module/Rest/src/Action/ShortUrl/DeleteShortUrlAction.php @@ -23,7 +23,7 @@ class DeleteShortUrlAction extends AbstractRestAction /** @var DeleteShortUrlServiceInterface */ private $deleteShortUrlService; - public function __construct(DeleteShortUrlServiceInterface $deleteShortUrlService, LoggerInterface $logger = null) + public function __construct(DeleteShortUrlServiceInterface $deleteShortUrlService, ?LoggerInterface $logger = null) { parent::__construct($logger); $this->deleteShortUrlService = $deleteShortUrlService; diff --git a/module/Rest/src/Action/ShortUrl/EditShortUrlAction.php b/module/Rest/src/Action/ShortUrl/EditShortUrlAction.php index b7bc54ab..13b95b83 100644 --- a/module/Rest/src/Action/ShortUrl/EditShortUrlAction.php +++ b/module/Rest/src/Action/ShortUrl/EditShortUrlAction.php @@ -24,7 +24,7 @@ class EditShortUrlAction extends AbstractRestAction /** @var ShortUrlServiceInterface */ private $shortUrlService; - public function __construct(ShortUrlServiceInterface $shortUrlService, LoggerInterface $logger = null) + public function __construct(ShortUrlServiceInterface $shortUrlService, ?LoggerInterface $logger = null) { parent::__construct($logger); $this->shortUrlService = $shortUrlService; diff --git a/module/Rest/src/Action/ShortUrl/EditShortUrlTagsAction.php b/module/Rest/src/Action/ShortUrl/EditShortUrlTagsAction.php index dbb8d0a0..b739da70 100644 --- a/module/Rest/src/Action/ShortUrl/EditShortUrlTagsAction.php +++ b/module/Rest/src/Action/ShortUrl/EditShortUrlTagsAction.php @@ -22,7 +22,7 @@ class EditShortUrlTagsAction extends AbstractRestAction /** @var ShortUrlServiceInterface */ private $shortUrlService; - public function __construct(ShortUrlServiceInterface $shortUrlService, LoggerInterface $logger = null) + public function __construct(ShortUrlServiceInterface $shortUrlService, ?LoggerInterface $logger = null) { parent::__construct($logger); $this->shortUrlService = $shortUrlService; diff --git a/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php b/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php index bd258273..7c1c3db9 100644 --- a/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php +++ b/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php @@ -29,7 +29,7 @@ class ListShortUrlsAction extends AbstractRestAction public function __construct( ShortUrlServiceInterface $shortUrlService, array $domainConfig, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { parent::__construct($logger); $this->shortUrlService = $shortUrlService; diff --git a/module/Rest/src/Action/ShortUrl/ResolveShortUrlAction.php b/module/Rest/src/Action/ShortUrl/ResolveShortUrlAction.php index 7fc75a58..13fc1258 100644 --- a/module/Rest/src/Action/ShortUrl/ResolveShortUrlAction.php +++ b/module/Rest/src/Action/ShortUrl/ResolveShortUrlAction.php @@ -30,7 +30,7 @@ class ResolveShortUrlAction extends AbstractRestAction public function __construct( UrlShortenerInterface $urlShortener, array $domainConfig, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { parent::__construct($logger); $this->urlShortener = $urlShortener; diff --git a/module/Rest/src/Action/ShortUrl/SingleStepCreateShortUrlAction.php b/module/Rest/src/Action/ShortUrl/SingleStepCreateShortUrlAction.php index 5de188bb..a2e485fc 100644 --- a/module/Rest/src/Action/ShortUrl/SingleStepCreateShortUrlAction.php +++ b/module/Rest/src/Action/ShortUrl/SingleStepCreateShortUrlAction.php @@ -23,7 +23,7 @@ class SingleStepCreateShortUrlAction extends AbstractCreateShortUrlAction UrlShortenerInterface $urlShortener, ApiKeyServiceInterface $apiKeyService, array $domainConfig, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { parent::__construct($urlShortener, $domainConfig, $logger); $this->apiKeyService = $apiKeyService; diff --git a/module/Rest/src/Action/Tag/CreateTagsAction.php b/module/Rest/src/Action/Tag/CreateTagsAction.php index 05e758dc..d7f49ab8 100644 --- a/module/Rest/src/Action/Tag/CreateTagsAction.php +++ b/module/Rest/src/Action/Tag/CreateTagsAction.php @@ -18,7 +18,7 @@ class CreateTagsAction extends AbstractRestAction /** @var TagServiceInterface */ private $tagService; - public function __construct(TagServiceInterface $tagService, LoggerInterface $logger = null) + public function __construct(TagServiceInterface $tagService, ?LoggerInterface $logger = null) { parent::__construct($logger); $this->tagService = $tagService; diff --git a/module/Rest/src/Action/Tag/DeleteTagsAction.php b/module/Rest/src/Action/Tag/DeleteTagsAction.php index 67764871..a796017d 100644 --- a/module/Rest/src/Action/Tag/DeleteTagsAction.php +++ b/module/Rest/src/Action/Tag/DeleteTagsAction.php @@ -18,7 +18,7 @@ class DeleteTagsAction extends AbstractRestAction /** @var TagServiceInterface */ private $tagService; - public function __construct(TagServiceInterface $tagService, LoggerInterface $logger = null) + public function __construct(TagServiceInterface $tagService, ?LoggerInterface $logger = null) { parent::__construct($logger); $this->tagService = $tagService; diff --git a/module/Rest/src/Action/Tag/ListTagsAction.php b/module/Rest/src/Action/Tag/ListTagsAction.php index bf0e7751..7213ea5a 100644 --- a/module/Rest/src/Action/Tag/ListTagsAction.php +++ b/module/Rest/src/Action/Tag/ListTagsAction.php @@ -18,7 +18,7 @@ class ListTagsAction extends AbstractRestAction /** @var TagServiceInterface */ private $tagService; - public function __construct(TagServiceInterface $tagService, LoggerInterface $logger = null) + public function __construct(TagServiceInterface $tagService, ?LoggerInterface $logger = null) { parent::__construct($logger); $this->tagService = $tagService; diff --git a/module/Rest/src/Action/Tag/UpdateTagAction.php b/module/Rest/src/Action/Tag/UpdateTagAction.php index 60a84831..ee85eb14 100644 --- a/module/Rest/src/Action/Tag/UpdateTagAction.php +++ b/module/Rest/src/Action/Tag/UpdateTagAction.php @@ -23,7 +23,7 @@ class UpdateTagAction extends AbstractRestAction /** @var TagServiceInterface */ private $tagService; - public function __construct(TagServiceInterface $tagService, LoggerInterface $logger = null) + public function __construct(TagServiceInterface $tagService, ?LoggerInterface $logger = null) { parent::__construct($logger); $this->tagService = $tagService; diff --git a/module/Rest/src/Action/Visit/GetVisitsAction.php b/module/Rest/src/Action/Visit/GetVisitsAction.php index 6f062325..ffd73b98 100644 --- a/module/Rest/src/Action/Visit/GetVisitsAction.php +++ b/module/Rest/src/Action/Visit/GetVisitsAction.php @@ -26,7 +26,7 @@ class GetVisitsAction extends AbstractRestAction /** @var VisitsTrackerInterface */ private $visitsTracker; - public function __construct(VisitsTrackerInterface $visitsTracker, LoggerInterface $logger = null) + public function __construct(VisitsTrackerInterface $visitsTracker, ?LoggerInterface $logger = null) { parent::__construct($logger); $this->visitsTracker = $visitsTracker; diff --git a/module/Rest/src/Authentication/AuthenticationPluginManagerFactory.php b/module/Rest/src/Authentication/AuthenticationPluginManagerFactory.php index 9e64a75a..ae697a00 100644 --- a/module/Rest/src/Authentication/AuthenticationPluginManagerFactory.php +++ b/module/Rest/src/Authentication/AuthenticationPluginManagerFactory.php @@ -23,7 +23,7 @@ class AuthenticationPluginManagerFactory implements FactoryInterface * creating a service. * @throws ContainerException if any other error occurs */ - public function __invoke(ContainerInterface $container, $requestedName, array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) { $config = $container->get('config') ?? []; return new AuthenticationPluginManager($container, $config['auth']['plugins'] ?? []); diff --git a/module/Rest/src/Authentication/JWTServiceInterface.php b/module/Rest/src/Authentication/JWTServiceInterface.php index ba162aa8..4cea3148 100644 --- a/module/Rest/src/Authentication/JWTServiceInterface.php +++ b/module/Rest/src/Authentication/JWTServiceInterface.php @@ -8,8 +8,8 @@ use Shlinkio\Shlink\Rest\Exception\AuthenticationException; interface JWTServiceInterface { - const DEFAULT_LIFETIME = 604800; // 1 week - const DEFAULT_ENCRYPTION_ALG = 'HS256'; + public const DEFAULT_LIFETIME = 604800; // 1 week + public const DEFAULT_ENCRYPTION_ALG = 'HS256'; /** * Creates a new JSON web token por provided API key diff --git a/module/Rest/src/Authentication/Plugin/AuthorizationHeaderPlugin.php b/module/Rest/src/Authentication/Plugin/AuthorizationHeaderPlugin.php index da82652a..5d326d1a 100644 --- a/module/Rest/src/Authentication/Plugin/AuthorizationHeaderPlugin.php +++ b/module/Rest/src/Authentication/Plugin/AuthorizationHeaderPlugin.php @@ -60,7 +60,7 @@ class AuthorizationHeaderPlugin implements AuthenticationPluginInterface } } - private function createInvalidTokenError(Throwable $prev = null): VerifyAuthenticationException + private function createInvalidTokenError(?Throwable $prev = null): VerifyAuthenticationException { return VerifyAuthenticationException::withError( RestUtils::INVALID_AUTH_TOKEN_ERROR, diff --git a/module/Rest/src/Exception/VerifyAuthenticationException.php b/module/Rest/src/Exception/VerifyAuthenticationException.php index cd6404c1..42547dfb 100644 --- a/module/Rest/src/Exception/VerifyAuthenticationException.php +++ b/module/Rest/src/Exception/VerifyAuthenticationException.php @@ -19,14 +19,14 @@ class VerifyAuthenticationException extends RuntimeException string $publicMessage, string $message = '', int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ) { parent::__construct($message, $code, $previous); $this->errorCode = $errorCode; $this->publicMessage = $publicMessage; } - public static function withError(string $errorCode, string $publicMessage, Throwable $prev = null): self + public static function withError(string $errorCode, string $publicMessage, ?Throwable $prev = null): self { return new self( $errorCode, diff --git a/module/Rest/src/Middleware/AuthenticationMiddleware.php b/module/Rest/src/Middleware/AuthenticationMiddleware.php index 2687d6df..f8061045 100644 --- a/module/Rest/src/Middleware/AuthenticationMiddleware.php +++ b/module/Rest/src/Middleware/AuthenticationMiddleware.php @@ -36,7 +36,7 @@ class AuthenticationMiddleware implements MiddlewareInterface, StatusCodeInterfa public function __construct( RequestToHttpAuthPluginInterface $requestToAuthPlugin, array $routesWhitelist, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { $this->routesWhitelist = $routesWhitelist; $this->requestToAuthPlugin = $requestToAuthPlugin; diff --git a/module/Rest/test-api/Fixtures/ApiKeyFixture.php b/module/Rest/test-api/Fixtures/ApiKeyFixture.php index 8990faa2..589b6989 100644 --- a/module/Rest/test-api/Fixtures/ApiKeyFixture.php +++ b/module/Rest/test-api/Fixtures/ApiKeyFixture.php @@ -19,7 +19,7 @@ class ApiKeyFixture implements FixtureInterface $manager->flush(); } - private function buildApiKey(string $key, bool $enabled, Chronos $expiresAt = null): ApiKey + private function buildApiKey(string $key, bool $enabled, ?Chronos $expiresAt = null): ApiKey { $apiKey = new ApiKey($expiresAt); $refObj = new ReflectionObject($apiKey);