File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed
src/phpDocumentor/Reflection
tests/unit/phpDocumentor/Reflection Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ public function parseSubElements()
48
48
}
49
49
break ;
50
50
case 'PHPParser_Node_Stmt_ClassMethod ' :
51
- $ this ->methods [] = new ClassReflector \MethodReflector (
51
+ $ this ->methods [strtolower ( $ stmt -> name ) ] = new ClassReflector \MethodReflector (
52
52
$ stmt ,
53
53
$ this ->context
54
54
);
@@ -107,10 +107,12 @@ public function getMethods()
107
107
108
108
/**
109
109
* @param string $name the method name
110
- * @return ClassReflector\MethodReflector
110
+ * @return ClassReflector\MethodReflector|null
111
111
*/
112
112
public function getMethod ($ name )
113
113
{
114
- return $ this ->methods [$ name ];
114
+ $ name = strtolower ($ name );
115
+
116
+ return isset ($ this ->methods [$ name ]) ? $ this ->methods [$ name ] : null ;
115
117
}
116
118
}
Original file line number Diff line number Diff line change @@ -149,4 +149,33 @@ public function testGetInterfaces()
149
149
150
150
$ this ->assertEquals (array ('\dummy ' ), $ class_reflector ->getInterfaces ());
151
151
}
152
+
153
+ /**
154
+ * Tests the getMethod method
155
+ *
156
+ * @covers \phpDocumentor\Reflection\ClassReflector::getMethod
157
+ *
158
+ * @return void
159
+ */
160
+ public function testGetMethod ()
161
+ {
162
+ $ node = new NodeStmtMock ();
163
+ $ node ->stmts = array (new \PHPParser_Node_Stmt_ClassMethod ('someMethod ' ));
164
+ $ class_reflector = new ClassReflectorMock (
165
+ $ node ,
166
+ new Context ()
167
+ );
168
+
169
+ // Before parseSubElements
170
+ $ this ->assertNull ($ class_reflector ->getMethod ('someMethod ' ));
171
+
172
+ $ class_reflector ->parseSubElements ();
173
+
174
+ // After parseSubElements
175
+ $ this ->assertInstanceOf (
176
+ '\phpDocumentor\Reflection\ClassReflector\MethodReflector ' ,
177
+ $ class_reflector ->getMethod ('someMethod ' )
178
+ );
179
+ $ this ->assertNull ($ class_reflector ->getMethod ('someOtherMethod ' ));
180
+ }
152
181
}
You can’t perform that action at this time.
0 commit comments