Skip to content

Commit

Permalink
[ci-review] Rector Rectify
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jul 3, 2022
1 parent f4f6b93 commit 11fffc5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
9 changes: 6 additions & 3 deletions rules/CodeQuality/Rector/For_/ForToForeachRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ public function refactor(Node $node): ?Node

private function processForToForeach(For_ $for, string $iteratedVariable): ?Foreach_
{
$originalVariableSingle = $this->inflector->singularize($iteratedVariable);
$iteratedVariableSingle = $originalVariableSingle;
$originalVariableSingle = null;
$iteratedVariableSingle = $this->inflector->singularize($iteratedVariable);

if ($iteratedVariableSingle === $iteratedVariable) {
$iteratedVariableSingle = 'single' . ucfirst($iteratedVariableSingle);
Expand All @@ -167,7 +167,10 @@ private function processForToForeach(For_ $for, string $iteratedVariable): ?Fore
return null;
}

private function createForeachFromForWithIteratedVariableSingle(For_ $for, string $iteratedVariableSingle): Foreach_
private function createForeachFromForWithIteratedVariableSingle(
\For_ $for,
string $iteratedVariableSingle
): Foreach_
{
$foreach = $this->foreachFactory->createFromFor(
$for,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
final class RemoveJustVariableAssignRector extends AbstractRector
{
public function __construct(
private VariableAnalyzer $variableAnalyzer
private readonly VariableAnalyzer $variableAnalyzer
) {
}

Expand Down
8 changes: 4 additions & 4 deletions rules/Privatization/Reflection/ClassConstantsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ public function __construct(
}

/**
* @return array<string, mixed>
* @return array<string, mixed>|null
*/
public function getClassConstantNamesToValues(string $classWithConstants): array
public function getClassConstantNamesToValues(string $classWithConstants): ?array
{
$constantNamesToValues = null;
if (isset($this->cachedConstantNamesToValues[$classWithConstants])) {
return $this->cachedConstantNamesToValues[$classWithConstants];
}
Expand All @@ -34,8 +35,7 @@ public function getClassConstantNamesToValues(string $classWithConstants): array
$classReflection = $this->reflectionProvider->getClass($classWithConstants);
$nativeReflection = $classReflection->getNativeReflection();

$constantNamesToValues = $nativeReflection->getConstants();
$this->cachedConstantNamesToValues = $constantNamesToValues;
$this->cachedConstantNamesToValues = $nativeReflection->getConstants();

return $constantNamesToValues;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ private function processGetter(PropertyFetch $propertyFetch): ?Node
);

if ($propertyToMethodCall->getNewGetArguments() !== []) {
$args = $this->nodeFactory->createArgs($propertyToMethodCall->getNewGetArguments());
$methodCall->args = $args;
$methodCall->args = $this->nodeFactory->createArgs($propertyToMethodCall->getNewGetArguments());
}

return $methodCall;
Expand Down

0 comments on commit 11fffc5

Please sign in to comment.