diff --git a/composer.json b/composer.json index 43bd14a9..79e927fa 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "doctrine/orm": "^2.15|^3.0", "friendsofphp/php-cs-fixer": "^3.34", "laravel/framework": "^10.0|^11.0", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^2.1.31", "phpunit/phpunit": "^10.4", "symfony/dependency-injection": "^6.0|^7.0", "symfony/framework-bundle": "^6.0|^7.0", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index b7263d0a..2c0b0fa2 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,8 +4,24 @@ parameters: - src - tests excludePaths: - - src/DependencyInjection/DbToolsConfiguration.php + - src/DependencyInjection/DbToolsConfiguration.php (?) checkMissingOverrideMethodAttribute: true + treatPhpDocTypesAsCertain: false ignoreErrors: - '#Instantiated class Seld\\PharUtils\\Timestamps not found.#' - '#on an unknown class Seld\\PharUtils\\Timestamps.#' + #- '#Call to method PHPUnit\\Framework\\Assert::assertNotNull\(\) with array will always evaluate to true.#' + - '#Call to static method PHPUnit\\Framework\\Assert::assertNotNull\(\) with string will always evaluate to true.#' + - '#Call to method PHPUnit\\Framework\\Assert::assertNotNull\(\) with int will always evaluate to true.#' + - '#Call to method PHPUnit\\Framework\\Assert::assertNotNull\(\) with float will always evaluate to true.#' + - '#Property MakinaCorpus\\DbToolsBundle\\Tests\\Resources\\Loader\\TestJoinedChild::\$url \(string\|null\) is never assigned string so it can be removed from the property type.#' + - '#Property MakinaCorpus\\DbToolsBundle\\Tests\\Resources\\Loader\\TestJoinedChild::\$thumbnail_url \(string\|null\) is never assigned string so it can be removed from the property type.#' + - '#Property MakinaCorpus\\DbToolsBundle\\Tests\\Resources\\Loader\\TestEntity::\$id \(int\|null\) is never assigned int so it can be removed from the property type.#' + - '#Call to function assert\(\) with true will always evaluate to true.#' + - '#Strict comparison using !== between Symfony\\Component\\Finder\\SplFileInfo and string\|null will always evaluate to true.#' + - '#Instanceof between MakinaCorpus\\DbToolsBundle\\Backupper\\MariadbBackupper\|MakinaCorpus\\DbToolsBundle\\Backupper\\MysqlBackupper\|MakinaCorpus\\DbToolsBundle\\Backupper\\PgsqlBackupper\|MakinaCorpus\\DbToolsBundle\\Backupper\\SqliteBackupper and MakinaCorpus\\DbToolsBundle\\Backupper\\AbstractBackupper will always evaluate to true.#' + - '#Instanceof between MakinaCorpus\\DbToolsBundle\\Restorer\\MariadbRestorer\|MakinaCorpus\\DbToolsBundle\\Restorer\\MysqlRestorer\|MakinaCorpus\\DbToolsBundle\\Restorer\\PgsqlRestorer\|MakinaCorpus\\DbToolsBundle\\Restorer\\SqliteRestorer and MakinaCorpus\\DbToolsBundle\\Restorer\\AbstractRestorer will always evaluate to true.#' + - '#Method MakinaCorpus\\DbToolsBundle\\Bridge\\Symfony\\DependencyInjection\\DbToolsExtension::getConfiguration\(\) never returns null so it can be removed from the return type.#' + - '#Property MakinaCorpus\\DbToolsBundle\\Tests\\Resources\\Loader\\TestEntityWithEmbedded::\$id \(int\|null\) is never assigned int so it can be removed from the property type.#' + - '#Property MakinaCorpus\\DbToolsBundle\\Tests\\Resources\\Loader\\TestJoinedParent::\$id \(int\|null\) is never assigned int so it can be removed from the property type.#' + - '#Property MakinaCorpus\\DbToolsBundle\\Tests\\Resources\\Loader\\TestJoinedParent::\$email \(string\|null\) is never assigned string so it can be removed from the property type.#' diff --git a/src/Anonymization/Anonymizer/Core/DateAnonymizer.php b/src/Anonymization/Anonymizer/Core/DateAnonymizer.php index 59ec3149..96267f9a 100644 --- a/src/Anonymization/Anonymizer/Core/DateAnonymizer.php +++ b/src/Anonymization/Anonymizer/Core/DateAnonymizer.php @@ -38,7 +38,6 @@ protected function validateOptions(): void throw new \InvalidArgumentException("You must specify both 'min' and 'max' boundaries."); } - // @phpstan-ignore-next-line False positive detected. if ($min && $max) { if ($max <= $min) { throw new \InvalidArgumentException("'min' value must be less than 'max' value."); diff --git a/src/Helper/LoremIpsum.php b/src/Helper/LoremIpsum.php index f1cf093c..b4ae3e87 100644 --- a/src/Helper/LoremIpsum.php +++ b/src/Helper/LoremIpsum.php @@ -271,7 +271,7 @@ private function shuffle(): void * the injection of commas as well as capitalizing the first letter of the * first word of the sentence. * - * @param array $words + * @param array $words * Word array. * @return string * Punctuated sentence. @@ -287,7 +287,7 @@ private function punctuate(array $words): string $commas = $this->gauss($mean, $std_dev); for ($i = 1; $i <= $commas; $i++) { - $word = \round($i * $word_count / ($commas + 1)); + $word = (int) \round($i * $word_count / ($commas + 1)); if ($word < ($word_count - 1) && $word > 0) { $words[$word] .= ','; diff --git a/tests/Unit/Bridge/Symfony/DependencyInjection/DbToolsExtensionTest.php b/tests/Unit/Bridge/Symfony/DependencyInjection/DbToolsExtensionTest.php index c57d0122..85b3e49c 100644 --- a/tests/Unit/Bridge/Symfony/DependencyInjection/DbToolsExtensionTest.php +++ b/tests/Unit/Bridge/Symfony/DependencyInjection/DbToolsExtensionTest.php @@ -32,7 +32,7 @@ private function getContainer(array $parameters = [], array $bundles = []): Cont return $container; } - private function testExtension(array $config, ContainerBuilder $container = null): void + private function testExtension(array $config, ?ContainerBuilder $container = null): void { $container ??= $this->getContainer(); $extension = new DbToolsExtension();