Skip to content

Commit 97a7618

Browse files
committed
Avoid double return statement
1 parent e740477 commit 97a7618

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/JsPhpize/Compiler/Compiler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,10 @@ protected function visitInstruction(Instruction $group, $indent)
328328
return $indent .
329329
($instruction instanceof Block && $instruction->handleInstructions()
330330
? $value
331-
: ($isReturnPrepended ? ' return ' : '') . $value . ';'
331+
: ($isReturnPrepended && !preg_match('/^\s*return(?![a-zA-Z0-9_])/', $value)
332+
? ' return '
333+
: ''
334+
) . $value . ';'
332335
) .
333336
"\n";
334337
}, $group->instructions));

0 commit comments

Comments
 (0)