Skip to content

Commit 04f550c

Browse files
committed
[ci-review] Rector Rectify
1 parent 9840750 commit 04f550c

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

rules/CodeQuality/Rector/ClassMethod/AddInstanceofAssertForNullableInstanceRector.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
use PhpParser\Node\Expr\MethodCall;
1212
use PhpParser\Node\Expr\Variable;
1313
use PhpParser\Node\Name\FullyQualified;
14+
use PhpParser\Node\Stmt;
1415
use PhpParser\Node\Stmt\ClassMethod;
1516
use PhpParser\Node\Stmt\Expression;
1617
use PhpParser\Node\Stmt\Foreach_;
1718
use PHPStan\Type\ObjectType;
1819
use PHPStan\Type\Type;
1920
use PHPStan\Type\TypeCombinator;
21+
use PHPStan\Type\UnionType;
2022
use Rector\PHPUnit\CodeQuality\ValueObject\VariableNameToType;
2123
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
2224
use Rector\Rector\AbstractRector;
@@ -159,7 +161,7 @@ public function refactor(Node $node): ?Node
159161

160162
private function isNullableType(Type $type): bool
161163
{
162-
if (! $type instanceof \PHPStan\Type\UnionType) {
164+
if (! $type instanceof UnionType) {
163165
return false;
164166
}
165167

@@ -217,12 +219,12 @@ private function matchNullableVariableNameToType(
217219
): ?VariableNameToType {
218220
$variableName = $this->getName($variable);
219221

220-
foreach ($nullableVariableNamesToTypes as $nullableVariableNamesToType) {
221-
if ($nullableVariableNamesToType->getVariableName() !== $variableName) {
222+
foreach ($nullableVariableNamesToTypes as $nullableVariableNameToType) {
223+
if ($nullableVariableNameToType->getVariableName() !== $variableName) {
222224
continue;
223225
}
224226

225-
return $nullableVariableNamesToType;
227+
return $nullableVariableNameToType;
226228
}
227229

228230
return null;
@@ -232,15 +234,15 @@ private function matchNullableVariableNameToType(
232234
* @param VariableNameToType[] $variableNamesToTypes
233235
*/
234236
private function matchedNullableVariableNameToType(
235-
Node\Stmt $stmt,
237+
Stmt $stmt,
236238
array $variableNamesToTypes
237239
): ?VariableNameToType {
238240
$matchedNullableVariableNameToType = null;
239241

240242
$this->traverseNodesWithCallable($stmt, function (Node $node) use (
241243
$variableNamesToTypes,
242244
&$matchedNullableVariableNameToType
243-
) {
245+
): null {
244246
if (! $node instanceof MethodCall) {
245247
return null;
246248
}

rules/CodeQuality/ValueObject/VariableNameToType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
namespace Rector\PHPUnit\CodeQuality\ValueObject;
66

7-
final class VariableNameToType
7+
final readonly class VariableNameToType
88
{
99
public function __construct(
10-
private readonly string $variableName,
11-
private readonly string $objectType
10+
private string $variableName,
11+
private string $objectType
1212
) {
1313
}
1414

0 commit comments

Comments
 (0)