diff --git a/mago-analyze-baseline.toml b/mago-analyze-baseline.toml index e8864fdd..d643042a 100644 --- a/mago-analyze-baseline.toml +++ b/mago-analyze-baseline.toml @@ -258,18 +258,6 @@ code = "redundant-logical-operation" message = "Redundant `&&` operation: left operand is evaluated and right operand is always falsy." count = 1 -[[issues]] -file = "module/CLI/src/Command/ShortUrl/DeleteExpiredShortUrlsCommand.php" -code = "redundant-condition" -message = "Redundant condition" -count = 1 - -[[issues]] -file = "module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php" -code = "invalid-array-element-key" -message = "Cannot use spread operator on an iterable with key type `mixed`." -count = 1 - [[issues]] file = "module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php" code = "less-specific-nested-return-statement" @@ -285,7 +273,7 @@ count = 1 [[issues]] file = "module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php" code = "mixed-property-access" -message = "Attempting to access a property on a non-object type (`mixed`)." +message = "Attempting to access property `$total` on a non-object type (`mixed`)." count = 1 [[issues]] @@ -462,6 +450,24 @@ code = "deprecated-class" message = 'Class `Shlinkio\Shlink\CLI\ApiKey\RoleResolver` is deprecated and should no longer be used.' count = 1 +[[issues]] +file = "module/CLI/test/ApiKey/RoleResolverTest.php" +code = "deprecated-property" +message = 'Use of deprecated property `Shlinkio\Shlink\CLI\Command\Api\Input\ApiKeyInput::$authorOnly`.' +count = 2 + +[[issues]] +file = "module/CLI/test/ApiKey/RoleResolverTest.php" +code = "deprecated-property" +message = 'Use of deprecated property `Shlinkio\Shlink\CLI\Command\Api\Input\ApiKeyInput::$domain`.' +count = 3 + +[[issues]] +file = "module/CLI/test/ApiKey/RoleResolverTest.php" +code = "deprecated-property" +message = 'Use of deprecated property `Shlinkio\Shlink\CLI\Command\Api\Input\ApiKeyInput::$noOrphanVisits`.' +count = 1 + [[issues]] file = "module/CLI/test/ApiKey/RoleResolverTest.php" code = "invalid-array-element-key" @@ -528,12 +534,24 @@ code = "invalid-return-statement" message = 'Invalid return type for function `ShlinkioTest\Shlink\CLI\Util\CliTestUtils::createCommandStub`: expected `PHPUnit\Framework\MockObject\Stub&Symfony\Component\Console\Command\Command`, but found `PHPUnit\Framework\MockObject\MockObject|PHPUnit\Framework\MockObject\Stub`.' count = 1 +[[issues]] +file = "module/CLI/test/Util/CliTestUtils.php" +code = "named-argument-not-allowed" +message = 'Named arguments are not allowed for `PHPUnit\Framework\MockObject\Generator\Generator::testDouble`.' +count = 3 + [[issues]] file = "module/Core/functions/array-utils.php" code = "mixed-argument" message = 'Invalid argument type for argument #2 of `callable`: expected `string|unknown-ref(Shlinkio\Shlink\Core\ArrayUtils\number)`, but found `mixed`.' count = 2 +[[issues]] +file = "module/Core/functions/array-utils.php" +code = "mixed-array-index" +message = '''Invalid index type `mixed` used in array assignment on `array`.''' +count = 1 + [[issues]] file = "module/Core/functions/array-utils.php" code = "mixed-assignment" @@ -606,24 +624,12 @@ code = "mixed-assignment" message = "Assigning `nonnull` type to a variable may lead to unexpected behavior." count = 1 -[[issues]] -file = "module/Core/functions/functions.php" -code = "mixed-method-access" -message = "Attempting to access a method on a non-object type (`nonnull`)." -count = 1 - [[issues]] file = "module/Core/functions/functions.php" code = "mixed-return-statement" message = 'Could not infer a precise return type for function `Shlinkio\Shlink\Core\enumSide`. Saw type `nonnull`.' count = 1 -[[issues]] -file = "module/Core/functions/functions.php" -code = "mixed-return-statement" -message = 'Could not infer a precise return type for function `Shlinkio\Shlink\Core\generateRandomShortCode`. Saw type `mixed`.' -count = 1 - [[issues]] file = "module/Core/functions/functions.php" code = "mixed-return-statement" @@ -738,6 +744,12 @@ code = "deprecated-method" message = 'Call to deprecated method: `Doctrine\DBAL\Schema\Table::setPrimaryKey`.' count = 2 +[[issues]] +file = "module/Core/migrations/Version20240226214216.php" +code = "mixed-array-index" +message = "Invalid index type `mixed` used in array assignment on `array`." +count = 1 + [[issues]] file = "module/Core/migrations/Version20240226214216.php" code = "mixed-assignment" @@ -1638,30 +1650,6 @@ code = "less-specific-return-statement" message = 'Returned type `Doctrine\Common\Collections\ArrayCollection` is less specific than the declared return type `Doctrine\Common\Collections\Collection` for function `Shlinkio\Shlink\Core\ShortUrl\Resolver\PersistenceShortUrlRelationResolver::resolveTags`.' count = 1 -[[issues]] -file = "module/Core/src/ShortUrl/Resolver/PersistenceShortUrlRelationResolver.php" -code = "mixed-assignment" -message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 1 - -[[issues]] -file = "module/Core/src/ShortUrl/Resolver/PersistenceShortUrlRelationResolver.php" -code = "mixed-method-access" -message = "Attempting to access a method on a non-object type (`mixed`)." -count = 1 - -[[issues]] -file = "module/Core/src/ShortUrl/Resolver/PersistenceShortUrlRelationResolver.php" -code = "property-type-coercion" -message = 'A value of a less specific type `array` is being assigned to property `$domainLocks` (array).' -count = 1 - -[[issues]] -file = "module/Core/src/ShortUrl/Resolver/PersistenceShortUrlRelationResolver.php" -code = "property-type-coercion" -message = 'A value of a less specific type `array` is being assigned to property `$tagLocks` (array).' -count = 1 - [[issues]] file = "module/Core/src/ShortUrl/Resolver/PersistenceShortUrlRelationResolver.php" code = "redundant-docblock-type" @@ -1887,7 +1875,7 @@ count = 1 [[issues]] file = "module/Core/src/Visit/Repository/VisitIterationRepository.php" code = "mixed-method-access" -message = "Attempting to access a method on a non-object type (`mixed`)." +message = "Attempting to call method `getId()` on a non-object type (`mixed`)." count = 1 [[issues]] @@ -1962,12 +1950,6 @@ code = "less-specific-nested-argument-type" message = 'Argument type mismatch for argument #1 of `Shlinkio\Shlink\Core\Visit\VisitsTracker::trackVisit`: expected `(callable(Shlinkio\Shlink\Core\Visit\Model\Visitor): Shlinkio\Shlink\Core\Visit\Entity\Visit)`, but provided type `(callable(...mixed=): mixed)` is less specific.' count = 1 -[[issues]] -file = "module/Core/test-api/Action/RedirectTest.php" -code = "invalid-array-element-key" -message = "Invalid array key type." -count = 1 - [[issues]] file = "module/Core/test-api/Action/RedirectTest.php" code = "invalid-iterator" @@ -1986,6 +1968,12 @@ code = "mixed-array-access" message = "Unsafe array access on type `mixed`." count = 3 +[[issues]] +file = "module/Core/test-api/Action/RedirectTest.php" +code = "mixed-array-index" +message = "Possibly invalid array key type." +count = 1 + [[issues]] file = "module/Core/test-api/Action/RedirectTest.php" code = "mixed-assignment" diff --git a/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php b/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php index 36b8520e..fd7b3eb5 100644 --- a/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php +++ b/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php @@ -49,11 +49,12 @@ class ListShortUrlsCommand extends Command $result = $this->renderPage($io, $columnsMap, $params, $paramsInput->all); $paramsInput->page += 1; - $continue = $result->hasNextPage() - && $io->confirm( - sprintf('Continue with page %s?', $paramsInput->page), - default: false, - ); + $continue = + $result->hasNextPage() + && $io->confirm( + sprintf('Continue with page %s?', $paramsInput->page), + default: false, + ); } while ($continue); $io->newLine(); diff --git a/module/Core/functions/functions.php b/module/Core/functions/functions.php index dcde05df..26abbdee 100644 --- a/module/Core/functions/functions.php +++ b/module/Core/functions/functions.php @@ -42,10 +42,7 @@ use const Shlinkio\Shlink\IP_ADDRESS_REQUEST_ATTRIBUTE; function generateRandomShortCode(int $length, ShortUrlMode $mode = ShortUrlMode::STRICT): string { - static $nanoIdClient; - if ($nanoIdClient === null) { - $nanoIdClient = new NanoidClient(); - } + static $nanoIdClient = new NanoidClient(); $alphabet = $mode === ShortUrlMode::STRICT ? '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' diff --git a/module/Core/src/ShortUrl/Resolver/PersistenceShortUrlRelationResolver.php b/module/Core/src/ShortUrl/Resolver/PersistenceShortUrlRelationResolver.php index 5be90a9b..4e67fe56 100644 --- a/module/Core/src/ShortUrl/Resolver/PersistenceShortUrlRelationResolver.php +++ b/module/Core/src/ShortUrl/Resolver/PersistenceShortUrlRelationResolver.php @@ -114,7 +114,6 @@ class PersistenceShortUrlRelationResolver implements ShortUrlRelationResolverInt } /** - * /** * @param array $locks */ private function releaseLock(array &$locks, string $name): void @@ -134,6 +133,9 @@ class PersistenceShortUrlRelationResolver implements ShortUrlRelationResolverInt $this->releaseLocks($this->domainLocks); } + /** + * @param array $locks + */ private function releaseLocks(array &$locks): void { foreach ($locks as $tagLock) {