Skip to content

Commit

Permalink
Support PHPStan 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
axlon committed Nov 23, 2024
1 parent fd5d233 commit 5a8400a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
],
"require": {
"php": "^8.1",
"phpstan/phpstan": "^1.12"
"phpstan/phpstan": "^2.0"
},
"require-dev": {
"phpoption/phpoption": "^1.9",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan-deprecation-rules": "^1.2",
"phpstan/phpstan-strict-rules": "^1.6",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^10.5 || ^11.3",
"slevomat/coding-standard": "^8.15"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Type/PhpOption/FilterReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function getTypeFromMethodCall(
}

$valueType = $scope->getType(new MethodCall($methodCall->var, 'get'));
$scope = $scope->assignExpression($var, $valueType);
$scope = $scope->assignExpression($var, $valueType, $valueType);

if ($methodReflection->getName() === 'filter') {
$scope = $scope->filterByTruthyValue($expr);
Expand Down
5 changes: 3 additions & 2 deletions tests/Type/PhpOption/data/option-fold-left.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

/**
* @var \PhpOption\Option<string> $option
* @var int $initialValue
*/
assertType('int|string', $option->foldLeft(123, static function ($initial, $value) {
assertType('int', $initial);
assertType('int|string', $option->foldLeft($initialValue, static function ($initialValue, $value) {
assertType('int', $initialValue);
assertType('string', $value);

return $value;
Expand Down
5 changes: 3 additions & 2 deletions tests/Type/PhpOption/data/option-fold-right.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

/**
* @var \PhpOption\Option<string> $option
* @var int $initialValue
*/
assertType('int|string', $option->foldRight(123, static function ($value, $initial) {
assertType('int', $initial);
assertType('int|string', $option->foldRight($initialValue, static function ($value, $initialValue) {
assertType('int', $initialValue);
assertType('string', $value);

return $value;
Expand Down
3 changes: 2 additions & 1 deletion tests/Type/PhpOption/data/option-get-or-call.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

/**
* @var \PhpOption\Option<string> $option
* @var \Closure(): int $callable
*/
assertType('int|string', $option->getOrCall(static fn () => 123));
assertType('int|string', $option->getOrCall($callable));
3 changes: 2 additions & 1 deletion tests/Type/PhpOption/data/option-get-or-else.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

/**
* @var \PhpOption\Option<string> $option
* @var int $default
*/
assertType('int|string', $option->getOrElse(123));
assertType('int|string', $option->getOrElse($default));

0 comments on commit 5a8400a

Please sign in to comment.