mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-17 15:59:56 +03:00
Merge pull request #578 from acelaya-forks/feature/php-74-requirement
Feature/php 74 requirement
This commit is contained in:
commit
8cd81d0441
162 changed files with 399 additions and 782 deletions
10
.travis.yml
10
.travis.yml
|
@ -5,14 +5,8 @@ branches:
|
|||
- /.*/
|
||||
|
||||
php:
|
||||
- '7.2'
|
||||
- '7.3'
|
||||
- '7.4'
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: '7.4'
|
||||
|
||||
services:
|
||||
- mysql
|
||||
- postgresql
|
||||
|
@ -39,7 +33,7 @@ before_script:
|
|||
|
||||
script:
|
||||
- composer ci
|
||||
- if [[ ! -z "$DOCKERFILE_CHANGED" && "${TRAVIS_PHP_VERSION}" == "7.2" ]]; then docker build -t shlink-docker-image:temp . ; fi
|
||||
- if [[ ! -z "$DOCKERFILE_CHANGED" && "${TRAVIS_PHP_VERSION}" == "7.4" ]]; then docker build -t shlink-docker-image:temp . ; fi
|
||||
|
||||
after_success:
|
||||
- rm -f build/clover.xml
|
||||
|
@ -61,4 +55,4 @@ deploy:
|
|||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
php: '7.2'
|
||||
php: '7.4'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM php:7.3.11-alpine3.10
|
||||
FROM php:7.4.1-alpine3.10
|
||||
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
|
||||
|
||||
ARG SHLINK_VERSION=1.20.2
|
||||
|
|
|
@ -29,7 +29,7 @@ A PHP-based self-hosted URL shortener that can be used to serve shortened URLs u
|
|||
|
||||
First, make sure the host where you are going to run shlink fulfills these requirements:
|
||||
|
||||
* PHP 7.2 or greater with JSON, APCu, intl, curl, PDO and gd extensions enabled.
|
||||
* PHP 7.4 or greater with JSON, APCu, intl, curl, PDO and gd extensions enabled.
|
||||
* MySQL, MariaDB, PostgreSQL or SQLite.
|
||||
* The web server of your choice with PHP integration (Apache or Nginx recommended).
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2",
|
||||
"php": "^7.4",
|
||||
"ext-json": "*",
|
||||
"ext-pdo": "*",
|
||||
"akrabat/ip-address-middleware": "^1.0",
|
||||
|
@ -30,7 +30,7 @@
|
|||
"mikehaertl/phpwkhtmltopdf": "^2.2",
|
||||
"monolog/monolog": "^2.0",
|
||||
"nikolaposa/monolog-factory": "^3.0",
|
||||
"ocramius/proxy-manager": "~2.2.2",
|
||||
"ocramius/proxy-manager": "^2.5.1",
|
||||
"phly/phly-event-dispatcher": "^1.0",
|
||||
"predis/predis": "^1.1",
|
||||
"pugx/shortid-php": "^0.5",
|
||||
|
@ -60,7 +60,7 @@
|
|||
"devster/ubench": "^2.0",
|
||||
"eaglewu/swoole-ide-helper": "dev-master",
|
||||
"infection/infection": "^0.15.0",
|
||||
"phpstan/phpstan-shim": "^0.11.16",
|
||||
"phpstan/phpstan": "^0.12.3",
|
||||
"phpunit/phpunit": "^8.3",
|
||||
"roave/security-advisories": "dev-master",
|
||||
"shlinkio/php-coding-standard": "~2.0.0",
|
||||
|
|
|
@ -15,6 +15,4 @@ $em = $container->get(EntityManager::class);
|
|||
|
||||
$testHelper->createTestDb();
|
||||
ApiTest\ApiTestCase::setApiClient($container->get('shlink_test_api_client'));
|
||||
ApiTest\ApiTestCase::setSeedFixturesCallback(function () use ($testHelper, $em, $config) {
|
||||
$testHelper->seedFixtures($em, $config['data_fixtures'] ?? []);
|
||||
});
|
||||
ApiTest\ApiTestCase::setSeedFixturesCallback(fn () => $testHelper->seedFixtures($em, $config['data_fixtures'] ?? []));
|
||||
|
|
|
@ -19,9 +19,7 @@ $swooleTestingPort = 9999;
|
|||
$buildDbConnection = function (): array {
|
||||
$driver = env('DB_DRIVER', 'sqlite');
|
||||
$isCi = env('TRAVIS', false);
|
||||
$getMysqlHost = function (string $driver) {
|
||||
return sprintf('shlink_db%s', $driver === 'mysql' ? '' : '_maria');
|
||||
};
|
||||
$getMysqlHost = fn (string $driver) => sprintf('shlink_db%s', $driver === 'mysql' ? '' : '_maria');
|
||||
|
||||
$driverConfigMap = [
|
||||
'sqlite' => [
|
||||
|
|
|
@ -11,7 +11,7 @@ server {
|
|||
|
||||
location ~ \.php$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
|
||||
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi.conf;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
FROM php:7.3.11-fpm-alpine3.10
|
||||
FROM php:7.4.1-fpm-alpine3.10
|
||||
MAINTAINER Alejandro Celaya <alejandro@alejandrocelaya.com>
|
||||
|
||||
ENV APCU_VERSION 5.1.18
|
||||
ENV APCU_BC_VERSION 1.0.5
|
||||
ENV XDEBUG_VERSION 2.8.0
|
||||
ENV XDEBUG_VERSION 2.9.0
|
||||
|
||||
RUN apk update
|
||||
|
||||
# Install common php extensions
|
||||
RUN docker-php-ext-install pdo_mysql
|
||||
RUN docker-php-ext-install iconv
|
||||
RUN docker-php-ext-install mbstring
|
||||
RUN docker-php-ext-install calendar
|
||||
|
||||
RUN apk add --no-cache oniguruma-dev
|
||||
RUN docker-php-ext-install mbstring
|
||||
|
||||
RUN apk add --no-cache sqlite-libs
|
||||
RUN apk add --no-cache sqlite-dev
|
||||
RUN docker-php-ext-install pdo_sqlite
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM php:7.3.11-alpine3.10
|
||||
FROM php:7.4.1-alpine3.10
|
||||
MAINTAINER Alejandro Celaya <alejandro@alejandrocelaya.com>
|
||||
|
||||
ENV APCU_VERSION 5.1.18
|
||||
|
@ -11,9 +11,11 @@ RUN apk update
|
|||
# Install common php extensions
|
||||
RUN docker-php-ext-install pdo_mysql
|
||||
RUN docker-php-ext-install iconv
|
||||
RUN docker-php-ext-install mbstring
|
||||
RUN docker-php-ext-install calendar
|
||||
|
||||
RUN apk add --no-cache oniguruma-dev
|
||||
RUN docker-php-ext-install mbstring
|
||||
|
||||
RUN apk add --no-cache sqlite-libs
|
||||
RUN apk add --no-cache sqlite-dev
|
||||
RUN docker-php-ext-install pdo_sqlite
|
||||
|
|
|
@ -19,8 +19,7 @@ class DisableKeyCommand extends Command
|
|||
{
|
||||
public const NAME = 'api-key:disable';
|
||||
|
||||
/** @var ApiKeyServiceInterface */
|
||||
private $apiKeyService;
|
||||
private ApiKeyServiceInterface $apiKeyService;
|
||||
|
||||
public function __construct(ApiKeyServiceInterface $apiKeyService)
|
||||
{
|
||||
|
|
|
@ -19,8 +19,7 @@ class GenerateKeyCommand extends Command
|
|||
{
|
||||
public const NAME = 'api-key:generate';
|
||||
|
||||
/** @var ApiKeyServiceInterface */
|
||||
private $apiKeyService;
|
||||
private ApiKeyServiceInterface $apiKeyService;
|
||||
|
||||
public function __construct(ApiKeyServiceInterface $apiKeyService)
|
||||
{
|
||||
|
|
|
@ -25,8 +25,7 @@ class ListKeysCommand extends Command
|
|||
|
||||
public const NAME = 'api-key:list';
|
||||
|
||||
/** @var ApiKeyServiceInterface */
|
||||
private $apiKeyService;
|
||||
private ApiKeyServiceInterface $apiKeyService;
|
||||
|
||||
public function __construct(ApiKeyServiceInterface $apiKeyService)
|
||||
{
|
||||
|
|
|
@ -15,10 +15,8 @@ use function array_unshift;
|
|||
|
||||
abstract class AbstractDatabaseCommand extends AbstractLockedCommand
|
||||
{
|
||||
/** @var ProcessHelper */
|
||||
private $processHelper;
|
||||
/** @var string */
|
||||
private $phpBinary;
|
||||
private ProcessHelper $processHelper;
|
||||
private string $phpBinary;
|
||||
|
||||
public function __construct(LockFactory $locker, ProcessHelper $processHelper, PhpExecutableFinder $phpFinder)
|
||||
{
|
||||
|
|
|
@ -21,10 +21,8 @@ class CreateDatabaseCommand extends AbstractDatabaseCommand
|
|||
public const DOCTRINE_SCRIPT = 'vendor/doctrine/orm/bin/doctrine.php';
|
||||
public const DOCTRINE_CREATE_SCHEMA_COMMAND = 'orm:schema-tool:create';
|
||||
|
||||
/** @var Connection */
|
||||
private $regularConn;
|
||||
/** @var Connection */
|
||||
private $noDbNameConn;
|
||||
private Connection $regularConn;
|
||||
private Connection $noDbNameConn;
|
||||
|
||||
public function __construct(
|
||||
LockFactory $locker,
|
||||
|
|
|
@ -21,8 +21,7 @@ class DeleteShortUrlCommand extends Command
|
|||
public const NAME = 'short-url:delete';
|
||||
private const ALIASES = ['short-code:delete'];
|
||||
|
||||
/** @var DeleteShortUrlServiceInterface */
|
||||
private $deleteShortUrlService;
|
||||
private DeleteShortUrlServiceInterface $deleteShortUrlService;
|
||||
|
||||
public function __construct(DeleteShortUrlServiceInterface $deleteShortUrlService)
|
||||
{
|
||||
|
|
|
@ -28,10 +28,8 @@ class GenerateShortUrlCommand extends Command
|
|||
public const NAME = 'short-url:generate';
|
||||
private const ALIASES = ['shortcode:generate', 'short-code:generate'];
|
||||
|
||||
/** @var UrlShortenerInterface */
|
||||
private $urlShortener;
|
||||
/** @var array */
|
||||
private $domainConfig;
|
||||
private UrlShortenerInterface $urlShortener;
|
||||
private array $domainConfig;
|
||||
|
||||
public function __construct(UrlShortenerInterface $urlShortener, array $domainConfig)
|
||||
{
|
||||
|
|
|
@ -24,8 +24,7 @@ class GetVisitsCommand extends AbstractWithDateRangeCommand
|
|||
public const NAME = 'short-url:visits';
|
||||
private const ALIASES = ['shortcode:visits', 'short-code:visits'];
|
||||
|
||||
/** @var VisitsTrackerInterface */
|
||||
private $visitsTracker;
|
||||
private VisitsTrackerInterface $visitsTracker;
|
||||
|
||||
public function __construct(VisitsTrackerInterface $visitsTracker)
|
||||
{
|
||||
|
|
|
@ -42,10 +42,8 @@ class ListShortUrlsCommand extends AbstractWithDateRangeCommand
|
|||
'tags',
|
||||
];
|
||||
|
||||
/** @var ShortUrlServiceInterface */
|
||||
private $shortUrlService;
|
||||
/** @var ShortUrlDataTransformer */
|
||||
private $transformer;
|
||||
private ShortUrlServiceInterface $shortUrlService;
|
||||
private ShortUrlDataTransformer $transformer;
|
||||
|
||||
public function __construct(ShortUrlServiceInterface $shortUrlService, array $domainConfig)
|
||||
{
|
||||
|
|
|
@ -21,8 +21,7 @@ class ResolveUrlCommand extends Command
|
|||
public const NAME = 'short-url:parse';
|
||||
private const ALIASES = ['shortcode:parse', 'short-code:parse'];
|
||||
|
||||
/** @var UrlShortenerInterface */
|
||||
private $urlShortener;
|
||||
private UrlShortenerInterface $urlShortener;
|
||||
|
||||
public function __construct(UrlShortenerInterface $urlShortener)
|
||||
{
|
||||
|
|
|
@ -16,8 +16,7 @@ class CreateTagCommand extends Command
|
|||
{
|
||||
public const NAME = 'tag:create';
|
||||
|
||||
/** @var TagServiceInterface */
|
||||
private $tagService;
|
||||
private TagServiceInterface $tagService;
|
||||
|
||||
public function __construct(TagServiceInterface $tagService)
|
||||
{
|
||||
|
|
|
@ -16,8 +16,7 @@ class DeleteTagsCommand extends Command
|
|||
{
|
||||
public const NAME = 'tag:delete';
|
||||
|
||||
/** @var TagServiceInterface */
|
||||
private $tagService;
|
||||
private TagServiceInterface $tagService;
|
||||
|
||||
public function __construct(TagServiceInterface $tagService)
|
||||
{
|
||||
|
|
|
@ -18,8 +18,7 @@ class ListTagsCommand extends Command
|
|||
{
|
||||
public const NAME = 'tag:list';
|
||||
|
||||
/** @var TagServiceInterface */
|
||||
private $tagService;
|
||||
private TagServiceInterface $tagService;
|
||||
|
||||
public function __construct(TagServiceInterface $tagService)
|
||||
{
|
||||
|
@ -47,8 +46,6 @@ class ListTagsCommand extends Command
|
|||
return [['No tags yet']];
|
||||
}
|
||||
|
||||
return map($tags, function (Tag $tag) {
|
||||
return [(string) $tag];
|
||||
});
|
||||
return map($tags, fn (Tag $tag) => [(string) $tag]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,7 @@ class RenameTagCommand extends Command
|
|||
{
|
||||
public const NAME = 'tag:rename';
|
||||
|
||||
/** @var TagServiceInterface */
|
||||
private $tagService;
|
||||
private TagServiceInterface $tagService;
|
||||
|
||||
public function __construct(TagServiceInterface $tagService)
|
||||
{
|
||||
|
|
|
@ -14,8 +14,7 @@ use function sprintf;
|
|||
|
||||
abstract class AbstractLockedCommand extends Command
|
||||
{
|
||||
/** @var LockFactory */
|
||||
private $locker;
|
||||
private LockFactory $locker;
|
||||
|
||||
public function __construct(LockFactory $locker)
|
||||
{
|
||||
|
|
|
@ -8,12 +8,9 @@ final class LockedCommandConfig
|
|||
{
|
||||
private const DEFAULT_TTL = 90.0; // 1.5 minutes
|
||||
|
||||
/** @var string */
|
||||
private $lockName;
|
||||
/** @var bool */
|
||||
private $isBlocking;
|
||||
/** @var float */
|
||||
private $ttl;
|
||||
private string $lockName;
|
||||
private bool $isBlocking;
|
||||
private float $ttl;
|
||||
|
||||
public function __construct(string $lockName, bool $isBlocking = false, float $ttl = self::DEFAULT_TTL)
|
||||
{
|
||||
|
|
|
@ -32,17 +32,12 @@ class LocateVisitsCommand extends AbstractLockedCommand
|
|||
public const NAME = 'visit:locate';
|
||||
public const ALIASES = ['visit:process'];
|
||||
|
||||
/** @var VisitServiceInterface */
|
||||
private $visitService;
|
||||
/** @var IpLocationResolverInterface */
|
||||
private $ipLocationResolver;
|
||||
/** @var GeolocationDbUpdaterInterface */
|
||||
private $dbUpdater;
|
||||
private VisitServiceInterface $visitService;
|
||||
private IpLocationResolverInterface $ipLocationResolver;
|
||||
private GeolocationDbUpdaterInterface $dbUpdater;
|
||||
|
||||
/** @var SymfonyStyle */
|
||||
private $io;
|
||||
/** @var ProgressBar */
|
||||
private $progressBar;
|
||||
private SymfonyStyle $io;
|
||||
private ?ProgressBar $progressBar = null;
|
||||
|
||||
public function __construct(
|
||||
VisitServiceInterface $visitService,
|
||||
|
|
|
@ -9,8 +9,7 @@ use Throwable;
|
|||
|
||||
class GeolocationDbUpdateFailedException extends RuntimeException implements ExceptionInterface
|
||||
{
|
||||
/** @var bool */
|
||||
private $olderDbExists;
|
||||
private bool $olderDbExists;
|
||||
|
||||
public static function create(bool $olderDbExists, ?Throwable $prev = null): self
|
||||
{
|
||||
|
|
|
@ -15,12 +15,9 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
|
|||
{
|
||||
private const LOCK_NAME = 'geolocation-db-update';
|
||||
|
||||
/** @var DbUpdaterInterface */
|
||||
private $dbUpdater;
|
||||
/** @var Reader */
|
||||
private $geoLiteDbReader;
|
||||
/** @var LockFactory */
|
||||
private $locker;
|
||||
private DbUpdaterInterface $dbUpdater;
|
||||
private Reader $geoLiteDbReader;
|
||||
private LockFactory $locker;
|
||||
|
||||
public function __construct(DbUpdaterInterface $dbUpdater, Reader $geoLiteDbReader, LockFactory $locker)
|
||||
{
|
||||
|
|
|
@ -12,8 +12,7 @@ final class ShlinkTable
|
|||
private const DEFAULT_STYLE_NAME = 'default';
|
||||
private const TABLE_TITLE_STYLE = '<options=bold> %s </>';
|
||||
|
||||
/** @var Table|null */
|
||||
private $baseTable;
|
||||
private ?Table $baseTable;
|
||||
|
||||
public function __construct(Table $baseTable)
|
||||
{
|
||||
|
|
|
@ -8,20 +8,18 @@ use PHPUnit\Framework\TestCase;
|
|||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\CLI\Command\Api\DisableKeyCommand;
|
||||
use Shlinkio\Shlink\Common\Exception\InvalidArgumentException;
|
||||
use Shlinkio\Shlink\Rest\Service\ApiKeyService;
|
||||
use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class DisableKeyCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $apiKeyService;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $apiKeyService;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->apiKeyService = $this->prophesize(ApiKeyService::class);
|
||||
$this->apiKeyService = $this->prophesize(ApiKeyServiceInterface::class);
|
||||
$command = new DisableKeyCommand($this->apiKeyService->reveal());
|
||||
$app = new Application();
|
||||
$app->add($command);
|
||||
|
|
|
@ -10,20 +10,18 @@ use Prophecy\Argument;
|
|||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\CLI\Command\Api\GenerateKeyCommand;
|
||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
use Shlinkio\Shlink\Rest\Service\ApiKeyService;
|
||||
use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class GenerateKeyCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $apiKeyService;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $apiKeyService;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->apiKeyService = $this->prophesize(ApiKeyService::class);
|
||||
$this->apiKeyService = $this->prophesize(ApiKeyServiceInterface::class);
|
||||
$command = new GenerateKeyCommand($this->apiKeyService->reveal());
|
||||
$app = new Application();
|
||||
$app->add($command);
|
||||
|
|
|
@ -8,20 +8,18 @@ use PHPUnit\Framework\TestCase;
|
|||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\CLI\Command\Api\ListKeysCommand;
|
||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
use Shlinkio\Shlink\Rest\Service\ApiKeyService;
|
||||
use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class ListKeysCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $apiKeyService;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $apiKeyService;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->apiKeyService = $this->prophesize(ApiKeyService::class);
|
||||
$this->apiKeyService = $this->prophesize(ApiKeyServiceInterface::class);
|
||||
$command = new ListKeysCommand($this->apiKeyService->reveal());
|
||||
$app = new Application();
|
||||
$app->add($command);
|
||||
|
|
|
@ -15,8 +15,7 @@ use function str_split;
|
|||
|
||||
class GenerateCharsetCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
private CommandTester $commandTester;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -21,18 +21,12 @@ use Symfony\Component\Process\PhpExecutableFinder;
|
|||
|
||||
class CreateDatabaseCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $processHelper;
|
||||
/** @var ObjectProphecy */
|
||||
private $regularConn;
|
||||
/** @var ObjectProphecy */
|
||||
private $noDbNameConn;
|
||||
/** @var ObjectProphecy */
|
||||
private $schemaManager;
|
||||
/** @var ObjectProphecy */
|
||||
private $databasePlatform;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $processHelper;
|
||||
private ObjectProphecy $regularConn;
|
||||
private ObjectProphecy $noDbNameConn;
|
||||
private ObjectProphecy $schemaManager;
|
||||
private ObjectProphecy $databasePlatform;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -18,10 +18,8 @@ use Symfony\Component\Process\PhpExecutableFinder;
|
|||
|
||||
class MigrateDatabaseCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $processHelper;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $processHelper;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -20,10 +20,8 @@ use const PHP_EOL;
|
|||
|
||||
class DeleteShortUrlCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $service;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $service;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -22,12 +22,9 @@ use function substr_count;
|
|||
|
||||
class GeneratePreviewCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $previewGenerator;
|
||||
/** @var ObjectProphecy */
|
||||
private $shortUrlService;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $previewGenerator;
|
||||
private ObjectProphecy $shortUrlService;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -25,10 +25,8 @@ class GenerateShortUrlCommandTest extends TestCase
|
|||
'hostname' => 'foo.com',
|
||||
];
|
||||
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $urlShortener;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $urlShortener;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -26,10 +26,8 @@ use function sprintf;
|
|||
|
||||
class GetVisitsCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $visitsTracker;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $visitsTracker;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -21,10 +21,8 @@ use function explode;
|
|||
|
||||
class ListShortUrlsCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $shortUrlService;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $shortUrlService;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
@ -44,9 +42,9 @@ class ListShortUrlsCommandTest extends TestCase
|
|||
$data[] = new ShortUrl('url_' . $i);
|
||||
}
|
||||
|
||||
$this->shortUrlService->listShortUrls(Argument::cetera())->will(function () use (&$data) {
|
||||
return new Paginator(new ArrayAdapter($data));
|
||||
})->shouldBeCalledTimes(3);
|
||||
$this->shortUrlService->listShortUrls(Argument::cetera())
|
||||
->will(fn () => new Paginator(new ArrayAdapter($data)))
|
||||
->shouldBeCalledTimes(3);
|
||||
|
||||
$this->commandTester->setInputs(['y', 'y', 'n']);
|
||||
$this->commandTester->execute([]);
|
||||
|
|
|
@ -19,10 +19,8 @@ use const PHP_EOL;
|
|||
|
||||
class ResolveUrlCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $urlShortener;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $urlShortener;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -14,10 +14,8 @@ use Symfony\Component\Console\Tester\CommandTester;
|
|||
|
||||
class CreateTagCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $tagService;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $tagService;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
@ -31,7 +29,7 @@ class CreateTagCommandTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function errorIsReturnedWhenNoTagsAreProvided()
|
||||
public function errorIsReturnedWhenNoTagsAreProvided(): void
|
||||
{
|
||||
$this->commandTester->execute([]);
|
||||
|
||||
|
@ -40,7 +38,7 @@ class CreateTagCommandTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function serviceIsInvokedOnSuccess()
|
||||
public function serviceIsInvokedOnSuccess(): void
|
||||
{
|
||||
$tagNames = ['foo', 'bar'];
|
||||
$createTags = $this->tagService->createTags($tagNames)->willReturn(new ArrayCollection());
|
||||
|
|
|
@ -13,12 +13,8 @@ use Symfony\Component\Console\Tester\CommandTester;
|
|||
|
||||
class DeleteTagsCommandTest extends TestCase
|
||||
{
|
||||
/** @var DeleteTagsCommand */
|
||||
private $command;
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $tagService;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $tagService;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
@ -32,7 +28,7 @@ class DeleteTagsCommandTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function errorIsReturnedWhenNoTagsAreProvided()
|
||||
public function errorIsReturnedWhenNoTagsAreProvided(): void
|
||||
{
|
||||
$this->commandTester->execute([]);
|
||||
|
||||
|
@ -41,7 +37,7 @@ class DeleteTagsCommandTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function serviceIsInvokedOnSuccess()
|
||||
public function serviceIsInvokedOnSuccess(): void
|
||||
{
|
||||
$tagNames = ['foo', 'bar'];
|
||||
$deleteTags = $this->tagService->deleteTags($tagNames)->will(function () {
|
||||
|
|
|
@ -14,12 +14,8 @@ use Symfony\Component\Console\Tester\CommandTester;
|
|||
|
||||
class ListTagsCommandTest extends TestCase
|
||||
{
|
||||
/** @var ListTagsCommand */
|
||||
private $command;
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $tagService;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $tagService;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
@ -33,7 +29,7 @@ class ListTagsCommandTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function noTagsPrintsEmptyMessage()
|
||||
public function noTagsPrintsEmptyMessage(): void
|
||||
{
|
||||
$listTags = $this->tagService->listTags()->willReturn([]);
|
||||
|
||||
|
@ -45,7 +41,7 @@ class ListTagsCommandTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function listOfTagsIsPrinted()
|
||||
public function listOfTagsIsPrinted(): void
|
||||
{
|
||||
$listTags = $this->tagService->listTags()->willReturn([
|
||||
new Tag('foo'),
|
||||
|
|
|
@ -15,12 +15,8 @@ use Symfony\Component\Console\Tester\CommandTester;
|
|||
|
||||
class RenameTagCommandTest extends TestCase
|
||||
{
|
||||
/** @var RenameTagCommand */
|
||||
private $command;
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $tagService;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $tagService;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -29,18 +29,12 @@ use function sprintf;
|
|||
|
||||
class LocateVisitsCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $visitService;
|
||||
/** @var ObjectProphecy */
|
||||
private $ipResolver;
|
||||
/** @var ObjectProphecy */
|
||||
private $locker;
|
||||
/** @var ObjectProphecy */
|
||||
private $lock;
|
||||
/** @var ObjectProphecy */
|
||||
private $dbUpdater;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $visitService;
|
||||
private ObjectProphecy $ipResolver;
|
||||
private ObjectProphecy $locker;
|
||||
private ObjectProphecy $lock;
|
||||
private ObjectProphecy $dbUpdater;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -16,10 +16,8 @@ use Symfony\Component\Console\Tester\CommandTester;
|
|||
|
||||
class UpdateDbCommandTest extends TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
/** @var ObjectProphecy */
|
||||
private $dbUpdater;
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $dbUpdater;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -9,8 +9,7 @@ use Shlinkio\Shlink\CLI\ConfigProvider;
|
|||
|
||||
class ConfigProviderTest extends TestCase
|
||||
{
|
||||
/** @var ConfigProvider */
|
||||
private $configProvider;
|
||||
private ConfigProvider $configProvider;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -15,8 +15,7 @@ use Zend\ServiceManager\ServiceManager;
|
|||
|
||||
class ApplicationFactoryTest extends TestCase
|
||||
{
|
||||
/** @var ApplicationFactory */
|
||||
private $factory;
|
||||
private ApplicationFactory $factory;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
@ -36,7 +35,6 @@ class ApplicationFactoryTest extends TestCase
|
|||
$sm->setService('foo', $this->createCommandMock('foo')->reveal());
|
||||
$sm->setService('bar', $this->createCommandMock('bar')->reveal());
|
||||
|
||||
/** @var Application $instance */
|
||||
$instance = ($this->factory)($sm);
|
||||
|
||||
$this->assertTrue($instance->has('foo'));
|
||||
|
|
|
@ -22,16 +22,11 @@ use function range;
|
|||
|
||||
class GeolocationDbUpdaterTest extends TestCase
|
||||
{
|
||||
/** @var GeolocationDbUpdater */
|
||||
private $geolocationDbUpdater;
|
||||
/** @var ObjectProphecy */
|
||||
private $dbUpdater;
|
||||
/** @var ObjectProphecy */
|
||||
private $geoLiteDbReader;
|
||||
/** @var ObjectProphecy */
|
||||
private $locker;
|
||||
/** @var ObjectProphecy */
|
||||
private $lock;
|
||||
private GeolocationDbUpdater $geolocationDbUpdater;
|
||||
private ObjectProphecy $dbUpdater;
|
||||
private ObjectProphecy $geoLiteDbReader;
|
||||
private ObjectProphecy $locker;
|
||||
private ObjectProphecy $lock;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
@ -55,9 +50,7 @@ class GeolocationDbUpdaterTest extends TestCase
|
|||
/** @test */
|
||||
public function exceptionIsThrownWhenOlderDbDoesNotExistAndDownloadFails(): void
|
||||
{
|
||||
$mustBeUpdated = function () {
|
||||
$this->assertTrue(true);
|
||||
};
|
||||
$mustBeUpdated = fn () => $this->assertTrue(true);
|
||||
$prev = new RuntimeException('');
|
||||
|
||||
$fileExists = $this->dbUpdater->databaseFileExists()->willReturn(false);
|
||||
|
@ -153,8 +146,6 @@ class GeolocationDbUpdaterTest extends TestCase
|
|||
|
||||
public function provideSmallDays(): iterable
|
||||
{
|
||||
return map(range(0, 34), function (int $days) {
|
||||
return [$days];
|
||||
});
|
||||
return map(range(0, 34), fn (int $days) => [$days]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
|
||||
class ShlinkTableTest extends TestCase
|
||||
{
|
||||
/** @var ShlinkTable */
|
||||
private $shlinkTable;
|
||||
/** @var ObjectProphecy */
|
||||
private $baseTable;
|
||||
private ShlinkTable $shlinkTable;
|
||||
private ObjectProphecy $baseTable;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -25,14 +25,10 @@ use function http_build_query;
|
|||
|
||||
abstract class AbstractTrackingAction implements MiddlewareInterface
|
||||
{
|
||||
/** @var UrlShortenerInterface */
|
||||
private $urlShortener;
|
||||
/** @var VisitsTrackerInterface */
|
||||
private $visitTracker;
|
||||
/** @var AppOptions */
|
||||
private $appOptions;
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
private UrlShortenerInterface $urlShortener;
|
||||
private VisitsTrackerInterface $visitTracker;
|
||||
private AppOptions $appOptions;
|
||||
private LoggerInterface $logger;
|
||||
|
||||
public function __construct(
|
||||
UrlShortenerInterface $urlShortener,
|
||||
|
|
|
@ -23,12 +23,9 @@ class QrCodeAction implements MiddlewareInterface
|
|||
private const MIN_SIZE = 50;
|
||||
private const MAX_SIZE = 1000;
|
||||
|
||||
/** @var RouterInterface */
|
||||
private $router;
|
||||
/** @var UrlShortenerInterface */
|
||||
private $urlShortener;
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
private RouterInterface $router;
|
||||
private UrlShortenerInterface $urlShortener;
|
||||
private LoggerInterface $logger;
|
||||
|
||||
public function __construct(
|
||||
RouterInterface $router,
|
||||
|
|
|
@ -75,9 +75,10 @@ class SimplifiedConfigParser
|
|||
// This mainly allows deprecating keys and defining new ones that will replace the older and always take
|
||||
// preference, while the old one keeps working for backwards compatibility if the new one is not provided.
|
||||
$simplifiedConfigOrder = array_flip(array_keys(self::SIMPLIFIED_CONFIG_MAPPING));
|
||||
uksort($configForExistingKeys, function (string $a, string $b) use ($simplifiedConfigOrder): int {
|
||||
return $simplifiedConfigOrder[$a] - $simplifiedConfigOrder[$b];
|
||||
});
|
||||
uksort(
|
||||
$configForExistingKeys,
|
||||
fn (string $a, string $b): int => $simplifiedConfigOrder[$a] - $simplifiedConfigOrder[$b]
|
||||
);
|
||||
|
||||
return $configForExistingKeys;
|
||||
}
|
||||
|
|
|
@ -9,8 +9,7 @@ use Shlinkio\Shlink\Core\Entity\Domain;
|
|||
|
||||
class PersistenceDomainResolver implements DomainResolverInterface
|
||||
{
|
||||
/** @var EntityManagerInterface */
|
||||
private $em;
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
|
|
|
@ -8,8 +8,7 @@ use Shlinkio\Shlink\Common\Entity\AbstractEntity;
|
|||
|
||||
class Domain extends AbstractEntity
|
||||
{
|
||||
/** @var string */
|
||||
private $authority;
|
||||
private string $authority;
|
||||
|
||||
public function __construct(string $authority)
|
||||
{
|
||||
|
|
|
@ -22,26 +22,18 @@ use function Shlinkio\Shlink\Core\generateRandomShortCode;
|
|||
|
||||
class ShortUrl extends AbstractEntity
|
||||
{
|
||||
/** @var string */
|
||||
private $longUrl;
|
||||
/** @var string */
|
||||
private $shortCode;
|
||||
/** @var Chronos */
|
||||
private $dateCreated;
|
||||
private string $longUrl;
|
||||
private string $shortCode;
|
||||
private Chronos $dateCreated;
|
||||
/** @var Collection|Visit[] */
|
||||
private $visits;
|
||||
private Collection $visits;
|
||||
/** @var Collection|Tag[] */
|
||||
private $tags;
|
||||
/** @var Chronos|null */
|
||||
private $validSince;
|
||||
/** @var Chronos|null */
|
||||
private $validUntil;
|
||||
/** @var integer|null */
|
||||
private $maxVisits;
|
||||
/** @var Domain|null */
|
||||
private $domain;
|
||||
/** @var bool */
|
||||
private $customSlugWasProvided;
|
||||
private Collection $tags;
|
||||
private ?Chronos $validSince;
|
||||
private ?Chronos $validUntil;
|
||||
private ?int $maxVisits;
|
||||
private ?Domain $domain;
|
||||
private bool $customSlugWasProvided;
|
||||
|
||||
public function __construct(
|
||||
string $longUrl,
|
||||
|
@ -196,9 +188,7 @@ class ShortUrl extends AbstractEntity
|
|||
$shortUrlTags = invoke($this->getTags(), '__toString');
|
||||
$hasAllTags = count($shortUrlTags) === count($tags) && array_reduce(
|
||||
$tags,
|
||||
function (bool $hasAllTags, string $tag) use ($shortUrlTags) {
|
||||
return $hasAllTags && contains($shortUrlTags, $tag);
|
||||
},
|
||||
fn (bool $hasAllTags, string $tag) => $hasAllTags && contains($shortUrlTags, $tag),
|
||||
true
|
||||
);
|
||||
|
||||
|
|
|
@ -9,8 +9,7 @@ use Shlinkio\Shlink\Common\Entity\AbstractEntity;
|
|||
|
||||
class Tag extends AbstractEntity implements JsonSerializable
|
||||
{
|
||||
/** @var string */
|
||||
private $name;
|
||||
private string $name;
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
|
|
|
@ -15,18 +15,12 @@ use Shlinkio\Shlink\Core\Visit\Model\VisitLocationInterface;
|
|||
|
||||
class Visit extends AbstractEntity implements JsonSerializable
|
||||
{
|
||||
/** @var string */
|
||||
private $referer;
|
||||
/** @var Chronos */
|
||||
private $date;
|
||||
/** @var string|null */
|
||||
private $remoteAddr;
|
||||
/** @var string */
|
||||
private $userAgent;
|
||||
/** @var ShortUrl */
|
||||
private $shortUrl;
|
||||
/** @var VisitLocation */
|
||||
private $visitLocation;
|
||||
private string $referer;
|
||||
private Chronos $date;
|
||||
private ?string $remoteAddr;
|
||||
private string $userAgent;
|
||||
private ShortUrl $shortUrl;
|
||||
private ?VisitLocation $visitLocation = null;
|
||||
|
||||
public function __construct(ShortUrl $shortUrl, Visitor $visitor, ?Chronos $date = null)
|
||||
{
|
||||
|
@ -93,7 +87,7 @@ class Visit extends AbstractEntity implements JsonSerializable
|
|||
{
|
||||
return [
|
||||
'referer' => $this->referer,
|
||||
'date' => $this->date !== null ? $this->date->toAtomString() : null,
|
||||
'date' => $this->date->toAtomString(),
|
||||
'userAgent' => $this->userAgent,
|
||||
'visitLocation' => $this->visitLocation,
|
||||
|
||||
|
|
|
@ -10,20 +10,13 @@ use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
|||
|
||||
class VisitLocation extends AbstractEntity implements VisitLocationInterface
|
||||
{
|
||||
/** @var string */
|
||||
private $countryCode;
|
||||
/** @var string */
|
||||
private $countryName;
|
||||
/** @var string */
|
||||
private $regionName;
|
||||
/** @var string */
|
||||
private $cityName;
|
||||
/** @var string */
|
||||
private $latitude;
|
||||
/** @var string */
|
||||
private $longitude;
|
||||
/** @var string */
|
||||
private $timezone;
|
||||
private string $countryCode;
|
||||
private string $countryName;
|
||||
private string $regionName;
|
||||
private string $cityName;
|
||||
private string $latitude; // FIXME Should be float
|
||||
private string $longitude; // FIXME Should be float
|
||||
private string $timezone;
|
||||
|
||||
public function __construct(Location $location)
|
||||
{
|
||||
|
|
|
@ -18,10 +18,8 @@ use function rtrim;
|
|||
|
||||
class NotFoundRedirectHandler implements MiddlewareInterface
|
||||
{
|
||||
/** @var NotFoundRedirectOptions */
|
||||
private $redirectOptions;
|
||||
/** @var string */
|
||||
private $shlinkBasePath;
|
||||
private NotFoundRedirectOptions $redirectOptions;
|
||||
private string $shlinkBasePath;
|
||||
|
||||
public function __construct(NotFoundRedirectOptions $redirectOptions, string $shlinkBasePath)
|
||||
{
|
||||
|
|
|
@ -18,8 +18,7 @@ class NotFoundTemplateHandler implements RequestHandlerInterface
|
|||
public const NOT_FOUND_TEMPLATE = 'ShlinkCore::error/404';
|
||||
public const INVALID_SHORT_CODE_TEMPLATE = 'ShlinkCore::invalid-short-code';
|
||||
|
||||
/** @var TemplateRendererInterface */
|
||||
private $renderer;
|
||||
private TemplateRendererInterface $renderer;
|
||||
|
||||
public function __construct(TemplateRendererInterface $renderer)
|
||||
{
|
||||
|
|
|
@ -19,16 +19,11 @@ use function sprintf;
|
|||
|
||||
class LocateShortUrlVisit
|
||||
{
|
||||
/** @var IpLocationResolverInterface */
|
||||
private $ipLocationResolver;
|
||||
/** @var EntityManagerInterface */
|
||||
private $em;
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
/** @var GeolocationDbUpdaterInterface */
|
||||
private $dbUpdater;
|
||||
/** @var EventDispatcherInterface */
|
||||
private $eventDispatcher;
|
||||
private IpLocationResolverInterface $ipLocationResolver;
|
||||
private EntityManagerInterface $em;
|
||||
private LoggerInterface $logger;
|
||||
private GeolocationDbUpdaterInterface $dbUpdater;
|
||||
private EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
public function __construct(
|
||||
IpLocationResolverInterface $ipLocationResolver,
|
||||
|
|
|
@ -22,18 +22,13 @@ use function GuzzleHttp\Promise\settle;
|
|||
|
||||
class NotifyVisitToWebHooks
|
||||
{
|
||||
/** @var ClientInterface */
|
||||
private $httpClient;
|
||||
/** @var EntityManagerInterface */
|
||||
private $em;
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
/** @var array */
|
||||
private $webhooks;
|
||||
/** @var ShortUrlDataTransformer */
|
||||
private $transformer;
|
||||
/** @var AppOptions */
|
||||
private $appOptions;
|
||||
private ClientInterface $httpClient;
|
||||
private EntityManagerInterface $em;
|
||||
private LoggerInterface $logger;
|
||||
/** @var string[] */
|
||||
private array $webhooks;
|
||||
private ShortUrlDataTransformer $transformer;
|
||||
private AppOptions $appOptions;
|
||||
|
||||
public function __construct(
|
||||
ClientInterface $httpClient,
|
||||
|
|
|
@ -8,8 +8,7 @@ use JsonSerializable;
|
|||
|
||||
final class ShortUrlVisited implements JsonSerializable
|
||||
{
|
||||
/** @var string */
|
||||
private $visitId;
|
||||
private string $visitId;
|
||||
|
||||
public function __construct(string $visitId)
|
||||
{
|
||||
|
|
|
@ -8,8 +8,7 @@ use JsonSerializable;
|
|||
|
||||
final class VisitLocated implements JsonSerializable
|
||||
{
|
||||
/** @var string */
|
||||
private $visitId;
|
||||
private string $visitId;
|
||||
|
||||
public function __construct(string $visitId)
|
||||
{
|
||||
|
|
|
@ -8,32 +8,24 @@ use Throwable;
|
|||
|
||||
class IpCannotBeLocatedException extends RuntimeException
|
||||
{
|
||||
/** @var bool */
|
||||
private $isNonLocatableAddress;
|
||||
|
||||
public function __construct(
|
||||
bool $isNonLocatableAddress,
|
||||
string $message,
|
||||
int $code = 0,
|
||||
?Throwable $previous = null
|
||||
) {
|
||||
$this->isNonLocatableAddress = $isNonLocatableAddress;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
private bool $isNonLocatableAddress = true;
|
||||
|
||||
public static function forEmptyAddress(): self
|
||||
{
|
||||
return new self(true, 'Ignored visit with no IP address');
|
||||
return new self('Ignored visit with no IP address');
|
||||
}
|
||||
|
||||
public static function forLocalhost(): self
|
||||
{
|
||||
return new self(true, 'Ignored localhost address');
|
||||
return new self('Ignored localhost address');
|
||||
}
|
||||
|
||||
public static function forError(Throwable $e): self
|
||||
{
|
||||
return new self(false, 'An error occurred while locating IP', $e->getCode(), $e);
|
||||
$e = new self('An error occurred while locating IP', $e->getCode(), $e);
|
||||
$e->isNonLocatableAddress = false;
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,8 +25,7 @@ class ValidationException extends InvalidArgumentException implements ProblemDet
|
|||
private const TITLE = 'Invalid data';
|
||||
private const TYPE = 'INVALID_ARGUMENT';
|
||||
|
||||
/** @var array */
|
||||
private $invalidElements;
|
||||
private array $invalidElements;
|
||||
|
||||
public static function fromInputFilter(InputFilterInterface $inputFilter, ?Throwable $prev = null): self
|
||||
{
|
||||
|
@ -70,12 +69,10 @@ class ValidationException extends InvalidArgumentException implements ProblemDet
|
|||
|
||||
private function invalidElementsToString(): string
|
||||
{
|
||||
return reduce_left($this->getInvalidElements(), function ($messageSet, string $name, $_, string $acc) {
|
||||
return $acc . sprintf(
|
||||
"\n '%s' => %s",
|
||||
$name,
|
||||
is_array($messageSet) ? print_r($messageSet, true) : $messageSet
|
||||
);
|
||||
}, '');
|
||||
return reduce_left($this->getInvalidElements(), fn ($messages, string $name, $_, string $acc) => $acc . sprintf(
|
||||
"\n '%s' => %s",
|
||||
$name,
|
||||
is_array($messages) ? print_r($messages, true) : $messages
|
||||
), '');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@ use Zend\Diactoros\Response as DiactResp;
|
|||
|
||||
class QrCodeCacheMiddleware implements MiddlewareInterface
|
||||
{
|
||||
/** @var Cache */
|
||||
private $cache;
|
||||
private Cache $cache;
|
||||
|
||||
public function __construct(Cache $cache)
|
||||
{
|
||||
|
|
|
@ -8,12 +8,9 @@ use Psr\Http\Message\UriInterface;
|
|||
|
||||
final class CreateShortUrlData
|
||||
{
|
||||
/** @var UriInterface */
|
||||
private $longUrl;
|
||||
/** @var array */
|
||||
private $tags;
|
||||
/** @var ShortUrlMeta */
|
||||
private $meta;
|
||||
private UriInterface $longUrl;
|
||||
private array $tags;
|
||||
private ShortUrlMeta $meta;
|
||||
|
||||
public function __construct(
|
||||
UriInterface $longUrl,
|
||||
|
|
|
@ -11,18 +11,12 @@ use Shlinkio\Shlink\Core\Validation\ShortUrlMetaInputFilter;
|
|||
|
||||
final class ShortUrlMeta
|
||||
{
|
||||
/** @var Chronos|null */
|
||||
private $validSince;
|
||||
/** @var Chronos|null */
|
||||
private $validUntil;
|
||||
/** @var string|null */
|
||||
private $customSlug;
|
||||
/** @var int|null */
|
||||
private $maxVisits;
|
||||
/** @var bool|null */
|
||||
private $findIfExists;
|
||||
/** @var string|null */
|
||||
private $domain;
|
||||
private ?Chronos $validSince = null;
|
||||
private ?Chronos $validUntil = null;
|
||||
private ?string $customSlug = null;
|
||||
private ?int $maxVisits = null;
|
||||
private ?bool $findIfExists = null;
|
||||
private ?string $domain = null;
|
||||
|
||||
// Force named constructors
|
||||
private function __construct()
|
||||
|
@ -90,8 +84,8 @@ final class ShortUrlMeta
|
|||
$this->validSince = $this->parseDateField($inputFilter->getValue(ShortUrlMetaInputFilter::VALID_SINCE));
|
||||
$this->validUntil = $this->parseDateField($inputFilter->getValue(ShortUrlMetaInputFilter::VALID_UNTIL));
|
||||
$this->customSlug = $inputFilter->getValue(ShortUrlMetaInputFilter::CUSTOM_SLUG);
|
||||
$this->maxVisits = $inputFilter->getValue(ShortUrlMetaInputFilter::MAX_VISITS);
|
||||
$this->maxVisits = $this->maxVisits !== null ? (int) $this->maxVisits : null;
|
||||
$maxVisits = $inputFilter->getValue(ShortUrlMetaInputFilter::MAX_VISITS);
|
||||
$this->maxVisits = $maxVisits !== null ? (int) $maxVisits : null;
|
||||
$this->findIfExists = $inputFilter->getValue(ShortUrlMetaInputFilter::FIND_IF_EXISTS);
|
||||
$this->domain = $inputFilter->getValue(ShortUrlMetaInputFilter::DOMAIN);
|
||||
}
|
||||
|
|
|
@ -15,12 +15,9 @@ final class Visitor
|
|||
public const REFERER_MAX_LENGTH = 1024;
|
||||
public const REMOTE_ADDRESS_MAX_LENGTH = 256;
|
||||
|
||||
/** @var string */
|
||||
private $userAgent;
|
||||
/** @var string */
|
||||
private $referer;
|
||||
/** @var string|null */
|
||||
private $remoteAddress;
|
||||
private string $userAgent;
|
||||
private string $referer;
|
||||
private ?string $remoteAddress;
|
||||
|
||||
public function __construct(string $userAgent, string $referer, ?string $remoteAddress)
|
||||
{
|
||||
|
|
|
@ -12,12 +12,9 @@ final class VisitsParams
|
|||
private const FIRST_PAGE = 1;
|
||||
private const ALL_ITEMS = -1;
|
||||
|
||||
/** @var null|DateRange */
|
||||
private $dateRange;
|
||||
/** @var int */
|
||||
private $page;
|
||||
/** @var int */
|
||||
private $itemsPerPage;
|
||||
private ?DateRange $dateRange;
|
||||
private int $page;
|
||||
private int $itemsPerPage;
|
||||
|
||||
public function __construct(?DateRange $dateRange = null, int $page = self::FIRST_PAGE, ?int $itemsPerPage = null)
|
||||
{
|
||||
|
|
|
@ -13,17 +13,11 @@ class AppOptions extends AbstractOptions
|
|||
{
|
||||
use StringUtilsTrait;
|
||||
|
||||
/** @var string */
|
||||
private $name = '';
|
||||
/** @var string */
|
||||
private $version = '1.0';
|
||||
/**
|
||||
* @var string
|
||||
* @deprecated
|
||||
*/
|
||||
private $secretKey = '';
|
||||
/** @var string|null */
|
||||
private $disableTrackParam;
|
||||
private string $name = '';
|
||||
private string $version = '1.0';
|
||||
/** @deprecated */
|
||||
private string $secretKey = '';
|
||||
private ?string $disableTrackParam = null;
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
|
|
|
@ -8,12 +8,9 @@ use Zend\Stdlib\AbstractOptions;
|
|||
|
||||
class NotFoundRedirectOptions extends AbstractOptions
|
||||
{
|
||||
/** @var string|null */
|
||||
private $invalidShortUrl;
|
||||
/** @var string|null */
|
||||
private $regular404;
|
||||
/** @var string|null */
|
||||
private $baseUrl;
|
||||
private ?string $invalidShortUrl = null;
|
||||
private ?string $regular404 = null;
|
||||
private ?string $baseUrl = null;
|
||||
|
||||
public function getInvalidShortUrlRedirect(): ?string
|
||||
{
|
||||
|
|
|
@ -15,16 +15,12 @@ class ShortUrlRepositoryAdapter implements AdapterInterface
|
|||
{
|
||||
public const ITEMS_PER_PAGE = 10;
|
||||
|
||||
/** @var ShortUrlRepositoryInterface */
|
||||
private $repository;
|
||||
/** @var null|string */
|
||||
private $searchTerm;
|
||||
private ShortUrlRepositoryInterface $repository;
|
||||
private ?string $searchTerm;
|
||||
/** @var null|array|string */
|
||||
private $orderBy;
|
||||
/** @var array */
|
||||
private $tags;
|
||||
/** @var DateRange|null */
|
||||
private $dateRange;
|
||||
private array $tags;
|
||||
private ?DateRange $dateRange;
|
||||
|
||||
public function __construct(
|
||||
ShortUrlRepositoryInterface $repository,
|
||||
|
|
|
@ -10,12 +10,9 @@ use Zend\Paginator\Adapter\AdapterInterface;
|
|||
|
||||
class VisitsPaginatorAdapter implements AdapterInterface
|
||||
{
|
||||
/** @var VisitRepositoryInterface */
|
||||
private $visitRepository;
|
||||
/** @var string */
|
||||
private $shortCode;
|
||||
/** @var VisitsParams */
|
||||
private $params;
|
||||
private VisitRepositoryInterface $visitRepository;
|
||||
private string $shortCode;
|
||||
private VisitsParams $params;
|
||||
|
||||
public function __construct(VisitRepositoryInterface $visitRepository, string $shortCode, VisitsParams $params)
|
||||
{
|
||||
|
|
|
@ -13,10 +13,8 @@ class DeleteShortUrlService implements DeleteShortUrlServiceInterface
|
|||
{
|
||||
use FindShortCodeTrait;
|
||||
|
||||
/** @var EntityManagerInterface */
|
||||
private $em;
|
||||
/** @var DeleteShortUrlsOptions */
|
||||
private $deleteShortUrlsOptions;
|
||||
private EntityManagerInterface $em;
|
||||
private DeleteShortUrlsOptions $deleteShortUrlsOptions;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, DeleteShortUrlsOptions $deleteShortUrlsOptions)
|
||||
{
|
||||
|
|
|
@ -20,8 +20,7 @@ class ShortUrlService implements ShortUrlServiceInterface
|
|||
use FindShortCodeTrait;
|
||||
use TagManagerTrait;
|
||||
|
||||
/** @var ORM\EntityManagerInterface */
|
||||
private $em;
|
||||
private ORM\EntityManagerInterface $em;
|
||||
|
||||
public function __construct(ORM\EntityManagerInterface $em)
|
||||
{
|
||||
|
|
|
@ -16,8 +16,7 @@ class TagService implements TagServiceInterface
|
|||
{
|
||||
use TagManagerTrait;
|
||||
|
||||
/** @var ORM\EntityManagerInterface */
|
||||
private $em;
|
||||
private ORM\EntityManagerInterface $em;
|
||||
|
||||
public function __construct(ORM\EntityManagerInterface $em)
|
||||
{
|
||||
|
|
|
@ -24,12 +24,9 @@ class UrlShortener implements UrlShortenerInterface
|
|||
{
|
||||
use TagManagerTrait;
|
||||
|
||||
/** @var EntityManagerInterface */
|
||||
private $em;
|
||||
/** @var UrlShortenerOptions */
|
||||
private $options;
|
||||
/** @var UrlValidatorInterface */
|
||||
private $urlValidator;
|
||||
private EntityManagerInterface $em;
|
||||
private UrlShortenerOptions $options;
|
||||
private UrlValidatorInterface $urlValidator;
|
||||
|
||||
public function __construct(
|
||||
UrlValidatorInterface $urlValidator,
|
||||
|
|
|
@ -13,8 +13,7 @@ use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
|||
|
||||
class VisitService implements VisitServiceInterface
|
||||
{
|
||||
/** @var EntityManagerInterface */
|
||||
private $em;
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
|
|
|
@ -18,10 +18,8 @@ use Zend\Paginator\Paginator;
|
|||
|
||||
class VisitsTracker implements VisitsTrackerInterface
|
||||
{
|
||||
/** @var ORM\EntityManagerInterface */
|
||||
private $em;
|
||||
/** @var EventDispatcherInterface */
|
||||
private $eventDispatcher;
|
||||
private ORM\EntityManagerInterface $em;
|
||||
private EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
public function __construct(ORM\EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher)
|
||||
{
|
||||
|
|
|
@ -12,8 +12,7 @@ use function Functional\invoke_if;
|
|||
|
||||
class ShortUrlDataTransformer implements DataTransformerInterface
|
||||
{
|
||||
/** @var array */
|
||||
private $domainConfig;
|
||||
private array $domainConfig;
|
||||
|
||||
public function __construct(array $domainConfig)
|
||||
{
|
||||
|
|
|
@ -14,8 +14,7 @@ class UrlValidator implements UrlValidatorInterface, RequestMethodInterface
|
|||
{
|
||||
private const MAX_REDIRECTS = 15;
|
||||
|
||||
/** @var ClientInterface */
|
||||
private $httpClient;
|
||||
private ClientInterface $httpClient;
|
||||
|
||||
public function __construct(ClientInterface $httpClient)
|
||||
{
|
||||
|
|
|
@ -28,8 +28,7 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
|
|||
Domain::class,
|
||||
];
|
||||
|
||||
/** @var ShortUrlRepository */
|
||||
private $repo;
|
||||
private ShortUrlRepository $repo;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -14,8 +14,7 @@ class TagRepositoryTest extends DatabaseTestCase
|
|||
Tag::class,
|
||||
];
|
||||
|
||||
/** @var TagRepository */
|
||||
private $repo;
|
||||
private TagRepository $repo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -26,8 +26,7 @@ class VisitRepositoryTest extends DatabaseTestCase
|
|||
ShortUrl::class,
|
||||
];
|
||||
|
||||
/** @var VisitRepository */
|
||||
private $repo;
|
||||
private VisitRepository $repo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@ -67,9 +66,7 @@ class VisitRepositoryTest extends DatabaseTestCase
|
|||
|
||||
public function provideBlockSize(): iterable
|
||||
{
|
||||
return map(range(1, 5), function (int $value) {
|
||||
return [$value];
|
||||
});
|
||||
return map(range(1, 5), fn (int $value) => [$value]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
|
|
@ -10,7 +10,6 @@ use Prophecy\Prophecy\ObjectProphecy;
|
|||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Shlinkio\Shlink\Common\Response\PixelResponse;
|
||||
use Shlinkio\Shlink\Core\Action\PixelAction;
|
||||
use Shlinkio\Shlink\Core\Action\RedirectAction;
|
||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\Options\AppOptions;
|
||||
use Shlinkio\Shlink\Core\Service\UrlShortener;
|
||||
|
@ -19,12 +18,9 @@ use Zend\Diactoros\ServerRequest;
|
|||
|
||||
class PixelActionTest extends TestCase
|
||||
{
|
||||
/** @var RedirectAction */
|
||||
private $action;
|
||||
/** @var ObjectProphecy */
|
||||
private $urlShortener;
|
||||
/** @var ObjectProphecy */
|
||||
private $visitTracker;
|
||||
private PixelAction $action;
|
||||
private ObjectProphecy $urlShortener;
|
||||
private ObjectProphecy $visitTracker;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ use function filesize;
|
|||
|
||||
use const FILEINFO_MIME;
|
||||
|
||||
/** @deprecated */
|
||||
class PreviewActionTest extends TestCase
|
||||
{
|
||||
/** @var PreviewAction */
|
||||
|
|
|
@ -19,10 +19,8 @@ use Zend\Expressive\Router\RouterInterface;
|
|||
|
||||
class QrCodeActionTest extends TestCase
|
||||
{
|
||||
/** @var QrCodeAction */
|
||||
private $action;
|
||||
/** @var ObjectProphecy */
|
||||
private $urlShortener;
|
||||
private QrCodeAction $action;
|
||||
private ObjectProphecy $urlShortener;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -21,12 +21,9 @@ use function array_key_exists;
|
|||
|
||||
class RedirectActionTest extends TestCase
|
||||
{
|
||||
/** @var RedirectAction */
|
||||
private $action;
|
||||
/** @var ObjectProphecy */
|
||||
private $urlShortener;
|
||||
/** @var ObjectProphecy */
|
||||
private $visitTracker;
|
||||
private RedirectAction $action;
|
||||
private ObjectProphecy $urlShortener;
|
||||
private ObjectProphecy $visitTracker;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -9,8 +9,7 @@ use Shlinkio\Shlink\Core\Config\BasePathPrefixer;
|
|||
|
||||
class BasePathPrefixerTest extends TestCase
|
||||
{
|
||||
/** @var BasePathPrefixer */
|
||||
private $prefixer;
|
||||
private BasePathPrefixer $prefixer;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -11,8 +11,7 @@ use function array_merge;
|
|||
|
||||
class DeprecatedConfigParserTest extends TestCase
|
||||
{
|
||||
/** @var DeprecatedConfigParser */
|
||||
private $postProcessor;
|
||||
private DeprecatedConfigParser $postProcessor;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -9,8 +9,7 @@ use Shlinkio\Shlink\Core\ConfigProvider;
|
|||
|
||||
class ConfigProviderTest extends TestCase
|
||||
{
|
||||
/** @var ConfigProvider */
|
||||
private $configProvider;
|
||||
private ConfigProvider $configProvider;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -13,10 +13,8 @@ use Shlinkio\Shlink\Core\Entity\Domain;
|
|||
|
||||
class PersistenceDomainResolverTest extends TestCase
|
||||
{
|
||||
/** @var PersistenceDomainResolver */
|
||||
private $domainResolver;
|
||||
/** @var ObjectProphecy */
|
||||
private $em;
|
||||
private PersistenceDomainResolver $domainResolver;
|
||||
private ObjectProphecy $em;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -10,8 +10,7 @@ use Shlinkio\Shlink\Core\Entity\Domain;
|
|||
|
||||
class SimpleDomainResolverTest extends TestCase
|
||||
{
|
||||
/** @var SimpleDomainResolver */
|
||||
private $domainResolver;
|
||||
private SimpleDomainResolver $domainResolver;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -19,10 +19,8 @@ use Zend\Expressive\Router\RouteResult;
|
|||
|
||||
class NotFoundRedirectHandlerTest extends TestCase
|
||||
{
|
||||
/** @var NotFoundRedirectHandler */
|
||||
private $middleware;
|
||||
/** @var NotFoundRedirectOptions */
|
||||
private $redirectOptions;
|
||||
private NotFoundRedirectHandler $middleware;
|
||||
private NotFoundRedirectOptions $redirectOptions;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -17,10 +17,8 @@ use Zend\Expressive\Template\TemplateRendererInterface;
|
|||
|
||||
class NotFoundTemplateHandlerTest extends TestCase
|
||||
{
|
||||
/** @var NotFoundTemplateHandler */
|
||||
private $handler;
|
||||
/** @var ObjectProphecy */
|
||||
private $renderer;
|
||||
private NotFoundTemplateHandler $handler;
|
||||
private ObjectProphecy $renderer;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
|
@ -27,18 +27,12 @@ use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface;
|
|||
|
||||
class LocateShortUrlVisitTest extends TestCase
|
||||
{
|
||||
/** @var LocateShortUrlVisit */
|
||||
private $locateVisit;
|
||||
/** @var ObjectProphecy */
|
||||
private $ipLocationResolver;
|
||||
/** @var ObjectProphecy */
|
||||
private $em;
|
||||
/** @var ObjectProphecy */
|
||||
private $logger;
|
||||
/** @var ObjectProphecy */
|
||||
private $dbUpdater;
|
||||
/** @var ObjectProphecy */
|
||||
private $eventDispatcher;
|
||||
private LocateShortUrlVisit $locateVisit;
|
||||
private ObjectProphecy $ipLocationResolver;
|
||||
private ObjectProphecy $em;
|
||||
private ObjectProphecy $logger;
|
||||
private ObjectProphecy $dbUpdater;
|
||||
private ObjectProphecy $eventDispatcher;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue