Skip to content

Commit e7f88bf

Browse files
committed
fix a class name that should be string
1 parent d076140 commit e7f88bf

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"phpstan/phpstan": "^2.1.33",
1212
"phpstan/phpstan-deprecation-rules": "^2.0",
1313
"phpstan/phpstan-webmozart-assert": "^2.0",
14-
"phpunit/phpunit": "^11.5|^12.0",
14+
"phpunit/phpunit": "^12.0",
1515
"rector/jack": "^0.5",
1616
"rector/rector-src": "dev-main",
1717
"rector/swiss-knife": "^2.3",

rules/CodeQuality/Rector/Class_/TypeWillReturnCallableArrowFunctionRector.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
use PHPStan\Type\NeverType;
2020
use PHPStan\Type\ObjectType;
2121
use PHPStan\Type\Type;
22-
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
2322
use Rector\Enum\ClassName;
2423
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
2524
use Rector\PHPUnit\CodeQuality\NodeAnalyser\SetUpAssignedMockTypesResolver;
2625
use Rector\PHPUnit\CodeQuality\Reflection\MethodParametersAndReturnTypesResolver;
2726
use Rector\PHPUnit\CodeQuality\ValueObject\ParamTypesAndReturnType;
27+
use Rector\PHPUnit\Enum\PHPUnitClassName;
2828
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
2929
use Rector\Rector\AbstractRector;
3030
use Rector\Reflection\ReflectionResolver;
@@ -166,7 +166,11 @@ public function refactor(Node $node): ?Class_
166166
$methodName = $methodNameExpr->value;
167167
$callerType = $this->getType($parentMethodCall->var);
168168

169-
if ($callerType instanceof ObjectType && $callerType->getClassName() === InvocationMocker::class) {
169+
if ($callerType instanceof ObjectType && in_array(
170+
$callerType->getClassName(),
171+
[PHPUnitClassName::INVOCATION_MOCKER, PHPUnitClassName::INVOCATION_STUBBER],
172+
true
173+
)) {
170174
$parentMethodCall = $parentMethodCall->var;
171175

172176
if ($parentMethodCall instanceof MethodCall) {

rules/CodeQuality/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,7 @@ public function refactor(Node $node): ?Node
120120

121121
[$functionName, $assetMethodName, $notAssertMethodName] = self::FUNCTION_NAME_WITH_ASSERT_METHOD_NAMES[$firstArgumentName];
122122

123-
$functionNameWithAssertMethods = new FunctionNameWithAssertMethods(
124-
$assetMethodName,
125-
$notAssertMethodName
126-
);
123+
$functionNameWithAssertMethods = new FunctionNameWithAssertMethods($assetMethodName, $notAssertMethodName);
127124

128125
$this->renameMethod($node, $functionNameWithAssertMethods);
129126

src/Enum/PHPUnitClassName.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ final class PHPUnitClassName
1717

1818
public const string INVOCATION_ORDER = 'PHPUnit\Framework\MockObject\Rule\InvocationOrder';
1919

20+
public const string INVOCATION_MOCKER = 'PHPUnit\Framework\MockObject\Builder\InvocationMocker';
21+
22+
public const string INVOCATION_STUBBER = 'PHPUnit\Framework\MockObject\InvocationStubberImplementation';
23+
2024
public const string TEST_LISTENER = 'PHPUnit\Framework\TestListener';
2125

2226
/**

0 commit comments

Comments
 (0)