Skip to content

Commit bd21d49

Browse files
authored
chore(deps): Upgrade to PHPStan 2 (#305)
1 parent c0e70dd commit bd21d49

8 files changed

+27
-11
lines changed

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
"ergebnis/composer-normalize": "^2.45",
3434
"fidry/makefile": "^1.1.1",
3535
"infection/infection": "^0.29.14",
36-
"jangregor/phpstan-prophecy": "^1.0.2",
36+
"jangregor/phpstan-prophecy": "^2.1.1",
3737
"phpspec/prophecy-phpunit": "^2.3",
38-
"phpstan/extension-installer": "^1.4.3",
39-
"phpstan/phpstan": "^1.12.23",
40-
"phpstan/phpstan-phpunit": "^1.4.2",
41-
"phpstan/phpstan-symfony": "^1.4.14",
42-
"phpstan/phpstan-webmozart-assert": "^1.2.11",
38+
"phpstan/extension-installer": "^1.1",
39+
"phpstan/phpstan": "^2.1.10",
40+
"phpstan/phpstan-phpunit": "^2.0.4",
41+
"phpstan/phpstan-symfony": "^2.0.3",
42+
"phpstan/phpstan-webmozart-assert": "^2.0",
4343
"phpunit/phpunit": "^10.5.45 || ^11.0",
4444
"symfony/framework-bundle": "^6.4.19 || ^7.2.4",
4545
"webmozarts/strict-phpunit": "^7.13.1"

phpstan-src.neon.dist

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,12 @@ parameters:
1010

1111
- path: src/Input/ChildCommandFactory.php
1212
message: '#Parameter \#1 \$callback of function array_map expects#'
13+
14+
- path: src/Configuration.php
15+
identifier: staticMethod.alreadyNarrowedType
16+
17+
- path: src/Input/RawInput.php
18+
identifier: return.type
19+
20+
- path: src/Parallelization.php
21+
identifier: trait.unused

phpstan-tests.neon.dist

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ parameters:
66
excludePaths:
77
- tests/Integration/App/var
88
- tests/Input/FakeInput.php
9-
- tests/Input/FakeInput74.php
10-
- tests/Input/FakeInput81.php
119
- tests/Input/FakeSymfony6Input.php
1210
- tests/Process/DummyProcess.php
13-
- tests/Process/DummyProcess74.php
14-
- tests/Process/DummyProcess81.php
1511
ignoreErrors:
1612
- path: tests/Integration/TestLogger.php
1713
message: '#TestLogger::\$outputHandler#'
@@ -39,5 +35,7 @@ parameters:
3935
- path: tests/Input/RawInputTest.php
4036
message: '#Webmozarts\\Console\\Parallelization\\Input\\FakeInput#'
4137

38+
- path: tests/LazyRewindableIteratorTest.php
39+
identifier: staticMethod.alreadyNarrowedType
4240
- path: tests/LazyRewindableIteratorTest.php
4341
identifier: staticMethod.impossibleType

src/ChunkedItemsIterator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function __construct(
7070
$this->numberOfItems = null;
7171
}
7272

73+
/** @phpstan-ignore assign.propertyType */
7374
$this->itemsChunks = chunk($this->items, $batchSize);
7475
}
7576

@@ -116,6 +117,7 @@ public static function fromItemOrCallable(?string $item, callable $fetchItems, i
116117
*/
117118
public function getItems(): array|LazyRewindableIterator
118119
{
120+
// @phpstan-ignore-next-line return.type
119121
return $this->items;
120122
}
121123

@@ -189,7 +191,6 @@ private static function normalizeItem(mixed $item, mixed $index): string
189191
),
190192
);
191193
Assert::false(
192-
// TODO: legit bug
193194
'' !== $item && str_contains($item, PHP_EOL),
194195
sprintf(
195196
'An item cannot contain a line return. Got one for "%s" for the item "%s".',

src/Input/InputOptionsSerializer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private static function serializeOption(
7070
string $name,
7171
array|bool|float|int|string|null $value,
7272
): array {
73+
// @phpstan-ignore-next-line return.type argument.type
7374
return match (true) {
7475
$option->isNegatable() => [sprintf('--%s%s', $value ? '' : 'no-', $name)],
7576
!$option->acceptValue() => [sprintf('--%s', $name)],

src/ParallelExecutorFactory.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Console\Input\InputDefinition;
1818
use Symfony\Component\Console\Input\InputInterface;
1919
use Symfony\Component\Console\Output\OutputInterface;
20+
use Webmozart\Assert\Assert;
2021
use Webmozarts\Console\Parallelization\ErrorHandler\ErrorHandler;
2122
use Webmozarts\Console\Parallelization\Input\ChildCommandFactory;
2223
use Webmozarts\Console\Parallelization\Process\PhpExecutableFinder;
@@ -336,6 +337,7 @@ private static function getNoopClosure(): Closure
336337
}
337338
// @codeCoverageIgnoreEnd
338339

340+
/** @phpstan-ignore return.type */
339341
return $noop;
340342
}
341343

@@ -344,6 +346,9 @@ private static function getScriptPath(): string
344346
$pwd = $_SERVER['PWD'] ?? getcwd();
345347
$scriptName = $_SERVER['SCRIPT_NAME'];
346348

349+
Assert::string($pwd);
350+
Assert::string($scriptName);
351+
347352
return (str_starts_with($scriptName, $pwd)
348353
|| str_starts_with($scriptName, DIRECTORY_SEPARATOR)
349354
)

src/Process/PhpExecutableFinder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public static function find(): array
4949
'Could not find the PHP executable.',
5050
);
5151

52+
/** @phpstan-ignore return.type */
5253
return array_values([
5354
$phpExecutable,
5455
...$finder->findArguments(),

tests/ChunkedItemsIteratorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ static function () use (&$itemsFetched) {
131131
self::assertFalse($itemsFetched);
132132

133133
self::assertNull($iterator->getNumberOfItems());
134+
// @phpstan-ignore staticMethod.alreadyNarrowedType
134135
self::assertFalse($itemsFetched);
135136

136137
self::assertSame(['item1', 'item2'], toArrayWithKeys($iterator->getItems()));

0 commit comments

Comments
 (0)