Skip to content

Commit

Permalink
Make changes compatible with phpstan 1 + 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Nov 12, 2024
1 parent 3c5eea0 commit 92438b0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
},
"require-dev": {
"phpunit/phpunit": "^8 || ^9",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0"
"phpstan/phpstan": "^1.12 || ^2",
"phpstan/phpstan-strict-rules": "^1 || ^2"
},
"conflict": {
"phpstan/phpstan": "<2.0"
"phpstan/phpstan": "<1.11.10"
},
"autoload": {
"psr-4": {
Expand Down
21 changes: 16 additions & 5 deletions src/PHPStan/PregMatchTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,24 @@ public function specifyTypes(MethodReflection $methodReflection, StaticCall $nod
$context = $context->negate();
}

$typeSpecifier = $this->typeSpecifier->create(
if (method_exists('PHPStan\Analyser\SpecifiedTypes', 'setRootExpr')) {

Check failure on line 96 in src/PHPStan/PregMatchTypeSpecifyingExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Call to function method_exists() with 'PHPStan\\Analyser…' and 'setRootExpr' will always evaluate to true.
$typeSpecifier = $this->typeSpecifier->create(
$matchesArg->value,
$matchedType,
$context,
$scope
)->setRootExpr($node);

return $overwrite ? $typeSpecifier->setAlwaysOverwriteTypes() : $typeSpecifier;
}

return $this->typeSpecifier->create(

Check failure on line 107 in src/PHPStan/PregMatchTypeSpecifyingExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Method PHPStan\Analyser\TypeSpecifier::create() invoked with 6 parameters, 4 required.
$matchesArg->value,
$matchedType,
$context,
$scope
)->setRootExpr($node);

return $overwrite ? $typeSpecifier->setAlwaysOverwriteTypes() : $typeSpecifier;
$overwrite,

Check failure on line 111 in src/PHPStan/PregMatchTypeSpecifyingExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Parameter #4 $scope of method PHPStan\Analyser\TypeSpecifier::create() expects PHPStan\Analyser\Scope, bool given.
$scope,
$node
);
}
}

0 comments on commit 92438b0

Please sign in to comment.