Skip to content

Commit e3e7773

Browse files
committed
Update to PHPStan 2.0
1 parent c214780 commit e3e7773

6 files changed

+10
-9
lines changed

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"require": {
99
"php": "^7.4 || ^8.0",
10-
"phpstan/phpstan": "^1.12"
10+
"phpstan/phpstan": "^2.0"
1111
},
1212
"conflict": {
1313
"azjezz/psl": "<1.6||>=4.0"
@@ -17,8 +17,8 @@
1717
"composer/semver": "^3.3",
1818
"nikic/php-parser": "^4.14.0",
1919
"php-parallel-lint/php-parallel-lint": "^1.2",
20-
"phpstan/phpstan-phpunit": "^1.4.0",
21-
"phpstan/phpstan-strict-rules": "^1.6.0",
20+
"phpstan/phpstan-phpunit": "^2.0",
21+
"phpstan/phpstan-strict-rules": "^2.0",
2222
"phpunit/phpunit": "^9.6"
2323
},
2424
"config": {

src/Type/AssertTypeSpecifyingExtension.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public function specifyTypes(MethodReflection $methodReflection, MethodCall $nod
4242
return $this->typeSpecifier->create(
4343
$args[0]->value,
4444
$scope->getType($node),
45-
TypeSpecifierContext::createTruthy()
45+
TypeSpecifierContext::createTruthy(),
46+
$scope
4647
);
4748
}
4849

src/Type/MatchesTypeSpecifyingExtension.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public function specifyTypes(MethodReflection $methodReflection, MethodCall $nod
4444
return $this->typeSpecifier->create(
4545
$args[0]->value,
4646
$specType->getTemplateType(TypeInterface::class, 'T'),
47-
$context
47+
$context,
48+
$scope
4849
);
4950
}
5051

src/Type/TypeShapeReturnTypeExtension.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use PHPStan\Type\Generic\GenericObjectType;
1313
use PHPStan\Type\Type;
1414
use PHPStan\Type\TypeCombinator;
15-
use PHPStan\Type\TypeUtils;
1615
use Psl\Type\Internal\OptionalType;
1716
use Psl\Type\TypeInterface;
1817
use function count;
@@ -33,7 +32,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
3332
}
3433

3534
$arg = $scope->getType($args[0]->value);
36-
$arrays = TypeUtils::getConstantArrays($arg);
35+
$arrays = $arg->getConstantArrays();
3736
if (count($arrays) === 0) {
3837
return null;
3938
}

tests/Type/data/coerce.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function coerceShape(array $input): void
2626
$output = $specification->coerce($input);
2727

2828
assertType('array{name: string, age: int, location?: array{city: string, state: string, country: string}}', $output);
29-
assertType('array', $input);
29+
assertType('array<mixed>', $input);
3030
}
3131

3232
public function coerceInt($i): void

tests/Type/data/matches.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function matchesShape(array $a): void
2626
if ($specification->matches($a)) {
2727
assertType('array{name: string, age: int, location?: array{city: string, state: string, country: string}}', $a);
2828
} else {
29-
assertType('array', $a);
29+
assertType('array<mixed>', $a);
3030
}
3131
}
3232

0 commit comments

Comments
 (0)