Skip to content

Commit 0d90f46

Browse files
committed
Allow to omit semi-colons, use "strict" => true to forbid
1 parent 92ed97a commit 0d90f46

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

examples/single-line.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var counter = function() { return [count++, count++, count++] }

examples/single-line.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$counter = function () {
2+
return array( $count++, $count++, $count++ );
3+
};

src/JsPhpize/Parser/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ protected function parseInstructions($block)
381381
continue;
382382
}
383383

384-
if ($token->is(';')) {
384+
if ($token->is(';') || !$this->engine->getOption('strict')) {
385385
$block->endInstruction();
386386

387387
continue;

tests/unexpectedTokens.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ public function testBadLet()
9090
*/
9191
public function testUnexpectedInBlock()
9292
{
93-
$jsPhpize = new JsPhpize();
93+
$jsPhpize = new JsPhpize(array(
94+
'strict' => true,
95+
));
9496
$jsPhpize->render('a = true; )');
9597
}
9698
}

0 commit comments

Comments
 (0)