Skip to content

Commit 784080a

Browse files
committed
Bump phpstan/phpstan from 1.x to 2.x
I also upgrade other PHPStan extensions we're using, and fixed a few issues.
1 parent b978fd9 commit 784080a

File tree

5 files changed

+10
-17
lines changed

5 files changed

+10
-17
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
},
1616
"require-dev": {
1717
"malukenho/docheader": "^0.1.7",
18-
"phpstan/phpstan": "^1.10",
19-
"phpstan/phpstan-deprecation-rules": "^1.1",
20-
"phpstan/phpstan-phpunit": "^1.3",
21-
"phpstan/phpstan-strict-rules": "^1.5",
18+
"phpstan/phpstan": "^2.1",
19+
"phpstan/phpstan-deprecation-rules": "^2.0",
20+
"phpstan/phpstan-phpunit": "^2.0",
21+
"phpstan/phpstan-strict-rules": "^2.0",
2222
"phpunit/phpunit": "^12.5",
2323
"respect/coding-standard": "^4.0",
2424
"squizlabs/php_codesniffer": "^3.7"

src/Stringifiers/CallableStringifier.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ public function stringify(mixed $raw, int $depth): ?string
6161
return $this->buildMethod(new ReflectionMethod($raw, '__invoke'), $raw, $depth);
6262
}
6363

64-
if (is_array($raw) && is_object($raw[0])) {
64+
if (is_array($raw) && is_object($raw[0]) && is_string($raw[1])) {
6565
return $this->buildMethod(new ReflectionMethod($raw[0], $raw[1]), $raw[0], $depth);
6666
}
6767

68-
if (is_array($raw) && is_string($raw[0])) {
68+
if (is_array($raw) && is_string($raw[0]) && is_string($raw[1])) {
6969
return $this->buildStaticMethod(new ReflectionMethod($raw[0], $raw[1]), $depth);
7070
}
7171

@@ -81,7 +81,7 @@ public function stringify(mixed $raw, int $depth): ?string
8181
return $this->buildFunction(new ReflectionFunction($raw), $depth);
8282
}
8383

84-
public function buildFunction(ReflectionFunction $raw, int $depth): ?string
84+
public function buildFunction(ReflectionFunction $raw, int $depth): string
8585
{
8686
return $this->quoter->quote($this->buildSignature($raw, $depth), $depth);
8787
}

tests/fixtures/WithMethods.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class WithMethods
1212
{
1313
public function publicMethod(Iterator&Countable $parameter): ?static
1414
{
15-
return new static();
15+
return $parameter instanceof SplHeap ? new static() : null;
1616
}
1717

1818
public static function publicStaticMethod(int|float $parameter): void

tests/src/Double/FakeStringifier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
final class FakeStringifier implements Stringifier
2020
{
21-
public function stringify(mixed $raw, int $depth): ?string
21+
public function stringify(mixed $raw, int $depth): string
2222
{
2323
return implode('.', ['fake', $depth, hash('crc32', serialize($raw))]);
2424
}

tests/unit/Stringifiers/CallableStringifierTest.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
use function array_sum;
2525
use function sprintf;
2626

27-
use const PHP_MAJOR_VERSION;
28-
use const PHP_MINOR_VERSION;
29-
3027
#[CoversClass(CallableStringifier::class)]
3128
final class CallableStringifierTest extends TestCase
3229
{
@@ -76,10 +73,6 @@ public function itShouldStringifyWhenRawValueIsCallableWithDefaultValues(): void
7673
#[Test]
7774
public function itShouldStringifyWhenRawValueIsCallableThatDoesNotHaveAnAccessibleDefaultValue(): void
7875
{
79-
if ([8, 1] !== [PHP_MAJOR_VERSION, PHP_MINOR_VERSION]) {
80-
self::markTestSkipped('This test is not applicable to PHP 8.1+');
81-
}
82-
8376
$raw = 'array_walk';
8477

8578
$quoter = new FakeQuoter();
@@ -88,7 +81,7 @@ public function itShouldStringifyWhenRawValueIsCallableThatDoesNotHaveAnAccessib
8881

8982
$actual = $sut->stringify($raw, self::DEPTH);
9083
$expected = $quoter->quote(
91-
'array_walk(object|array &$array, callable $callback, ?mixed $arg = fake.1.cbade92e): bool',
84+
'array_walk(object|array &$array, callable $callback, ?mixed $arg = fake.1.cbade92e): true',
9285
self::DEPTH
9386
);
9487

0 commit comments

Comments
 (0)