Skip to content

Commit 975cd4b

Browse files
committed
Correct usage of Scope to always be passed with NodeCallbackInvoker in tests
Since PHPStan `2.1.32`, `Scope` alone cannot be passed to `\PHPStan\Rules\Rule#processNode()`, which instead needs a `Scope&NodeCallbackInvoker`. Ref: phpstan/phpstan-src@e271af4 Ref: https://github.com/phpstan/phpstan-src/blob/f7ccea98010d132f30891af12a66a9b49b2596ba/src/Rules/Rule.php Ref: phpstan/phpstan-src#4429
1 parent df57cda commit 975cd4b

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

tests/src/DisallowFloatInMethodSignatureRuleTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Roave\PHPStanTest\Rules\Floats;
66

77
use PhpParser\Node\Stmt\ClassMethod;
8-
use PHPStan\Analyser\Scope;
98
use PHPStan\Rules\Rule;
109
use PHPStan\ShouldNotHappenException;
1110
use PHPStan\Testing\RuleTestCase;
@@ -63,7 +62,7 @@ public function testRuleWillNotWorkWhenNotInClassScope(): void
6362
$rule = new DisallowFloatInMethodSignatureRule();
6463

6564
$node = $this->createMock(ClassMethod::class);
66-
$scope = $this->createMock(Scope::class);
65+
$scope = $this->createMock(ScopeWithNodeCallbackInvoker::class);
6766

6867
$scope
6968
->method('isInClass')

tests/src/DisallowFloatPropertyTypeRuleTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Roave\PHPStanTest\Rules\Floats;
66

77
use PhpParser\Node\PropertyItem;
8-
use PHPStan\Analyser\Scope;
98
use PHPStan\Rules\Rule;
109
use PHPStan\ShouldNotHappenException;
1110
use PHPStan\Testing\RuleTestCase;
@@ -41,7 +40,7 @@ public function testRuleWillNotWorkWhenNotInClassScope(): void
4140
$rule = new DisallowFloatPropertyTypeRule();
4241

4342
$node = $this->createMock(PropertyItem::class);
44-
$scope = $this->createMock(Scope::class);
43+
$scope = $this->createMock(ScopeWithNodeCallbackInvoker::class);
4544

4645
$scope
4746
->method('isInClass')
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Roave\PHPStanTest\Rules\Floats;
6+
7+
use PHPStan\Analyser\NodeCallbackInvoker;
8+
use PHPStan\Analyser\Scope;
9+
10+
interface ScopeWithNodeCallbackInvoker extends Scope, NodeCallbackInvoker
11+
{
12+
}

0 commit comments

Comments
 (0)