Skip to content

Commit 84a4e36

Browse files
committed
[exp] Remove always-run key re-indexing on every node
1 parent fff99ae commit 84a4e36

File tree

6 files changed

+34
-8
lines changed

6 files changed

+34
-8
lines changed

rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,15 @@ public function refactor(Node $node): ?Node
8282
return null;
8383
}
8484

85+
// remove first arg
86+
$originalArgs = $node->getArgs();
87+
array_shift($originalArgs);
88+
8589
$methodCall = $this->arrayCallableToMethodCallFactory->create($firstArgValue);
8690
if (! $methodCall instanceof MethodCall) {
8791
return null;
8892
}
8993

90-
$originalArgs = $node->args;
91-
unset($originalArgs[0]);
92-
9394
$methodCall->args = $originalArgs;
9495
return $methodCall;
9596
}

rules/DeadCode/Rector/Assign/RemoveDoubleAssignRector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,17 @@ public function refactor(Node $node): ?Node
112112

113113
// remove current Stmt if will be overridden in next stmt
114114
unset($node->stmts[$key]);
115+
115116
$hasChanged = true;
116117
}
117118

118119
if (! $hasChanged) {
119120
return null;
120121
}
121122

123+
// update array keys to fit printer
124+
$node->stmts = array_values($node->stmts);
125+
122126
return $node;
123127
}
124128

rules/Php85/Rector/FuncCall/RemoveFinfoBufferContextArgRector.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function getNodeTypes(): array
5656
*/
5757
public function refactor(Node $node): ?Node
5858
{
59+
// Cannot handle variadic args
5960
if ($node->isFirstClassCallable()) {
6061
return null;
6162
}
@@ -106,13 +107,20 @@ private function removeContextArg(FuncCall|MethodCall $callLike): bool
106107

107108
unset($callLike->args[3 + $methodArgCorrection]);
108109

110+
// update indexed to make printer work as expected
111+
$callLike->args = array_values($callLike->args);
112+
109113
return true;
110114
}
111115

116+
// process named arguments
112117
foreach ($args as $position => $arg) {
113118
if ($arg->name instanceof Identifier && $this->isName($arg->name, 'context')) {
114119
unset($callLike->args[$position]);
115120

121+
// update indexed to make printer work as expected
122+
$callLike->args = array_values($callLike->args);
123+
116124
return true;
117125
}
118126
}

src/Application/ChangedNodeScopeRefresher.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ public function refresh(Node $node, string $filePath, ?MutatingScope $mutatingSc
5858
throw new ShouldNotHappenException($errorMessage);
5959
}
6060

61-
// reindex stmt_key already covered on StmtKeyNodeVisitor on next processNodes()
62-
// so set flag $reIndexStmtKey to false to avoid double loop
63-
NodeAttributeReIndexer::reIndexNodeAttributes($node, false);
64-
6561
$stmts = $this->resolveStmts($node);
6662
$this->phpStanNodeScopeResolver->processNodes($stmts, $filePath, $mutatingScope);
6763
}

src/NodeTypeResolver/Node/AttributeKey.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ final class AttributeKey
163163

164164
/**
165165
* @deprecated This value can change, as based on default input keys. Use existing array keys instead.
166-
*
167166
* @var string
168167
*/
169168
public const STMT_KEY = 'stmt_key';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use shop\product\business\ProductFilter;
6+
7+
class NamespacedAfterTernaryToNullCoalesce
8+
{
9+
private function sharedProductFilter(): void
10+
{
11+
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
12+
13+
$this->brands = Hersteller::getListForProducts(new \ProductFilter());
14+
}
15+
16+
}
17+
18+
?>

0 commit comments

Comments
 (0)