Updated to coding-standard library v1.2.2

This commit is contained in:
Alejandro Celaya 2019-08-01 19:49:54 +02:00
parent 3562afc2bd
commit aff1df32f2
63 changed files with 78 additions and 83 deletions

View file

@ -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.

View file

@ -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",

View file

@ -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,

View file

@ -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);

View file

@ -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 */

View file

@ -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

View file

@ -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);
}

View file

@ -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();

View file

@ -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);

View file

@ -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();

View file

@ -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;

View file

@ -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' => []]);

View file

@ -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'] ?? []);

View file

@ -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,

View file

@ -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);

View file

@ -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(), [

View file

@ -12,5 +12,5 @@ interface DbUpdaterInterface
/**
* @throws RuntimeException
*/
public function downloadFreshCopy(callable $handleProgress = null): void;
public function downloadFreshCopy(?callable $handleProgress = null): void;
}

View file

@ -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}';

View file

@ -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'] ?? [];

View file

@ -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;
}

View file

@ -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;

View file

@ -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);

View file

@ -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 */

View file

@ -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);

View file

@ -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 */

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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();

View file

@ -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);

View file

@ -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);

View file

@ -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(

View file

@ -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)');

View file

@ -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);

View file

@ -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

View file

@ -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 */

View file

@ -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);

View file

@ -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);

View file

@ -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'] ?? [];

View file

@ -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 */

View file

@ -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();
}

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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'] ?? []);

View file

@ -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

View file

@ -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,

View file

@ -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,

View file

@ -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;

View file

@ -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);