Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/NodeAnalyzer/ApplicationAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class ApplicationAnalyzer
{
private ?string $version = null;

/**
* @param class-string $applicationClass
*/
public function __construct(
private string $applicationClass = 'Illuminate\Foundation\Application',
) {}
Expand All @@ -20,13 +23,19 @@ public function setVersion(?string $version): static
return $this;
}

/**
* @param class-string $applicationClass
*/
public function setApplicationClass(string $applicationClass): static
{
$this->applicationClass = $applicationClass;

return $this;
}

/**
* @return class-string $applicationClass
*/
public function getApplicationClass(): string
{
return $this->applicationClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public function refactor(Node $node): ?Node
$parentStaticCallExpression = new Expression($staticCall);

$node->stmts = array_merge([$parentStaticCallExpression], (array) $node->stmts);
$node->stmts = array_values($node->stmts);

return $node;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public function refactor(Node $node): ?Node
$parentStaticCallExpression = new Expression($staticCall);

$node->stmts = array_merge([$parentStaticCallExpression], (array) $node->stmts);
$node->stmts = array_values($node->stmts);

return $node;
}
Expand Down
9 changes: 6 additions & 3 deletions src/Rector/ClassMethod/MigrateToSimplifiedAttributeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ public function refactor(Node $node): ?Node
}
}

return $hasChanged
? $node
: null;
if ($hasChanged) {
$node->stmts = array_values($node->stmts);

return $node;
}

return null;
}

public function getRuleDefinition(): RuleDefinition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function refactor(Node $node): ?Class_
$method->addStmt(new Return_($stmt->props[0]->default));
$methodNode = $method->getNode();
$node->stmts[] = $methodNode;
$node->stmts = array_values($node->stmts);

$this->restorePhpDoc($methodNode);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function refactor(Node $node): ?Node
}

unset($node->stmts[array_search($deferProperty, $node->stmts, true)]);
$node->stmts = array_values($node->stmts);

$node->implements[] = new FullyQualified('Illuminate\Contracts\Support\DeferrableProvider');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function refactor(Node $node): ?Node
}

unset($node->stmts[$index]);
$node->stmts = array_values($node->stmts);

break;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Rector/Class_/UnifyModelDatesWithCastsRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function getNodeTypes(): array
/**
* @param Class_ $node
*/
public function refactor(Node $node)
public function refactor(Node $node): ?Node
{
if (! $this->isObjectType($node, new ObjectType('Illuminate\Database\Eloquent\Model'))) {
return null;
Expand Down Expand Up @@ -128,8 +128,9 @@ public function refactor(Node $node)
}

unset($node->stmts[array_search($datesProperty, $node->stmts, true)]);
$node->stmts = array_values($node->stmts);

return null;
return $node;
}

private function createCastsProperty(): Property
Expand Down
1 change: 1 addition & 0 deletions src/Rector/MethodCall/WhereToWhereLikeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public function refactor(Node $node): ?Node

// Remove the second argument (the 'like' operator)
unset($node->args[1]);
$node->args = array_values($node->args);

return $node;
}
Expand Down
1 change: 1 addition & 0 deletions src/Rector/Namespace_/FactoryDefinitionRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public function refactor(Node $node): ?Node
}

$node->stmts = array_merge($node->stmts, $factories);
$node->stmts = array_values($node->stmts);

return $node;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function refactor(Node $node): ?Node
}

unset($node->args[2]);
$node->args = array_values($node->args);

$node->name = new Identifier('permanentRedirect');

Expand Down