@@ -158,17 +158,7 @@ private function scanFile() {
158158 $ this ->corrupted = true ;
159159 }
160160
161- // Alphabetically sort the arrays based on the key
162- ksort ($ this ->consts );
163-
164- ksort ($ this ->methods ['public ' ]);
165- ksort ($ this ->methods ['protected ' ]);
166- ksort ($ this ->methods ['private ' ]);
167- ksort ($ this ->methods ['static ' ]);
168-
169- ksort ($ this ->properties ['public ' ]);
170- ksort ($ this ->properties ['protected ' ]);
171- ksort ($ this ->properties ['private ' ]);
161+ $ this ->sortArrays ();
172162
173163 }
174164
@@ -177,28 +167,9 @@ public function getPublicProperties()
177167 return $ this ->properties ['public ' ];
178168 }
179169
180- public function getPublicMethods ($ exclude = null )
170+ public function getPublicMethods ()
181171 {
182- if (is_array ($ exclude ))
183- {
184- // Get everything not already in the given array
185- $ output = [];
186-
187- foreach ($ this ->methods as $ key => $ value )
188- {
189- if (!array_key_exists ($ key , $ exclude ))
190- {
191- $ output [$ key ] = $ value ;
192- }
193- }
194-
195- return $ output ;
196- }
197- else
198- {
199- return $ this ->methods ['public ' ];
200- }
201-
172+ return $ this ->methods ['public ' ];
202173 }
203174
204175 public function getArray ()
@@ -212,14 +183,52 @@ public function getArray()
212183 $ consts [] = $ value ->getArray ();
213184 }
214185
215- foreach ($ this ->methods as $ key => $ value )
186+ // Methods
187+
188+ $ methods ['public ' ] = [];
189+ $ methods ['protected ' ] = [];
190+ $ methods ['private ' ] = [];
191+ $ methods ['static ' ] = [];
192+
193+ foreach ($ this ->methods ['public ' ] as $ key => $ value )
194+ {
195+ $ methods ['public ' ][] = $ value ->getArray ();
196+ }
197+
198+ foreach ($ this ->methods ['protected ' ] as $ key => $ value )
199+ {
200+ $ methods ['protected ' ][] = $ value ->getArray ();
201+ }
202+
203+ foreach ($ this ->methods ['private ' ] as $ key => $ value )
216204 {
217- $ methods [] = $ value ->getArray ();
205+ $ methods [' private ' ][ ] = $ value ->getArray ();
218206 }
219207
220- foreach ($ this ->properties as $ key => $ value )
208+ foreach ($ this ->methods [ ' static ' ] as $ key => $ value )
221209 {
222- $ properties [] = $ value ->getArray ();
210+ $ methods ['static ' ][] = $ value ->getArray ();
211+ }
212+
213+ // Properties
214+
215+ $ properties ['public ' ] = [];
216+ $ properties ['protected ' ] = [];
217+ $ properties ['private ' ] = [];
218+
219+ foreach ($ this ->properties ['public ' ] as $ key => $ value )
220+ {
221+ $ properties ['public ' ][] = $ value ->getArray ();
222+ }
223+
224+ foreach ($ this ->properties ['protected ' ] as $ key => $ value )
225+ {
226+ $ properties ['protected ' ][] = $ value ->getArray ();
227+ }
228+
229+ foreach ($ this ->properties ['private ' ] as $ key => $ value )
230+ {
231+ $ properties ['private ' ][] = $ value ->getArray ();
223232 }
224233
225234 return array (
@@ -253,7 +262,6 @@ public function extend()
253262 // Quick bailout
254263 if (!$ this ->class ->extendsFrom ())
255264 {
256- echo "quick bailout \n" ;
257265 return ;
258266 }
259267
@@ -263,53 +271,87 @@ public function extend()
263271 {
264272 $ extends = $ proc ->class ->extends ;
265273 $ proc = $ this ->docgen ->get ($ extends );
266- echo "\n\nextend found: " . $ proc ->getName () . "\n" ;
274+ // echo "\n\nextend found: " . $proc->getName() . "\n";
267275
268276 $ this ->merge ($ proc );
269277 }
270278 while ($ proc ->class ->extendsFrom ());
271279
280+ $ this ->sortArrays ();
281+
272282 }
273283
274- public function merge ($ processor )
284+ public function sortArrays ()
285+ {
286+ // Alphabetically sort the arrays based on the key
287+ ksort ($ this ->consts );
288+
289+ ksort ($ this ->methods ['public ' ]);
290+ ksort ($ this ->methods ['protected ' ]);
291+ ksort ($ this ->methods ['private ' ]);
292+ ksort ($ this ->methods ['static ' ]);
293+
294+ ksort ($ this ->properties ['public ' ]);
295+ ksort ($ this ->properties ['protected ' ]);
296+ ksort ($ this ->properties ['private ' ]);
297+ }
298+
299+ public function getMethodNames ()
300+ {
301+ $ output = [];
302+
303+ foreach ($ this ->methods ['public ' ] as $ key => $ method )
304+ {
305+ $ output [$ method ->name ] = true ;
306+ }
307+
308+ return $ output ;
309+ }
310+
311+ public function getPropertyNames ()
275312 {
276- echo "Merging ... \n\n" ;
313+ $ output = [];
314+
315+ foreach ($ this ->properties ['public ' ] as $ key => $ property )
316+ {
317+ $ output [$ property ->name ] = true ;
318+ }
277319
320+ return $ output ;
321+ }
322+
323+ public function merge ($ processor )
324+ {
278325 // We only want to merge in public methods and properties.
279326 // Technically JavaScript merges in bloody everything, but for the sake of docs we'll keep them #public# only.
280327
281- echo "Methods \n" ;
282- echo "------- \n" ;
283-
284- $ inheritedMethods = $ processor ->getPublicMethods ($ this ->getPublicMethods ());
328+ $ inheritedMethods = $ processor ->getPublicMethods ();
329+ $ currentMethods = $ this ->getMethodNames ();
285330
286331 // Flag them as inherited
287332 foreach ($ inheritedMethods as $ key => $ method )
288333 {
289- echo $ method ->name . "\n" ;
290- $ method ->inherited = true ;
291- $ method ->inheritedFrom = $ processor ->getName ();
334+ if (!array_key_exists ($ method ->name , $ currentMethods ))
335+ {
336+ $ method ->inherited = true ;
337+ $ method ->inheritedFrom = $ processor ->getName ();
338+ $ this ->methods ['public ' ][$ method ->name ] = $ method ;
339+ }
292340 }
293341
294- // We should only merge methods not already defined
295- $ this ->methods ['public ' ] = array_merge ($ this ->methods ['public ' ], $ inheritedMethods );
296-
297- echo "\n" ;
298- echo "Properties \n" ;
299- echo "---------- \n" ;
300-
301342 $ inheritedProperties = $ processor ->getPublicProperties ();
343+ $ currentProperties = $ this ->getPropertyNames ();
302344
303345 // Flag them as inherited!
304346 foreach ($ inheritedProperties as $ key => $ property )
305347 {
306- echo $ property ->name . "\n" ;
307- $ property ->inherited = true ;
308- $ property ->inheritedFrom = $ processor ->getName ();
348+ if (!array_key_exists ($ property ->name , $ currentProperties ))
349+ {
350+ $ property ->inherited = true ;
351+ $ property ->inheritedFrom = $ processor ->getName ();
352+ $ this ->properties ['public ' ][$ property ->name ] = $ property ;
353+ }
309354 }
310-
311- $ this ->properties ['public ' ] = array_merge ($ this ->properties ['public ' ], $ inheritedProperties );
312-
313355 }
314356
315357 /**
0 commit comments