Skip to content

Commit 3ffad20

Browse files
authored
PHPStan 2.0 support (#243)
* Pass now required `$scope` argument * Use `ReflectionProvider` instead of `Broker` * More `$scope` * `RuleLevelHelperAcceptsResult` * PHPCS fixes * Require PHPStan 2.0 and PHP 7.4 * PHPCS fixes * Remove file again * Update travis config * Remove comments again
1 parent cda932a commit 3ffad20

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

composer.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,25 @@
1111
"phpstan"
1212
],
1313
"require": {
14-
"php": "^7.2 || ^8.0",
14+
"php": "^7.4 || ^8.0",
1515
"php-stubs/wordpress-stubs": "^6.6.2",
16-
"phpstan/phpstan": "^1.11.0",
16+
"phpstan/phpstan": "^2.0",
1717
"symfony/polyfill-php73": "^1.12.0"
1818
},
1919
"require-dev": {
2020
"composer/composer": "^2.1.14",
2121
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
2222
"php-parallel-lint/php-parallel-lint": "^1.1",
23-
"phpstan/phpstan-strict-rules": "^1.2",
24-
"phpunit/phpunit": "^8.0 || ^9.0",
23+
"phpstan/phpstan-strict-rules": "^2.0",
24+
"phpunit/phpunit": "^9.0",
2525
"szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.0",
2626
"wp-coding-standards/wpcs": "3.1.0 as 2.3.0"
2727
},
2828
"suggest": {
2929
"swissspidy/phpstan-no-private": "Detect usage of internal core functions, classes and methods"
3030
},
31+
"minimum-stability": "dev",
32+
"prefer-stable": true,
3133
"autoload": {
3234
"psr-4": {
3335
"SzepeViktor\\PHPStan\\WordPress\\": "src/"

src/AssertNotWpErrorTypeSpecifyingExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function specifyTypes(MethodReflection $methodReflection, MethodCall $nod
4141
$typeBefore = $scope->getType($expr);
4242
$type = TypeCombinator::remove($typeBefore, new ObjectType(\WP_Error::class));
4343

44-
return $this->typeSpecifier->create($expr, $type, TypeSpecifierContext::createTruthy());
44+
return $this->typeSpecifier->create($expr, $type, TypeSpecifierContext::createTruthy(), $scope);
4545
}
4646

4747
public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void

src/AssertWpErrorTypeSpecifyingExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public function specifyTypes(MethodReflection $methodReflection, MethodCall $nod
4141
return $this->typeSpecifier->create(
4242
$args[0]->value,
4343
new ObjectType(\WP_Error::class),
44-
TypeSpecifierContext::createTruthy()
44+
TypeSpecifierContext::createTruthy(),
45+
$scope
4546
);
4647
}
4748

src/HookDocsRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ protected function validateSingleParamTag(string $paramName, ParamTag $paramTag,
199199
$this->currentScope->isDeclareStrictTypes()
200200
);
201201

202-
if ($accepted) {
202+
if ($accepted->result) {
203203
return;
204204
}
205205

0 commit comments

Comments
 (0)