@@ -69,7 +69,7 @@ public function parse($source, $path)
6969 {
7070 $ index = array ();
7171
72- $ annotations = array ();
72+ $ docblocks = array ();
7373 $ state = self ::SCAN ;
7474 $ nesting = 0 ;
7575 $ class = null ;
@@ -154,8 +154,8 @@ public function parse($source, $path)
154154 case self ::CLASS_NAME :
155155 if ($ type == T_STRING ) {
156156 $ class = ($ namespace ? $ namespace . '\\' : '' ) . $ str ;
157- $ index [$ class ] = $ annotations ;
158- $ annotations = array ();
157+ $ index [$ class ] = $ docblocks ;
158+ $ docblocks = array ();
159159 $ state = self ::SCAN_CLASS ;
160160 }
161161 break ;
@@ -171,8 +171,8 @@ public function parse($source, $path)
171171
172172 case self ::MEMBER :
173173 if ($ type == T_VARIABLE ) {
174- $ index [$ class . ':: ' . $ str ] = $ annotations ;
175- $ annotations = array ();
174+ $ index [$ class . ':: ' . $ str ] = $ docblocks ;
175+ $ docblocks = array ();
176176 $ state = self ::SCAN_CLASS ;
177177 }
178178 if ($ type == T_FUNCTION ) {
@@ -182,8 +182,8 @@ public function parse($source, $path)
182182
183183 case self ::METHOD_NAME :
184184 if ($ type == T_STRING ) {
185- $ index [$ class . ':: ' . $ str ] = $ annotations ;
186- $ annotations = array ();
185+ $ index [$ class . ':: ' . $ str ] = $ docblocks ;
186+ $ docblocks = array ();
187187 $ state = self ::SCAN_CLASS ;
188188 }
189189 break ;
@@ -206,7 +206,7 @@ public function parse($source, $path)
206206 }
207207
208208 if ($ type == T_COMMENT || $ type == T_DOC_COMMENT ) {
209- $ annotations = array_merge ( $ annotations , $ this -> findAnnotations ( $ str)) ;
209+ $ docblocks [] = $ str ;
210210 }
211211
212212 if ($ type == T_CURLY_OPEN ) {
@@ -223,14 +223,16 @@ public function parse($source, $path)
223223 echo '</table> ' ;
224224 }
225225
226- if (count ($ annotations )) {
227- throw new AnnotationException ("Orphaned annotation(s) found at end of a file {$ path }: " . implode (", \r" , $ annotations ));
228- }
226+ unset($ docblocks );
229227
230228 $ code = "return array( \n" ;
231229 $ code .= " '#namespace' => " . var_export ($ namespace , true ) . ", \n" ;
232230 $ code .= " '#uses' => " . var_export ($ uses , true ) . ", \n" ;
233- foreach ($ index as $ key => $ array ) {
231+ foreach ($ index as $ key => $ docblocks ) {
232+ $ array = array ();
233+ foreach ($ docblocks as $ str ) {
234+ $ array = array_merge ($ array , $ this ->findAnnotations ($ str ));
235+ }
234236 if (count ($ array )) {
235237 $ code .= " " . trim (var_export ($ key , true )) . " => array( \n " . implode (
236238 ", \n " ,
0 commit comments