@@ -30,6 +30,7 @@ class Block
3030
3131 public $ isProperty = false ;
3232 public $ isMethod = false ;
33+ public $ isConst = false ;
3334
3435 public function __construct ($ start , $ end , $ code , $ content )
3536 {
@@ -43,6 +44,7 @@ public function __construct($start, $end, $code, $content)
4344
4445 $ this ->isProperty = $ this ->getTypeBoolean ('@property ' );
4546 $ this ->isMethod = $ this ->getTypeBoolean ('@method ' );
47+ $ this ->isConst = $ this ->getTypeBoolean ('@constant ' );
4648 }
4749
4850 public function getTypeBoolean ($ scan )
@@ -173,14 +175,33 @@ public function __construct($line)
173175
174176 }
175177
178+ class ReturnType
179+ {
180+ public $ types = []; // an array containing all possible types it can be: string, number, etc
181+ public $ help = [];
182+
183+ public function __construct ($ line )
184+ {
185+ // echo "rt: $line \n";
186+ if (preg_match ("/.*@return\s?{(\S*)} ?(.*)/ " , $ line , $ output ))
187+ {
188+ $ this ->types = explode ('| ' , $ output [1 ]);
189+ $ this ->help = $ output [2 ];
190+ // echo "rt2: " . $this->help . "\n";
191+ // echo "rt3: ";
192+ // print_r($this->types);
193+ }
194+ }
195+
196+ }
197+
176198 class Method
177199 {
178200 public $ line ; // number, line number in the source file this is found on?
179201 public $ name ; // bringToTop, kill, etc
180202 public $ parameters = []; // an array containing the parameters
181203 public $ help = [];
182- public $ returnType = '' ;
183- public $ returnHelp = '' ;
204+ public $ returns = false ;
184205
185206 public $ isPublic = true ;
186207 public $ isProtected = false ;
@@ -209,9 +230,6 @@ public function __construct($block)
209230 $ this ->parameters [] = new Parameter ($ params [$ i ]);
210231 }
211232
212- // parameter match
213- // preg_match("/.*(@param)\s?{(\S*)} (\S*)( - ?)?(.*)/", $block->getLine('@property'), $output);
214-
215233 if ($ block ->getTypeBoolean ('@protected ' ))
216234 {
217235 $ this ->isPublic = false ;
@@ -225,6 +243,11 @@ public function __construct($block)
225243
226244 $ this ->help = $ block ->cleanContent ();
227245
246+ if ($ block ->getTypeBoolean ('@return ' ))
247+ {
248+ $ this ->returns = new ReturnType ($ block ->getLine ('@return ' ));
249+ }
250+
228251 }
229252
230253 }
@@ -242,6 +265,8 @@ class Property
242265 public $ isProtected = false ;
243266 public $ isPrivate = false ;
244267
268+ public $ isReadOnly = false ;
269+
245270 public function __construct ($ block )
246271 {
247272 // Because zero offset + allowing for final line
@@ -276,6 +301,11 @@ public function __construct($block)
276301
277302 $ this ->help = $ block ->cleanContent ();
278303
304+ if ($ block ->getTypeBoolean ('@readonly ' ))
305+ {
306+ $ this ->isReadOnly = true ;
307+ }
308+
279309 }
280310
281311 }
@@ -338,10 +368,12 @@ public function __construct($block)
338368 {
339369 $ method = new Method ($ blocks [$ i ]);
340370
341- echo $ method ->name . "\n" ;
342- echo "Help: " . "\n" ;
343- // print_r($method->help);
371+ echo "\n\n" ;
372+ echo $ method ->name ;
373+ echo "\n" ;
374+ print_r ($ method ->help );
344375 print_r ($ method ->parameters );
376+ print_r ($ method ->returns );
345377 }
346378 }
347379
0 commit comments