Skip to content

Commit 3e538dd

Browse files
committed
Update PHPStan
1 parent 646b514 commit 3e538dd

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

phpstan.neon

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,20 @@ includes:
77
parameters:
88
excludes_analyse:
99
- */tests/*/data/*
10+
11+
services:
12+
scopeIsInClass:
13+
class: PHPStan\Build\ScopeIsInClassTypeSpecifyingExtension
14+
arguments:
15+
isInMethodName: isInClass
16+
removeNullMethodName: getClassReflection
17+
tags:
18+
- phpstan.typeSpecifier.methodTypeSpecifyingExtension
19+
20+
scopeIsInTrait:
21+
class: PHPStan\Build\ScopeIsInClassTypeSpecifyingExtension
22+
arguments:
23+
isInMethodName: isInTrait
24+
removeNullMethodName: getTraitReflection
25+
tags:
26+
- phpstan.typeSpecifier.methodTypeSpecifyingExtension

src/Rules/PHPUnit/AssertRuleHelper.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
class AssertRuleHelper
1010
{
1111

12-
/**
13-
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node
14-
* @param \PHPStan\Analyser\Scope $scope
15-
* @return bool
16-
*/
1712
public static function isMethodOrStaticCallOnTestCase(Node $node, Scope $scope): bool
1813
{
1914
$testCaseType = new ObjectType(\PHPUnit\Framework\TestCase::class);
@@ -22,15 +17,18 @@ public static function isMethodOrStaticCallOnTestCase(Node $node, Scope $scope):
2217
} elseif ($node instanceof Node\Expr\StaticCall) {
2318
if ($node->class instanceof Node\Name) {
2419
$class = (string) $node->class;
25-
if (in_array(
26-
strtolower($class),
27-
[
28-
'self',
29-
'static',
30-
'parent',
31-
],
32-
true
33-
)) {
20+
if (
21+
$scope->isInClass()
22+
&& in_array(
23+
strtolower($class),
24+
[
25+
'self',
26+
'static',
27+
'parent',
28+
],
29+
true
30+
)
31+
) {
3432
$calledOnType = new ObjectType($scope->getClassReflection()->getName());
3533
} else {
3634
$calledOnType = new ObjectType($class);

0 commit comments

Comments
 (0)