File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,8 @@ public function scanOperator($matches)
7171 public function scanVariable ($ matches )
7272 {
7373 $ varPrefix = $ this ->engine ->getOption ('varPrefix ' , JsPhpize::VAR_PREFIX );
74- if (substr ($ matches [0 ], 0 , 5 ) === $ varPrefix ) {
75- throw new Exception ('Variables cannot start with ' . $ varPrefix . ', this prefix is reserved for JsPhpize ' . $ this ->exceptionInfos (), 1 );
74+ if (strpos ($ matches [1 ], $ varPrefix ) === 0 ) {
75+ throw new Exception ('Variables cannot start with ' . $ varPrefix . ', this prefix is reserved for JsPhpize ' . $ this ->exceptionInfos (), 4 );
7676 }
7777
7878 return $ this ->valueToken ('variable ' , $ matches );
Original file line number Diff line number Diff line change @@ -52,4 +52,18 @@ public function testConstPrefixRestriction()
5252 var a = FOOBAR;
5353 ' );
5454 }
55+
56+ /**
57+ * @expectedException \JsPhpize\Lexer\Exception
58+ * @expectedExceptionCode 4
59+ */
60+ public function testVarPrefixRestriction ()
61+ {
62+ $ jsPhpize = new JsPhpize (array (
63+ 'varPrefix ' => 'test ' ,
64+ ));
65+ $ jsPhpize ->render ('
66+ var a = test_zz;
67+ ' );
68+ }
5569}
You can’t perform that action at this time.
0 commit comments