File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ public function compile($input, $filename = null)
7878
7979 $ dependencies = $ compiler ->getDependencies ();
8080 if ($ this ->getOption ('catchDependencies ' )) {
81- $ this ->dependencies = array_merge ($ this ->dependencies , $ dependencies );
81+ $ this ->dependencies = array_unique ( array_merge ($ this ->dependencies , $ dependencies) );
8282 $ dependencies = array ();
8383 }
8484
Original file line number Diff line number Diff line change @@ -48,6 +48,30 @@ public function testCompileWithoutDependencies()
4848 $ this ->assertSame ($ expected , $ actual );
4949 }
5050
51+ public function testDependenciesGrouping ()
52+ {
53+ $ jsPhpize = new JsPhpize (array (
54+ 'catchDependencies ' => true ,
55+ ));
56+ $ jsPhpize ->compileCode ("a = 4 + 5; \n b = '9' + '3' " );
57+ $ jsPhpize ->compileCode ('4 + 5 ' );
58+ $ jsPhpize ->compileCode ('4 + 5 + 9 ' );
59+ $ jsPhpize ->compileCode ('a.b.c ' );
60+ $ jsPhpize ->compileCode ("a.b(); \nc = a.c " );
61+ $ jsPhpize ->compileCode ('a.b ' );
62+ $ jsPhpize ->compileCode ('a.b ' );
63+
64+ $ this ->assertSame (1 , mb_substr_count (
65+ $ jsPhpize ->compileDependencies (),
66+ '$GLOBALS[ \'__jpv_dot \'] = function ($base) { '
67+ ));
68+
69+ $ this ->assertSame (1 , mb_substr_count (
70+ $ jsPhpize ->compileDependencies (),
71+ '$GLOBALS[ \'__jpv_plus \'] = function ($base) { '
72+ ));
73+ }
74+
5175 public function testTruncatedCode ()
5276 {
5377 $ jsPhpize = new JsPhpize (array (
You can’t perform that action at this time.
0 commit comments