mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-29 13:03:52 +03:00
Updated to coding-standard library v1.2.2
This commit is contained in:
parent
3562afc2bd
commit
aff1df32f2
63 changed files with 78 additions and 83 deletions
|
@ -43,7 +43,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
|
||||||
|
|
||||||
#### Changed
|
#### 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
|
### Deprecated
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
|
||||||
#### Fixed
|
#### 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.
|
* [#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.
|
* [#427](https://github.com/shlinkio/shlink/issues/427) Fixed shlink being unusable after a database error on swoole contexts.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
"phpunit/phpcov": "^6.0",
|
"phpunit/phpcov": "^6.0",
|
||||||
"phpunit/phpunit": "^8.0",
|
"phpunit/phpunit": "^8.0",
|
||||||
"roave/security-advisories": "dev-master",
|
"roave/security-advisories": "dev-master",
|
||||||
"shlinkio/php-coding-standard": "~1.1.0",
|
"shlinkio/php-coding-standard": "~1.2.2",
|
||||||
"symfony/dotenv": "^4.2",
|
"symfony/dotenv": "^4.2",
|
||||||
"symfony/var-dumper": "^4.2",
|
"symfony/var-dumper": "^4.2",
|
||||||
"zendframework/zend-component-installer": "^2.1",
|
"zendframework/zend-component-installer": "^2.1",
|
||||||
|
|
|
@ -11,13 +11,13 @@ class GeolocationDbUpdateFailedException extends RuntimeException implements Exc
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
private $olderDbExists;
|
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;
|
$this->olderDbExists = $olderDbExists;
|
||||||
parent::__construct($message, $code, $previous);
|
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(
|
return new self(
|
||||||
$olderDbExists,
|
$olderDbExists,
|
||||||
|
|
|
@ -29,7 +29,7 @@ class ApplicationFactory implements FactoryInterface
|
||||||
* @throws ServiceNotCreatedException if an exception is raised when creating a service.
|
* @throws ServiceNotCreatedException if an exception is raised when creating a service.
|
||||||
* @throws ContainerException if any other error occurs
|
* @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'];
|
$config = $container->get('config')['cli'];
|
||||||
$appOptions = $container->get(AppOptions::class);
|
$appOptions = $container->get(AppOptions::class);
|
||||||
|
|
|
@ -12,11 +12,11 @@ use Shlinkio\Shlink\Core\Service\ShortUrl\DeleteShortUrlServiceInterface;
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
|
||||||
use const PHP_EOL;
|
|
||||||
|
|
||||||
use function array_pop;
|
use function array_pop;
|
||||||
use function sprintf;
|
use function sprintf;
|
||||||
|
|
||||||
|
use const PHP_EOL;
|
||||||
|
|
||||||
class DeleteShortUrlCommandTest extends TestCase
|
class DeleteShortUrlCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
/** @var CommandTester */
|
/** @var CommandTester */
|
||||||
|
|
|
@ -3,8 +3,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\Common;
|
namespace Shlinkio\Shlink\Common;
|
||||||
|
|
||||||
use const JSON_ERROR_NONE;
|
|
||||||
|
|
||||||
use function getenv;
|
use function getenv;
|
||||||
use function json_decode as spl_json_decode;
|
use function json_decode as spl_json_decode;
|
||||||
use function json_last_error;
|
use function json_last_error;
|
||||||
|
@ -13,6 +11,8 @@ use function sprintf;
|
||||||
use function strtolower;
|
use function strtolower;
|
||||||
use function trim;
|
use function trim;
|
||||||
|
|
||||||
|
use const JSON_ERROR_NONE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of an environment variable. Supports boolean, empty and null.
|
* Gets the value of an environment variable. Supports boolean, empty and null.
|
||||||
* This is basically Laravel's env helper
|
* This is basically Laravel's env helper
|
||||||
|
|
|
@ -9,7 +9,7 @@ use function sprintf;
|
||||||
|
|
||||||
class WrongIpException extends RuntimeException
|
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);
|
return new self(sprintf('Provided IP "%s" is invalid', $ipAddress), 0, $prev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use function Shlinkio\Shlink\Common\env;
|
||||||
|
|
||||||
class CacheFactory implements FactoryInterface
|
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);
|
$appOptions = $container->get(AppOptions::class);
|
||||||
$adapter = env('APP_ENV', 'pro') === 'pro' ? new Cache\ApcuCache() : new Cache\ArrayCache();
|
$adapter = env('APP_ENV', 'pro') === 'pro' ? new Cache\ApcuCache() : new Cache\ArrayCache();
|
||||||
|
|
|
@ -44,7 +44,7 @@ class DottedAccessConfigAbstractFactory implements AbstractFactoryInterface
|
||||||
* creating a service.
|
* creating a service.
|
||||||
* @throws ContainerException if any other error occurs
|
* @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);
|
$parts = explode('.', $requestedName);
|
||||||
$serviceName = array_shift($parts);
|
$serviceName = array_shift($parts);
|
||||||
|
|
|
@ -25,7 +25,7 @@ class EmptyResponseImplicitOptionsMiddlewareFactory implements FactoryInterface
|
||||||
* creating a service.
|
* creating a service.
|
||||||
* @throws ContainerException if any other error occurs
|
* @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 ImplicitOptionsMiddleware(function () {
|
||||||
return new EmptyResponse();
|
return new EmptyResponse();
|
||||||
|
|
|
@ -25,7 +25,7 @@ class EntityManagerFactory implements FactoryInterface
|
||||||
* @throws ORMException
|
* @throws ORMException
|
||||||
* @throws DBALException
|
* @throws DBALException
|
||||||
*/
|
*/
|
||||||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
|
public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null)
|
||||||
{
|
{
|
||||||
$globalConfig = $container->get('config');
|
$globalConfig = $container->get('config');
|
||||||
$isDevMode = isset($globalConfig['debug']) ? ((bool) $globalConfig['debug']) : false;
|
$isDevMode = isset($globalConfig['debug']) ? ((bool) $globalConfig['debug']) : false;
|
||||||
|
|
|
@ -27,7 +27,7 @@ class LoggerFactory implements FactoryInterface
|
||||||
* creating a service.
|
* creating a service.
|
||||||
* @throws ContainerException if any other error occurs
|
* @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') : [];
|
$config = $container->has('config') ? $container->get('config') : [];
|
||||||
Cascade::fileConfig($config['logger'] ?? ['loggers' => []]);
|
Cascade::fileConfig($config['logger'] ?? ['loggers' => []]);
|
||||||
|
|
|
@ -24,7 +24,7 @@ class TranslatorFactory implements FactoryInterface
|
||||||
* creating a service.
|
* creating a service.
|
||||||
* @throws ContainerException if any other error occurs
|
* @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');
|
$config = $container->get('config');
|
||||||
return Translator::factory($config['translator'] ?? []);
|
return Translator::factory($config['translator'] ?? []);
|
||||||
|
|
|
@ -24,7 +24,7 @@ class ImageBuilderFactory implements FactoryInterface
|
||||||
* creating a service.
|
* creating a service.
|
||||||
* @throws ContainerException if any other error occurs
|
* @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' => [
|
return new ImageBuilder($container, ['factories' => [
|
||||||
Image::class => ImageFactory::class,
|
Image::class => ImageFactory::class,
|
||||||
|
|
|
@ -24,7 +24,7 @@ class ImageFactory implements FactoryInterface
|
||||||
* creating a service.
|
* creating a service.
|
||||||
* @throws ContainerException if any other error occurs
|
* @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'];
|
$config = $container->get('config')['wkhtmltopdf'];
|
||||||
$image = new Image($config['images'] ?? null);
|
$image = new Image($config['images'] ?? null);
|
||||||
|
|
|
@ -37,7 +37,7 @@ class DbUpdater implements DbUpdaterInterface
|
||||||
/**
|
/**
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function downloadFreshCopy(callable $handleProgress = null): void
|
public function downloadFreshCopy(?callable $handleProgress = null): void
|
||||||
{
|
{
|
||||||
$tempDir = $this->options->getTempDir();
|
$tempDir = $this->options->getTempDir();
|
||||||
$compressedFile = sprintf('%s/%s', $tempDir, self::DB_COMPRESSED_FILE);
|
$compressedFile = sprintf('%s/%s', $tempDir, self::DB_COMPRESSED_FILE);
|
||||||
|
@ -48,7 +48,7 @@ class DbUpdater implements DbUpdaterInterface
|
||||||
$this->deleteTempFiles([$compressedFile, $tempFullPath]);
|
$this->deleteTempFiles([$compressedFile, $tempFullPath]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function downloadDbFile(string $dest, callable $handleProgress = null): void
|
private function downloadDbFile(string $dest, ?callable $handleProgress = null): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->httpClient->request(RequestMethod::METHOD_GET, $this->options->getDownloadFrom(), [
|
$this->httpClient->request(RequestMethod::METHOD_GET, $this->options->getDownloadFrom(), [
|
||||||
|
|
|
@ -12,5 +12,5 @@ interface DbUpdaterInterface
|
||||||
/**
|
/**
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function downloadFreshCopy(callable $handleProgress = null): void;
|
public function downloadFreshCopy(?callable $handleProgress = null): void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,11 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\Common\Logger\Processor;
|
namespace Shlinkio\Shlink\Common\Logger\Processor;
|
||||||
|
|
||||||
use const PHP_EOL;
|
|
||||||
|
|
||||||
use function str_replace;
|
use function str_replace;
|
||||||
use function strpos;
|
use function strpos;
|
||||||
|
|
||||||
|
use const PHP_EOL;
|
||||||
|
|
||||||
final class ExceptionWithNewLineProcessor
|
final class ExceptionWithNewLineProcessor
|
||||||
{
|
{
|
||||||
private const EXCEPTION_PLACEHOLDER = '{e}';
|
private const EXCEPTION_PLACEHOLDER = '{e}';
|
||||||
|
|
|
@ -21,7 +21,7 @@ class IpAddressMiddlewareFactory implements FactoryInterface
|
||||||
* @throws ServiceNotFoundException if unable to resolve the service.
|
* @throws ServiceNotFoundException if unable to resolve the service.
|
||||||
* @throws ServiceNotCreatedException if an exception is raised when creating a 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');
|
$config = $container->get('config');
|
||||||
$headersToInspect = $config['ip_address_resolution']['headers_to_inspect'] ?? [];
|
$headersToInspect = $config['ip_address_resolution']['headers_to_inspect'] ?? [];
|
||||||
|
|
|
@ -16,9 +16,9 @@ interface PaginableRepositoryInterface
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function findList(
|
public function findList(
|
||||||
int $limit = null,
|
?int $limit = null,
|
||||||
int $offset = null,
|
?int $offset = null,
|
||||||
string $searchTerm = null,
|
?string $searchTerm = null,
|
||||||
array $tags = [],
|
array $tags = [],
|
||||||
$orderBy = null
|
$orderBy = null
|
||||||
): array;
|
): array;
|
||||||
|
@ -30,5 +30,5 @@ interface PaginableRepositoryInterface
|
||||||
* @param array $tags
|
* @param array $tags
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function countList(string $searchTerm = null, array $tags = []): int;
|
public function countList(?string $searchTerm = null, array $tags = []): int;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,11 @@ use PHPUnit\Framework\TestCase;
|
||||||
use Shlinkio\Shlink\Common\Logger\Processor\ExceptionWithNewLineProcessor;
|
use Shlinkio\Shlink\Common\Logger\Processor\ExceptionWithNewLineProcessor;
|
||||||
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
|
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
|
||||||
|
|
||||||
use const PHP_EOL;
|
|
||||||
|
|
||||||
use function Functional\map;
|
use function Functional\map;
|
||||||
use function range;
|
use function range;
|
||||||
|
|
||||||
|
use const PHP_EOL;
|
||||||
|
|
||||||
class ExceptionWithNewLineProcessorTest extends TestCase
|
class ExceptionWithNewLineProcessorTest extends TestCase
|
||||||
{
|
{
|
||||||
use StringUtilsTrait;
|
use StringUtilsTrait;
|
||||||
|
|
|
@ -14,7 +14,7 @@ class TestUtils
|
||||||
{
|
{
|
||||||
private static $prophet;
|
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();
|
$argument = $request ?: Argument::any();
|
||||||
$delegate = static::getProphet()->prophesize(RequestHandlerInterface::class);
|
$delegate = static::getProphet()->prophesize(RequestHandlerInterface::class);
|
||||||
|
|
|
@ -5,7 +5,6 @@ namespace Shlinkio\Shlink\Core;
|
||||||
|
|
||||||
use Doctrine\DBAL\Types\Type;
|
use Doctrine\DBAL\Types\Type;
|
||||||
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
||||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
|
||||||
use Shlinkio\Shlink\Common\Type\ChronosDateTimeType;
|
use Shlinkio\Shlink\Common\Type\ChronosDateTimeType;
|
||||||
|
|
||||||
/** @var $metadata ClassMetadata */
|
/** @var $metadata ClassMetadata */
|
||||||
|
|
|
@ -5,7 +5,6 @@ namespace Shlinkio\Shlink\Core;
|
||||||
|
|
||||||
use Doctrine\DBAL\Types\Type;
|
use Doctrine\DBAL\Types\Type;
|
||||||
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
||||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
|
||||||
|
|
||||||
/** @var $metadata ClassMetadata */
|
/** @var $metadata ClassMetadata */
|
||||||
$builder = new ClassMetadataBuilder($metadata);
|
$builder = new ClassMetadataBuilder($metadata);
|
||||||
|
|
|
@ -5,7 +5,6 @@ namespace Shlinkio\Shlink\Core;
|
||||||
|
|
||||||
use Doctrine\DBAL\Types\Type;
|
use Doctrine\DBAL\Types\Type;
|
||||||
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
||||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
|
||||||
use Shlinkio\Shlink\Common\Type\ChronosDateTimeType;
|
use Shlinkio\Shlink\Common\Type\ChronosDateTimeType;
|
||||||
|
|
||||||
/** @var $metadata ClassMetadata */
|
/** @var $metadata ClassMetadata */
|
||||||
|
|
|
@ -5,7 +5,6 @@ namespace Shlinkio\Shlink\Core;
|
||||||
|
|
||||||
use Doctrine\DBAL\Types\Type;
|
use Doctrine\DBAL\Types\Type;
|
||||||
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
||||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
|
||||||
|
|
||||||
/** @var $metadata ClassMetadata */
|
/** @var $metadata ClassMetadata */
|
||||||
$builder = new ClassMetadataBuilder($metadata);
|
$builder = new ClassMetadataBuilder($metadata);
|
||||||
|
|
|
@ -33,7 +33,7 @@ abstract class AbstractTrackingAction implements MiddlewareInterface
|
||||||
UrlShortenerInterface $urlShortener,
|
UrlShortenerInterface $urlShortener,
|
||||||
VisitsTrackerInterface $visitTracker,
|
VisitsTrackerInterface $visitTracker,
|
||||||
AppOptions $appOptions,
|
AppOptions $appOptions,
|
||||||
LoggerInterface $logger = null
|
?LoggerInterface $logger = null
|
||||||
) {
|
) {
|
||||||
$this->urlShortener = $urlShortener;
|
$this->urlShortener = $urlShortener;
|
||||||
$this->visitTracker = $visitTracker;
|
$this->visitTracker = $visitTracker;
|
||||||
|
|
|
@ -32,7 +32,7 @@ class PreviewAction implements MiddlewareInterface
|
||||||
public function __construct(
|
public function __construct(
|
||||||
PreviewGeneratorInterface $previewGenerator,
|
PreviewGeneratorInterface $previewGenerator,
|
||||||
UrlShortenerInterface $urlShortener,
|
UrlShortenerInterface $urlShortener,
|
||||||
LoggerInterface $logger = null
|
?LoggerInterface $logger = null
|
||||||
) {
|
) {
|
||||||
$this->previewGenerator = $previewGenerator;
|
$this->previewGenerator = $previewGenerator;
|
||||||
$this->urlShortener = $urlShortener;
|
$this->urlShortener = $urlShortener;
|
||||||
|
|
|
@ -36,7 +36,7 @@ class QrCodeAction implements MiddlewareInterface
|
||||||
public function __construct(
|
public function __construct(
|
||||||
RouterInterface $router,
|
RouterInterface $router,
|
||||||
UrlShortenerInterface $urlShortener,
|
UrlShortenerInterface $urlShortener,
|
||||||
LoggerInterface $logger = null
|
?LoggerInterface $logger = null
|
||||||
) {
|
) {
|
||||||
$this->router = $router;
|
$this->router = $router;
|
||||||
$this->urlShortener = $urlShortener;
|
$this->urlShortener = $urlShortener;
|
||||||
|
|
|
@ -25,7 +25,7 @@ class RedirectAction extends AbstractTrackingAction
|
||||||
VisitsTrackerInterface $visitTracker,
|
VisitsTrackerInterface $visitTracker,
|
||||||
Options\AppOptions $appOptions,
|
Options\AppOptions $appOptions,
|
||||||
Options\NotFoundShortUrlOptions $notFoundOptions,
|
Options\NotFoundShortUrlOptions $notFoundOptions,
|
||||||
LoggerInterface $logger = null
|
?LoggerInterface $logger = null
|
||||||
) {
|
) {
|
||||||
parent::__construct($urlShortener, $visitTracker, $appOptions, $logger);
|
parent::__construct($urlShortener, $visitTracker, $appOptions, $logger);
|
||||||
$this->notFoundOptions = $notFoundOptions;
|
$this->notFoundOptions = $notFoundOptions;
|
||||||
|
|
|
@ -30,7 +30,7 @@ class ShortUrl extends AbstractEntity
|
||||||
/** @var integer|null */
|
/** @var integer|null */
|
||||||
private $maxVisits;
|
private $maxVisits;
|
||||||
|
|
||||||
public function __construct(string $longUrl, ShortUrlMeta $meta = null)
|
public function __construct(string $longUrl, ?ShortUrlMeta $meta = null)
|
||||||
{
|
{
|
||||||
$meta = $meta ?? ShortUrlMeta::createEmpty();
|
$meta = $meta ?? ShortUrlMeta::createEmpty();
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class DeleteShortUrlException extends RuntimeException
|
||||||
/** @var int */
|
/** @var int */
|
||||||
private $visitsThreshold;
|
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;
|
$this->visitsThreshold = $visitsThreshold;
|
||||||
parent::__construct($message, $code, $previous);
|
parent::__construct($message, $code, $previous);
|
||||||
|
|
|
@ -9,7 +9,7 @@ use function sprintf;
|
||||||
|
|
||||||
class InvalidUrlException extends RuntimeException
|
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;
|
$code = $previous !== null ? $previous->getCode() : -1;
|
||||||
return new static(sprintf('Provided URL "%s" is not an existing and valid URL', $url), $code, $previous);
|
return new static(sprintf('Provided URL "%s" is not an existing and valid URL', $url), $code, $previous);
|
||||||
|
|
|
@ -6,12 +6,12 @@ namespace Shlinkio\Shlink\Core\Exception;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use Zend\InputFilter\InputFilterInterface;
|
use Zend\InputFilter\InputFilterInterface;
|
||||||
|
|
||||||
use const PHP_EOL;
|
|
||||||
|
|
||||||
use function is_array;
|
use function is_array;
|
||||||
use function print_r;
|
use function print_r;
|
||||||
use function sprintf;
|
use function sprintf;
|
||||||
|
|
||||||
|
use const PHP_EOL;
|
||||||
|
|
||||||
class ValidationException extends RuntimeException
|
class ValidationException extends RuntimeException
|
||||||
{
|
{
|
||||||
/** @var array */
|
/** @var array */
|
||||||
|
@ -21,7 +21,7 @@ class ValidationException extends RuntimeException
|
||||||
string $message = '',
|
string $message = '',
|
||||||
array $invalidElements = [],
|
array $invalidElements = [],
|
||||||
int $code = 0,
|
int $code = 0,
|
||||||
Throwable $previous = null
|
?Throwable $previous = null
|
||||||
) {
|
) {
|
||||||
$this->invalidElements = $invalidElements;
|
$this->invalidElements = $invalidElements;
|
||||||
parent::__construct($message, $code, $previous);
|
parent::__construct($message, $code, $previous);
|
||||||
|
@ -32,7 +32,7 @@ class ValidationException extends RuntimeException
|
||||||
* @param \Throwable|null $prev
|
* @param \Throwable|null $prev
|
||||||
* @return ValidationException
|
* @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);
|
return static::fromArray($inputFilter->getMessages(), $prev);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class ValidationException extends RuntimeException
|
||||||
* @param \Throwable|null $prev
|
* @param \Throwable|null $prev
|
||||||
* @return ValidationException
|
* @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(
|
return new self(
|
||||||
sprintf(
|
sprintf(
|
||||||
|
|
|
@ -22,9 +22,9 @@ class ShortUrlRepository extends EntityRepository implements ShortUrlRepositoryI
|
||||||
* @return ShortUrl[]
|
* @return ShortUrl[]
|
||||||
*/
|
*/
|
||||||
public function findList(
|
public function findList(
|
||||||
int $limit = null,
|
?int $limit = null,
|
||||||
int $offset = null,
|
?int $offset = null,
|
||||||
string $searchTerm = null,
|
?string $searchTerm = null,
|
||||||
array $tags = [],
|
array $tags = [],
|
||||||
$orderBy = null
|
$orderBy = null
|
||||||
): array {
|
): array {
|
||||||
|
@ -76,7 +76,7 @@ class ShortUrlRepository extends EntityRepository implements ShortUrlRepositoryI
|
||||||
return $qb->getQuery()->getResult();
|
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 = $this->createListQueryBuilder($searchTerm, $tags);
|
||||||
$qb->select('COUNT(DISTINCT s)');
|
$qb->select('COUNT(DISTINCT s)');
|
||||||
|
|
|
@ -31,7 +31,7 @@ class ShortUrlService implements ShortUrlServiceInterface
|
||||||
* @param array|string|null $orderBy
|
* @param array|string|null $orderBy
|
||||||
* @return ShortUrl[]|Paginator
|
* @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 */
|
/** @var ShortUrlRepository $repo */
|
||||||
$repo = $this->em->getRepository(ShortUrl::class);
|
$repo = $this->em->getRepository(ShortUrl::class);
|
||||||
|
|
|
@ -15,7 +15,7 @@ interface ShortUrlServiceInterface
|
||||||
* @param array|string|null $orderBy
|
* @param array|string|null $orderBy
|
||||||
* @return ShortUrl[]|Paginator
|
* @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
|
* @param string[] $tags
|
||||||
|
|
|
@ -18,10 +18,10 @@ use ShlinkioTest\Shlink\Common\Util\TestUtils;
|
||||||
use Zend\Diactoros\Response;
|
use Zend\Diactoros\Response;
|
||||||
use Zend\Diactoros\ServerRequest;
|
use Zend\Diactoros\ServerRequest;
|
||||||
|
|
||||||
use const FILEINFO_MIME;
|
|
||||||
|
|
||||||
use function filesize;
|
use function filesize;
|
||||||
|
|
||||||
|
use const FILEINFO_MIME;
|
||||||
|
|
||||||
class PreviewActionTest extends TestCase
|
class PreviewActionTest extends TestCase
|
||||||
{
|
{
|
||||||
/** @var PreviewAction */
|
/** @var PreviewAction */
|
||||||
|
|
|
@ -14,7 +14,7 @@ class TaskRunnerDelegator implements DelegatorFactoryInterface
|
||||||
ContainerInterface $container,
|
ContainerInterface $container,
|
||||||
$name,
|
$name,
|
||||||
callable $callback,
|
callable $callback,
|
||||||
array $options = null
|
?array $options = null
|
||||||
): HttpServer {
|
): HttpServer {
|
||||||
$server = $callback();
|
$server = $callback();
|
||||||
$logger = $container->get(LoggerInterface::class);
|
$logger = $container->get(LoggerInterface::class);
|
||||||
|
|
|
@ -9,7 +9,7 @@ use Zend\ServiceManager\Factory\FactoryInterface;
|
||||||
|
|
||||||
class TaskRunnerFactory implements 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);
|
$logger = $container->get(LoggerInterface::class);
|
||||||
return new TaskRunner($logger, $container);
|
return new TaskRunner($logger, $container);
|
||||||
|
|
|
@ -13,7 +13,7 @@ use function Shlinkio\Shlink\EventDispatcher\asyncListener;
|
||||||
|
|
||||||
class ListenerProviderFactory implements FactoryInterface
|
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') : [];
|
$config = $container->has('config') ? $container->get('config') : [];
|
||||||
$events = $config['events'] ?? [];
|
$events = $config['events'] ?? [];
|
||||||
|
|
|
@ -5,7 +5,6 @@ namespace Shlinkio\Shlink\Rest;
|
||||||
|
|
||||||
use Doctrine\DBAL\Types\Type;
|
use Doctrine\DBAL\Types\Type;
|
||||||
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
||||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
|
||||||
use Shlinkio\Shlink\Common\Type\ChronosDateTimeType;
|
use Shlinkio\Shlink\Common\Type\ChronosDateTimeType;
|
||||||
|
|
||||||
/** @var $metadata ClassMetadata */
|
/** @var $metadata ClassMetadata */
|
||||||
|
|
|
@ -19,7 +19,7 @@ abstract class AbstractRestAction implements RequestHandlerInterface, RequestMet
|
||||||
/** @var LoggerInterface */
|
/** @var LoggerInterface */
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
public function __construct(LoggerInterface $logger = null)
|
public function __construct(?LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
$this->logger = $logger ?: new NullLogger();
|
$this->logger = $logger ?: new NullLogger();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class AuthenticateAction extends AbstractRestAction
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ApiKeyServiceInterface $apiKeyService,
|
ApiKeyServiceInterface $apiKeyService,
|
||||||
JWTServiceInterface $jwtService,
|
JWTServiceInterface $jwtService,
|
||||||
LoggerInterface $logger = null
|
?LoggerInterface $logger = null
|
||||||
) {
|
) {
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
$this->apiKeyService = $apiKeyService;
|
$this->apiKeyService = $apiKeyService;
|
||||||
|
|
|
@ -25,7 +25,7 @@ class HealthAction extends AbstractRestAction
|
||||||
/** @var Connection */
|
/** @var Connection */
|
||||||
private $conn;
|
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);
|
parent::__construct($logger);
|
||||||
$this->conn = $conn;
|
$this->conn = $conn;
|
||||||
|
|
|
@ -29,7 +29,7 @@ abstract class AbstractCreateShortUrlAction extends AbstractRestAction
|
||||||
public function __construct(
|
public function __construct(
|
||||||
UrlShortenerInterface $urlShortener,
|
UrlShortenerInterface $urlShortener,
|
||||||
array $domainConfig,
|
array $domainConfig,
|
||||||
LoggerInterface $logger = null
|
?LoggerInterface $logger = null
|
||||||
) {
|
) {
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
$this->urlShortener = $urlShortener;
|
$this->urlShortener = $urlShortener;
|
||||||
|
|
|
@ -23,7 +23,7 @@ class DeleteShortUrlAction extends AbstractRestAction
|
||||||
/** @var DeleteShortUrlServiceInterface */
|
/** @var DeleteShortUrlServiceInterface */
|
||||||
private $deleteShortUrlService;
|
private $deleteShortUrlService;
|
||||||
|
|
||||||
public function __construct(DeleteShortUrlServiceInterface $deleteShortUrlService, LoggerInterface $logger = null)
|
public function __construct(DeleteShortUrlServiceInterface $deleteShortUrlService, ?LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
$this->deleteShortUrlService = $deleteShortUrlService;
|
$this->deleteShortUrlService = $deleteShortUrlService;
|
||||||
|
|
|
@ -24,7 +24,7 @@ class EditShortUrlAction extends AbstractRestAction
|
||||||
/** @var ShortUrlServiceInterface */
|
/** @var ShortUrlServiceInterface */
|
||||||
private $shortUrlService;
|
private $shortUrlService;
|
||||||
|
|
||||||
public function __construct(ShortUrlServiceInterface $shortUrlService, LoggerInterface $logger = null)
|
public function __construct(ShortUrlServiceInterface $shortUrlService, ?LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
$this->shortUrlService = $shortUrlService;
|
$this->shortUrlService = $shortUrlService;
|
||||||
|
|
|
@ -22,7 +22,7 @@ class EditShortUrlTagsAction extends AbstractRestAction
|
||||||
/** @var ShortUrlServiceInterface */
|
/** @var ShortUrlServiceInterface */
|
||||||
private $shortUrlService;
|
private $shortUrlService;
|
||||||
|
|
||||||
public function __construct(ShortUrlServiceInterface $shortUrlService, LoggerInterface $logger = null)
|
public function __construct(ShortUrlServiceInterface $shortUrlService, ?LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
$this->shortUrlService = $shortUrlService;
|
$this->shortUrlService = $shortUrlService;
|
||||||
|
|
|
@ -29,7 +29,7 @@ class ListShortUrlsAction extends AbstractRestAction
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ShortUrlServiceInterface $shortUrlService,
|
ShortUrlServiceInterface $shortUrlService,
|
||||||
array $domainConfig,
|
array $domainConfig,
|
||||||
LoggerInterface $logger = null
|
?LoggerInterface $logger = null
|
||||||
) {
|
) {
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
$this->shortUrlService = $shortUrlService;
|
$this->shortUrlService = $shortUrlService;
|
||||||
|
|
|
@ -30,7 +30,7 @@ class ResolveShortUrlAction extends AbstractRestAction
|
||||||
public function __construct(
|
public function __construct(
|
||||||
UrlShortenerInterface $urlShortener,
|
UrlShortenerInterface $urlShortener,
|
||||||
array $domainConfig,
|
array $domainConfig,
|
||||||
LoggerInterface $logger = null
|
?LoggerInterface $logger = null
|
||||||
) {
|
) {
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
$this->urlShortener = $urlShortener;
|
$this->urlShortener = $urlShortener;
|
||||||
|
|
|
@ -23,7 +23,7 @@ class SingleStepCreateShortUrlAction extends AbstractCreateShortUrlAction
|
||||||
UrlShortenerInterface $urlShortener,
|
UrlShortenerInterface $urlShortener,
|
||||||
ApiKeyServiceInterface $apiKeyService,
|
ApiKeyServiceInterface $apiKeyService,
|
||||||
array $domainConfig,
|
array $domainConfig,
|
||||||
LoggerInterface $logger = null
|
?LoggerInterface $logger = null
|
||||||
) {
|
) {
|
||||||
parent::__construct($urlShortener, $domainConfig, $logger);
|
parent::__construct($urlShortener, $domainConfig, $logger);
|
||||||
$this->apiKeyService = $apiKeyService;
|
$this->apiKeyService = $apiKeyService;
|
||||||
|
|
|
@ -18,7 +18,7 @@ class CreateTagsAction extends AbstractRestAction
|
||||||
/** @var TagServiceInterface */
|
/** @var TagServiceInterface */
|
||||||
private $tagService;
|
private $tagService;
|
||||||
|
|
||||||
public function __construct(TagServiceInterface $tagService, LoggerInterface $logger = null)
|
public function __construct(TagServiceInterface $tagService, ?LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
$this->tagService = $tagService;
|
$this->tagService = $tagService;
|
||||||
|
|
|
@ -18,7 +18,7 @@ class DeleteTagsAction extends AbstractRestAction
|
||||||
/** @var TagServiceInterface */
|
/** @var TagServiceInterface */
|
||||||
private $tagService;
|
private $tagService;
|
||||||
|
|
||||||
public function __construct(TagServiceInterface $tagService, LoggerInterface $logger = null)
|
public function __construct(TagServiceInterface $tagService, ?LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
$this->tagService = $tagService;
|
$this->tagService = $tagService;
|
||||||
|
|
|
@ -18,7 +18,7 @@ class ListTagsAction extends AbstractRestAction
|
||||||
/** @var TagServiceInterface */
|
/** @var TagServiceInterface */
|
||||||
private $tagService;
|
private $tagService;
|
||||||
|
|
||||||
public function __construct(TagServiceInterface $tagService, LoggerInterface $logger = null)
|
public function __construct(TagServiceInterface $tagService, ?LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
$this->tagService = $tagService;
|
$this->tagService = $tagService;
|
||||||
|
|
|
@ -23,7 +23,7 @@ class UpdateTagAction extends AbstractRestAction
|
||||||
/** @var TagServiceInterface */
|
/** @var TagServiceInterface */
|
||||||
private $tagService;
|
private $tagService;
|
||||||
|
|
||||||
public function __construct(TagServiceInterface $tagService, LoggerInterface $logger = null)
|
public function __construct(TagServiceInterface $tagService, ?LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
$this->tagService = $tagService;
|
$this->tagService = $tagService;
|
||||||
|
|
|
@ -26,7 +26,7 @@ class GetVisitsAction extends AbstractRestAction
|
||||||
/** @var VisitsTrackerInterface */
|
/** @var VisitsTrackerInterface */
|
||||||
private $visitsTracker;
|
private $visitsTracker;
|
||||||
|
|
||||||
public function __construct(VisitsTrackerInterface $visitsTracker, LoggerInterface $logger = null)
|
public function __construct(VisitsTrackerInterface $visitsTracker, ?LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
$this->visitsTracker = $visitsTracker;
|
$this->visitsTracker = $visitsTracker;
|
||||||
|
|
|
@ -23,7 +23,7 @@ class AuthenticationPluginManagerFactory implements FactoryInterface
|
||||||
* creating a service.
|
* creating a service.
|
||||||
* @throws ContainerException if any other error occurs
|
* @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') ?? [];
|
$config = $container->get('config') ?? [];
|
||||||
return new AuthenticationPluginManager($container, $config['auth']['plugins'] ?? []);
|
return new AuthenticationPluginManager($container, $config['auth']['plugins'] ?? []);
|
||||||
|
|
|
@ -8,8 +8,8 @@ use Shlinkio\Shlink\Rest\Exception\AuthenticationException;
|
||||||
|
|
||||||
interface JWTServiceInterface
|
interface JWTServiceInterface
|
||||||
{
|
{
|
||||||
const DEFAULT_LIFETIME = 604800; // 1 week
|
public const DEFAULT_LIFETIME = 604800; // 1 week
|
||||||
const DEFAULT_ENCRYPTION_ALG = 'HS256';
|
public const DEFAULT_ENCRYPTION_ALG = 'HS256';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new JSON web token por provided API key
|
* Creates a new JSON web token por provided API key
|
||||||
|
|
|
@ -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(
|
return VerifyAuthenticationException::withError(
|
||||||
RestUtils::INVALID_AUTH_TOKEN_ERROR,
|
RestUtils::INVALID_AUTH_TOKEN_ERROR,
|
||||||
|
|
|
@ -19,14 +19,14 @@ class VerifyAuthenticationException extends RuntimeException
|
||||||
string $publicMessage,
|
string $publicMessage,
|
||||||
string $message = '',
|
string $message = '',
|
||||||
int $code = 0,
|
int $code = 0,
|
||||||
Throwable $previous = null
|
?Throwable $previous = null
|
||||||
) {
|
) {
|
||||||
parent::__construct($message, $code, $previous);
|
parent::__construct($message, $code, $previous);
|
||||||
$this->errorCode = $errorCode;
|
$this->errorCode = $errorCode;
|
||||||
$this->publicMessage = $publicMessage;
|
$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(
|
return new self(
|
||||||
$errorCode,
|
$errorCode,
|
||||||
|
|
|
@ -36,7 +36,7 @@ class AuthenticationMiddleware implements MiddlewareInterface, StatusCodeInterfa
|
||||||
public function __construct(
|
public function __construct(
|
||||||
RequestToHttpAuthPluginInterface $requestToAuthPlugin,
|
RequestToHttpAuthPluginInterface $requestToAuthPlugin,
|
||||||
array $routesWhitelist,
|
array $routesWhitelist,
|
||||||
LoggerInterface $logger = null
|
?LoggerInterface $logger = null
|
||||||
) {
|
) {
|
||||||
$this->routesWhitelist = $routesWhitelist;
|
$this->routesWhitelist = $routesWhitelist;
|
||||||
$this->requestToAuthPlugin = $requestToAuthPlugin;
|
$this->requestToAuthPlugin = $requestToAuthPlugin;
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ApiKeyFixture implements FixtureInterface
|
||||||
$manager->flush();
|
$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);
|
$apiKey = new ApiKey($expiresAt);
|
||||||
$refObj = new ReflectionObject($apiKey);
|
$refObj = new ReflectionObject($apiKey);
|
||||||
|
|
Loading…
Add table
Reference in a new issue