@@ -70,6 +70,10 @@ public function getLine($scan)
7070 {
7171 return $ this ->content [$ i ];
7272 }
73+ else
74+ {
75+ return false ;
76+ }
7377 }
7478
7579 public function getContentIndex ($ scan , $ offset = 0 )
@@ -175,21 +179,56 @@ public function __construct($line)
175179
176180 }
177181
182+ class Constant
183+ {
184+ public $ name ; // TEXTURE_ATLAS_JSON_ARRAY, PHYSICS_PHASER_JSON, etc
185+ public $ types = []; // an array containing the one single type the const can be
186+ public $ help = [];
187+ public $ line ; // number, line number in the source file this is found on?
188+
189+ public function __construct ($ block )
190+ {
191+ // Because zero offset + allowing for final line
192+ $ this ->line = $ block ->end + 2 ;
193+
194+ // Phaser.Cache.TEXTURE = 3;
195+ $ name = $ block ->code ;
196+ $ period = strrpos ($ name , '. ' );
197+ $ equals = strrpos ($ name , '= ' );
198+
199+ if ($ period > 0 && $ equals > 0 )
200+ {
201+ $ len = $ equals - $ period - 1 ;
202+ $ name = substr ($ name , $ period + 1 , $ len );
203+ }
204+ else if ($ period > 0 )
205+ {
206+ $ name = substr ($ name , $ period + 1 , -1 );
207+ }
208+
209+ $ this ->name = trim ($ name );
210+
211+ $ line = $ block ->getLine ('@type ' );
212+
213+ if ($ line && preg_match ("/.*@type\s?{(\S*)}/ " , $ line , $ output ))
214+ {
215+ $ this ->types = explode ('| ' , $ output [1 ]);
216+ }
217+ }
218+
219+ }
220+
178221 class ReturnType
179222 {
180223 public $ types = []; // an array containing all possible types it can be: string, number, etc
181224 public $ help = [];
182225
183226 public function __construct ($ line )
184227 {
185- // echo "rt: $line \n";
186228 if (preg_match ("/.*@return\s?{(\S*)} ?(.*)/ " , $ line , $ output ))
187229 {
188230 $ this ->types = explode ('| ' , $ output [1 ]);
189231 $ this ->help = $ output [2 ];
190- // echo "rt2: " . $this->help . "\n";
191- // echo "rt3: ";
192- // print_r($this->types);
193232 }
194233 }
195234
@@ -317,7 +356,8 @@ public function __construct($block)
317356 $ properties = [];
318357 $ methods = [];
319358
320- $ file = "../src/gameobjects/Sprite.js " ;
359+ // $file = "../src/gameobjects/Sprite.js";
360+ $ file = "../src/loader/Cache.js " ;
321361
322362 $ js = file ($ file );
323363
@@ -360,6 +400,22 @@ public function __construct($block)
360400 // That's the whole file scanned, how many blocks did we get out of it?
361401 echo count ($ blocks ) . " blocks found \n\n" ;
362402
403+ echo "\nConstants: \n\n" ;
404+
405+ for ($ i = 0 ; $ i < count ($ blocks ); $ i ++)
406+ {
407+ if ($ blocks [$ i ]->isConst )
408+ {
409+ $ const = new Constant ($ blocks [$ i ]);
410+
411+ echo "\n\n" ;
412+ echo $ const ->name ;
413+ echo "\n" ;
414+ print_r ($ const ->types );
415+ // print_r($method->help);
416+ }
417+ }
418+
363419 echo "\nMethods: \n\n" ;
364420
365421 for ($ i = 0 ; $ i < count ($ blocks ); $ i ++)
0 commit comments