Skip to content

Commit

Permalink
Update to PHPStan 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Nov 11, 2024
1 parent c214780 commit e3e7773
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"require": {
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^1.12"
"phpstan/phpstan": "^2.0"
},
"conflict": {
"azjezz/psl": "<1.6||>=4.0"
Expand All @@ -17,8 +17,8 @@
"composer/semver": "^3.3",
"nikic/php-parser": "^4.14.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-phpunit": "^1.4.0",
"phpstan/phpstan-strict-rules": "^1.6.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.6"
},
"config": {
Expand Down
3 changes: 2 additions & 1 deletion src/Type/AssertTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public function specifyTypes(MethodReflection $methodReflection, MethodCall $nod
return $this->typeSpecifier->create(
$args[0]->value,
$scope->getType($node),
TypeSpecifierContext::createTruthy()
TypeSpecifierContext::createTruthy(),
$scope
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Type/MatchesTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public function specifyTypes(MethodReflection $methodReflection, MethodCall $nod
return $this->typeSpecifier->create(
$args[0]->value,
$specType->getTemplateType(TypeInterface::class, 'T'),
$context
$context,
$scope
);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Type/TypeShapeReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use PHPStan\Type\Generic\GenericObjectType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\TypeUtils;
use Psl\Type\Internal\OptionalType;
use Psl\Type\TypeInterface;
use function count;
Expand All @@ -33,7 +32,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
}

$arg = $scope->getType($args[0]->value);
$arrays = TypeUtils::getConstantArrays($arg);
$arrays = $arg->getConstantArrays();
if (count($arrays) === 0) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Type/data/coerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function coerceShape(array $input): void
$output = $specification->coerce($input);

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

public function coerceInt($i): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Type/data/matches.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function matchesShape(array $a): void
if ($specification->matches($a)) {
assertType('array{name: string, age: int, location?: array{city: string, state: string, country: string}}', $a);
} else {
assertType('array', $a);
assertType('array<mixed>', $a);
}
}

Expand Down

0 comments on commit e3e7773

Please sign in to comment.