@@ -44,16 +44,19 @@ public function read(\ReflectionClass $reflection, $method)
4444 throw new \InvalidArgumentException (sprintf ("Class '%s' has no method '%s' method. " , $ reflection ->getName (), $ method ));
4545 }
4646
47- return $ this ->getParamsFromMethod ($ reflection ->getMethod ($ method ));
47+ $ methodParams = $ this ->getParamsFromMethod ($ reflection ->getMethod ($ method ));
48+ $ classParams = $ this ->getParamsFromClass ($ reflection );
49+ return array_merge ($ methodParams , $ classParams );
4850 }
49-
51+
5052 /**
51- * {@inheritDoc}
53+ * Fetches parameters from provided annotation array (fetched from annotationReader)
54+ *
55+ * @param array $annotations
56+ * @return \FOS\RestBundle\Controller\Annotations\Param
5257 */
53- public function getParamsFromMethod ( \ ReflectionMethod $ method )
58+ private function getParamsFromAnnotationArray ( array $ annotations )
5459 {
55- $ annotations = $ this ->annotationReader ->getMethodAnnotations ($ method );
56-
5760 $ params = array ();
5861 foreach ($ annotations as $ annotation ) {
5962 if ($ annotation instanceof Param) {
@@ -63,4 +66,25 @@ public function getParamsFromMethod(\ReflectionMethod $method)
6366
6467 return $ params ;
6568 }
69+
70+ /**
71+ * {@inheritDoc}
72+ */
73+ public function getParamsFromMethod (\ReflectionMethod $ method )
74+ {
75+ $ annotations = $ this ->annotationReader ->getMethodAnnotations ($ method );
76+
77+ return $ this ->getParamsFromAnnotationArray ($ annotations );
78+ }
79+
80+ /**
81+ *
82+ * {@inheritDoc}
83+ */
84+ public function getParamsFromClass (\ReflectionClass $ class )
85+ {
86+ $ annotations = $ this ->annotationReader ->getClassAnnotations ($ class );
87+
88+ return $ this ->getParamsFromAnnotationArray ($ annotations );
89+ }
6690}
0 commit comments