Skip to content

Commit 409f7ba

Browse files
committed
[ci-review] Rector Rectify
1 parent ca8922d commit 409f7ba

6 files changed

+11
-10
lines changed

config/sets/laravel-array-str-functions-to-static-call.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// @see https://laravel.com/docs/5.7/facades#facades-vs-dependency-injection
1212

1313
return static function (RectorConfig $rectorConfig): void {
14-
1514
$rectorConfig->import(__DIR__ . '/../config.php');
1615

1716
$internalFunctions = get_defined_functions()['internal'];
@@ -64,7 +63,7 @@
6463
new FuncCallToStaticCall('studly_case', 'Illuminate\Support\Str', 'studly'),
6564
new FuncCallToStaticCall('title_case', 'Illuminate\Support\Str', 'title'),
6665
],
67-
fn($function) => ! in_array($function->getOldFuncName(), $internalFunctions)
66+
fn ($function) => ! in_array($function->getOldFuncName(), $internalFunctions, true)
6867
)
6968
);
7069
};

src/NodeFactory/ModelFactoryNodeFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function (Node $node) use ($closure, $name): ?Return_ {
125125
return null;
126126
}
127127

128-
if ($node->expr === null) {
128+
if (! $node->expr instanceof Expr) {
129129
return null;
130130
}
131131

src/Rector/ClassMethod/AddGenericReturnTypeToRelationsRector.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node
125125
// Don't update an existing return type if it differs from the native return type (thus the one without generics).
126126
// E.g. we only add generics to an existing return type, but don't change the type itself.
127127
if (
128-
$phpDocInfo->getReturnTagValue() !== null
128+
$phpDocInfo->getReturnTagValue() instanceof ReturnTagValueNode
129129
&& ! $this->areNativeTypeAndPhpDocReturnTypeEqual(
130130
$node,
131131
$methodReturnType,
@@ -151,7 +151,7 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node
151151
// Don't update the docblock if return type already contains the correct generics. This avoids overwriting
152152
// non-FQCN with our fully qualified ones.
153153
if (
154-
$phpDocInfo->getReturnTagValue() !== null
154+
$phpDocInfo->getReturnTagValue() instanceof ReturnTagValueNode
155155
&& $this->areGenericTypesEqual(
156156
$node,
157157
$phpDocInfo->getReturnTagValue(),
@@ -168,7 +168,7 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node
168168
);
169169

170170
// Update or add return tag
171-
if ($phpDocInfo->getReturnTagValue() !== null) {
171+
if ($phpDocInfo->getReturnTagValue() instanceof ReturnTagValueNode) {
172172
$phpDocInfo->getReturnTagValue()
173173
->type = $genericTypeNode;
174174
} else {

src/Rector/ClassMethod/MigrateToSimplifiedAttributeRector.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace RectorLaravel\Rector\ClassMethod;
66

7+
use PhpParser\Comment\Doc;
78
use PhpParser\Node;
89
use PhpParser\Node\Arg;
910
use PhpParser\Node\Expr\Array_;
@@ -96,7 +97,7 @@ public function refactor(Node $node): ?Node
9697
// Preserve docblock
9798
$docComment = $node->getDocComment();
9899

99-
if ($docComment !== null) {
100+
if ($docComment instanceof Doc) {
100101
$newNode->setDocComment($docComment);
101102
}
102103

src/Rector/Class_/PropertyDeferToDeferrableProviderToRector.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace RectorLaravel\Rector\Class_;
66

77
use PhpParser\Node;
8+
use PhpParser\Node\Expr;
89
use PhpParser\Node\Name\FullyQualified;
910
use PhpParser\Node\Stmt\Class_;
1011
use PhpParser\Node\Stmt\Property;
@@ -88,7 +89,7 @@ private function matchDeferWithFalseProperty(Class_ $class): ?Property
8889
}
8990

9091
$onlyProperty = $property->props[0];
91-
if ($onlyProperty->default === null) {
92+
if (! $onlyProperty->default instanceof Expr) {
9293
return null;
9394
}
9495

src/Rector/MethodCall/LumenRoutesStringMiddlewareToArrayRector.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private function getRouterMethodAttributes(MethodCall $methodCall): ?Array_
115115
private function findItemInArrayByKey(Array_ $array, string $keyName): ?ArrayItem
116116
{
117117
foreach ($array->items as $i => $item) {
118-
if ($item === null) {
118+
if (! $item instanceof ArrayItem) {
119119
continue;
120120
}
121121
if (! $this->arrayManipulator->hasKeyName($item, $keyName)) {
@@ -133,7 +133,7 @@ private function findItemInArrayByKey(Array_ $array, string $keyName): ?ArrayIte
133133
private function replaceItemInArrayByKey(Array_ $array, ArrayItem $arrayItem, string $keyName): void
134134
{
135135
foreach ($array->items as $i => $item) {
136-
if ($item === null) {
136+
if (! $item instanceof ArrayItem) {
137137
continue;
138138
}
139139
if (! $this->arrayManipulator->hasKeyName($item, $keyName)) {

0 commit comments

Comments
 (0)