Skip to content

Commit 62ab5b5

Browse files
committed
Move strict types remove/adding logic in to loop
1 parent 0661f8f commit 62ab5b5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/CodePatcher.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ private function applyPatch(Patch $patch, string $code): string
9292
$statements = [];
9393
}
9494

95-
$declare = null;
96-
if ($this->isFirstStatementStrictTypesDeclare($statements)) {
97-
$declare = array_shift($statements);
98-
}
99-
10095
foreach ($patch->getModifiers() as $modifier) {
96+
$declare = null;
97+
if ($this->isFirstStatementStrictTypesDeclare($statements)) {
98+
$declare = array_shift($statements);
99+
}
100+
101101
if ($modifier instanceof CodeInsertion) {
102102
$statements = $this->applyCodeInsertion($modifier, $statements);
103103
}
@@ -109,10 +109,10 @@ private function applyPatch(Patch $patch, string $code): string
109109
if ($modifier instanceof Transformer) {
110110
$statements = $modifier->transform($statements);
111111
}
112-
}
113112

114-
if ($declare !== null && !$this->isFirstStatementStrictTypesDeclare($statements)) {
115-
array_unshift($statements, $declare);
113+
if ($declare !== null && !$this->isFirstStatementStrictTypesDeclare($statements)) {
114+
array_unshift($statements, $declare);
115+
}
116116
}
117117

118118
return $this->printer->prettyPrintFile($statements);

0 commit comments

Comments
 (0)