Merge pull request #2132 from acelaya-forks/feature/update-phpstan

Update to latest phpstan
This commit is contained in:
Alejandro Celaya 2024-05-21 19:05:39 +02:00 committed by GitHub
commit 5ad4b39160
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 15 additions and 14 deletions

View File

@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
### Changed ### Changed
* Use new reusable workflow to publish docker image * Use new reusable workflow to publish docker image
* [#2015](https://github.com/shlinkio/shlink/issues/2015) Update to PHPUnit 11. * [#2015](https://github.com/shlinkio/shlink/issues/2015) Update to PHPUnit 11.
* [#2130](https://github.com/shlinkio/shlink/pull/2130) Replace deprecated `pugx/shortid-php` package with `hidehalo/nanoid-php`.
### Deprecated ### Deprecated
* *Nothing* * *Nothing*

View File

@ -63,10 +63,10 @@
"require-dev": { "require-dev": {
"devizzent/cebe-php-openapi": "^1.0.1", "devizzent/cebe-php-openapi": "^1.0.1",
"devster/ubench": "^2.1", "devster/ubench": "^2.1",
"phpstan/phpstan": "^1.10", "phpstan/phpstan": "^1.11",
"phpstan/phpstan-doctrine": "^1.3", "phpstan/phpstan-doctrine": "^1.4",
"phpstan/phpstan-phpunit": "^1.3", "phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan-symfony": "^1.3", "phpstan/phpstan-symfony": "^1.4",
"phpunit/php-code-coverage": "^11.0", "phpunit/php-code-coverage": "^11.0",
"phpunit/phpcov": "^10.0", "phpunit/phpcov": "^10.0",
"phpunit/phpunit": "^11.1", "phpunit/phpunit": "^11.1",

View File

@ -105,7 +105,7 @@ services:
shlink_db_ms: shlink_db_ms:
container_name: shlink_db_ms container_name: shlink_db_ms
image: mcr.microsoft.com/mssql/server:2019-latest image: mcr.microsoft.com/mssql/server:2022-latest
ports: ports:
- "1433:1433" - "1433:1433"
environment: environment:

View File

@ -9,7 +9,7 @@ use Cake\Chronos\Chronos;
use DateTimeInterface; use DateTimeInterface;
use Doctrine\ORM\Mapping\Builder\FieldBuilder; use Doctrine\ORM\Mapping\Builder\FieldBuilder;
use GuzzleHttp\Psr7\Query; use GuzzleHttp\Psr7\Query;
use Hidehalo\Nanoid\Client; use Hidehalo\Nanoid\Client as NanoidClient;
use Jaybizzle\CrawlerDetect\CrawlerDetect; use Jaybizzle\CrawlerDetect\CrawlerDetect;
use Laminas\Filter\Word\CamelCaseToSeparator; use Laminas\Filter\Word\CamelCaseToSeparator;
use Laminas\Filter\Word\CamelCaseToUnderscore; use Laminas\Filter\Word\CamelCaseToUnderscore;
@ -37,15 +37,15 @@ use function ucfirst;
function generateRandomShortCode(int $length, ShortUrlMode $mode = ShortUrlMode::STRICT): string function generateRandomShortCode(int $length, ShortUrlMode $mode = ShortUrlMode::STRICT): string
{ {
static $shortIdFactory; static $nanoIdClient;
if ($shortIdFactory === null) { if ($nanoIdClient === null) {
$shortIdFactory = new Client(); $nanoIdClient = new NanoidClient();
} }
$alphabet = $mode === ShortUrlMode::STRICT $alphabet = $mode === ShortUrlMode::STRICT
? '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ? '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
: '0123456789abcdefghijklmnopqrstuvwxyz'; : '0123456789abcdefghijklmnopqrstuvwxyz';
return $shortIdFactory->formattedId($alphabet, $length); return $nanoIdClient->formattedId($alphabet, $length);
} }
function parseDateFromQuery(array $query, string $dateName): ?Chronos function parseDateFromQuery(array $query, string $dateName): ?Chronos

View File

@ -37,8 +37,8 @@ class MatomoTrackerBuilderTest extends TestCase
{ {
$tracker = $this->builder()->buildMatomoTracker(); $tracker = $this->builder()->buildMatomoTracker();
self::assertEquals('api_token', $tracker->token_auth); // @phpstan-ignore-line self::assertEquals('api_token', $tracker->token_auth);
self::assertEquals(5, $tracker->idSite); // @phpstan-ignore-line self::assertEquals(5, $tracker->idSite);
self::assertEquals(MatomoTrackerBuilder::MATOMO_DEFAULT_TIMEOUT, $tracker->getRequestTimeout()); self::assertEquals(MatomoTrackerBuilder::MATOMO_DEFAULT_TIMEOUT, $tracker->getRequestTimeout());
self::assertEquals(MatomoTrackerBuilder::MATOMO_DEFAULT_TIMEOUT, $tracker->getRequestConnectTimeout()); self::assertEquals(MatomoTrackerBuilder::MATOMO_DEFAULT_TIMEOUT, $tracker->getRequestConnectTimeout());
} }

View File

@ -4,8 +4,6 @@ includes:
- vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon - vendor/phpstan/phpstan-phpunit/rules.neon
parameters: parameters:
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
symfony: symfony:
console_application_loader: 'config/cli-app.php' console_application_loader: 'config/cli-app.php'
doctrine: doctrine:
@ -14,3 +12,5 @@ parameters:
ignoreErrors: ignoreErrors:
- '#should return int<0, max> but returns int#' - '#should return int<0, max> but returns int#'
- '#expects -1|int<1, max>, int given#' - '#expects -1|int<1, max>, int given#'
- identifier: missingType.generics
- identifier: missingType.iterableValue