Skip to content

Commit d61fc49

Browse files
authored
Merge pull request #230 from samsonasik/use-key
Clean up loop to get key of stmts on ImplementsFactoryInterfaceToPsrFactoryRector
2 parents 2901c29 + d3e51f1 commit d61fc49

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

src/Rector/Class_/ImplementsFactoryInterfaceToPsrFactoryRector.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private function replaceUseInteropStatementOnAutoImportEnabled(
178178
/** @var Use_[] $uses */
179179
$uses = array_filter($namespace->stmts, fn (Stmt $stmt): bool => $stmt instanceof Use_);
180180

181-
foreach ($uses as $use) {
181+
foreach ($uses as $stmtKey => $use) {
182182
/** @var UseItem|false $useUse */
183183
$useUse = current($use->uses);
184184

@@ -191,12 +191,7 @@ private function replaceUseInteropStatementOnAutoImportEnabled(
191191
}
192192

193193
if ($useUse->name->toString() === 'Interop\Container\ContainerInterface') {
194-
foreach ($namespace->stmts as $stmtKey => $stmt) {
195-
if ($stmt === $use) {
196-
unset($namespace->stmts[$stmtKey]);
197-
return $namespace;
198-
}
199-
}
194+
unset($namespace->stmts[$stmtKey]);
200195
}
201196
}
202197

0 commit comments

Comments
 (0)