Skip to content

Commit 6512963

Browse files
committed
feat: migrate phpstan 1 => 2
1 parent 60bf941 commit 6512963

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"doctrine/orm": "^2.15|^3.0",
2929
"friendsofphp/php-cs-fixer": "^3.34",
3030
"laravel/framework": "^10.0|^11.0",
31-
"phpstan/phpstan": "^1.10",
31+
"phpstan/phpstan": "^2.1.31",
3232
"phpunit/phpunit": "^10.4",
3333
"symfony/dependency-injection": "^6.0|^7.0",
3434
"symfony/framework-bundle": "^6.0|^7.0",

phpstan.neon.dist

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,24 @@ parameters:
44
- src
55
- tests
66
excludePaths:
7-
- src/DependencyInjection/DbToolsConfiguration.php
7+
- src/DependencyInjection/DbToolsConfiguration.php (?)
88
checkMissingOverrideMethodAttribute: true
9+
treatPhpDocTypesAsCertain: false
910
ignoreErrors:
1011
- '#Instantiated class Seld\\PharUtils\\Timestamps not found.#'
1112
- '#on an unknown class Seld\\PharUtils\\Timestamps.#'
13+
#- '#Call to method PHPUnit\\Framework\\Assert::assertNotNull\(\) with array<string, mixed> will always evaluate to true.#'
14+
- '#Call to static method PHPUnit\\Framework\\Assert::assertNotNull\(\) with string will always evaluate to true.#'
15+
- '#Call to method PHPUnit\\Framework\\Assert::assertNotNull\(\) with int will always evaluate to true.#'
16+
- '#Call to method PHPUnit\\Framework\\Assert::assertNotNull\(\) with float will always evaluate to true.#'
17+
- '#Property MakinaCorpus\\DbToolsBundle\\Tests\\Resources\\Loader\\TestJoinedChild::\$url \(string\|null\) is never assigned string so it can be removed from the property type.#'
18+
- '#Property MakinaCorpus\\DbToolsBundle\\Tests\\Resources\\Loader\\TestJoinedChild::\$thumbnail_url \(string\|null\) is never assigned string so it can be removed from the property type.#'
19+
- '#Property MakinaCorpus\\DbToolsBundle\\Tests\\Resources\\Loader\\TestEntity::\$id \(int\|null\) is never assigned int so it can be removed from the property type.#'
20+
- '#Call to function assert\(\) with true will always evaluate to true.#'
21+
- '#Strict comparison using !== between Symfony\\Component\\Finder\\SplFileInfo and string\|null will always evaluate to true.#'
22+
- '#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.#'
23+
- '#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.#'
24+
- '#Method MakinaCorpus\\DbToolsBundle\\Bridge\\Symfony\\DependencyInjection\\DbToolsExtension::getConfiguration\(\) never returns null so it can be removed from the return type.#'
25+
- '#Property MakinaCorpus\\DbToolsBundle\\Tests\\Resources\\Loader\\TestEntityWithEmbedded::\$id \(int\|null\) is never assigned int so it can be removed from the property type.#'
26+
- '#Property MakinaCorpus\\DbToolsBundle\\Tests\\Resources\\Loader\\TestJoinedParent::\$id \(int\|null\) is never assigned int so it can be removed from the property type.#'
27+
- '#Property MakinaCorpus\\DbToolsBundle\\Tests\\Resources\\Loader\\TestJoinedParent::\$email \(string\|null\) is never assigned string so it can be removed from the property type.#'

src/Anonymization/Anonymizer/Core/DateAnonymizer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ protected function validateOptions(): void
3838
throw new \InvalidArgumentException("You must specify both 'min' and 'max' boundaries.");
3939
}
4040

41-
// @phpstan-ignore-next-line False positive detected.
4241
if ($min && $max) {
4342
if ($max <= $min) {
4443
throw new \InvalidArgumentException("'min' value must be less than 'max' value.");

src/Helper/LoremIpsum.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ private function shuffle(): void
271271
* the injection of commas as well as capitalizing the first letter of the
272272
* first word of the sentence.
273273
*
274-
* @param array<string> $words
274+
* @param array<int, string> $words
275275
* Word array.
276276
* @return string
277277
* Punctuated sentence.
@@ -287,7 +287,7 @@ private function punctuate(array $words): string
287287
$commas = $this->gauss($mean, $std_dev);
288288

289289
for ($i = 1; $i <= $commas; $i++) {
290-
$word = \round($i * $word_count / ($commas + 1));
290+
$word = (int) \round($i * $word_count / ($commas + 1));
291291

292292
if ($word < ($word_count - 1) && $word > 0) {
293293
$words[$word] .= ',';

tests/Unit/Bridge/Symfony/DependencyInjection/DbToolsExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private function getContainer(array $parameters = [], array $bundles = []): Cont
3232
return $container;
3333
}
3434

35-
private function testExtension(array $config, ContainerBuilder $container = null): void
35+
private function testExtension(array $config, ?ContainerBuilder $container = null): void
3636
{
3737
$container ??= $this->getContainer();
3838
$extension = new DbToolsExtension();

0 commit comments

Comments
 (0)