File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 77use mindplay \annotations \AnnotationManager ;
88use mindplay \annotations \Annotations ;
99use mindplay \annotations \Annotation ;
10+ use mindplay \annotations \standard \ReturnAnnotation ;
1011use mindplay \test \annotations \Package ;
1112use mindplay \test \lib \xTest ;
1213use mindplay \test \lib \xTestRunner ;
@@ -811,6 +812,22 @@ public function testMalformedParamAnnotationThrowsException()
811812 Annotations::ofMethod ('BrokenParamAnnotationClass ' , 'brokenParamAnnotation ' );
812813 }
813814
815+ protected function testOrphanedAnnotationsAreIgnored ()
816+ {
817+ $ manager = new AnnotationManager ();
818+ $ manager ->namespace = 'mindplay\test\Sample ' ;
819+ $ manager ->cache = false ;
820+
821+ /** @var Annotation[] $annotations */
822+ $ annotations = $ manager ->getMethodAnnotations ('mindplay\test\Sample\OrphanedAnnotations ' , 'someMethod ' );
823+
824+ $ this ->check (count ($ annotations ) == 1 , 'the @return annotation was found ' );
825+ $ this ->check (
826+ $ annotations [0 ] instanceof ReturnAnnotation,
827+ 'the @return annotation has correct type '
828+ );
829+ }
830+
814831}
815832
816833return new AnnotationsTest ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace mindplay \test \Sample ;
4+
5+ class OrphanedAnnotations
6+ {
7+
8+ /**
9+ * Some method.
10+ *
11+ * @return void
12+ */
13+ public function someMethod ()
14+ {
15+ $ a = 5 ;
16+
17+ // @codeCoverageIgnoreStart
18+ if (false ) {
19+ $ a = 6 ;
20+ }
21+ // @codeCoverageIgnoreEnd
22+
23+ $ a = 5 ;
24+ }
25+
26+ }
You can’t perform that action at this time.
0 commit comments