summaryrefslogtreecommitdiffstats
path: root/lib/private/AppFramework/Utility
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-01-17 14:36:44 +0100
committerBjoern Schiessle <bjoern@schiessle.org>2017-01-18 15:25:16 +0100
commit32e0ec3e585d516749f9b1a096abb78ca3003d61 (patch)
treeaf8696d0fdf301e1f3c98143fcf9e930317d28e2 /lib/private/AppFramework/Utility
parent29a0a239183c9a2b8ab89b32b7ce5afde922159b (diff)
downloadnextcloud-server-32e0ec3e585d516749f9b1a096abb78ca3003d61.tar.gz
nextcloud-server-32e0ec3e585d516749f9b1a096abb78ca3003d61.zip
handle optional annotation parameters
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib/private/AppFramework/Utility')
-rw-r--r--lib/private/AppFramework/Utility/ControllerMethodReflector.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/private/AppFramework/Utility/ControllerMethodReflector.php b/lib/private/AppFramework/Utility/ControllerMethodReflector.php
index 9f653b0384e..034fc3a1759 100644
--- a/lib/private/AppFramework/Utility/ControllerMethodReflector.php
+++ b/lib/private/AppFramework/Utility/ControllerMethodReflector.php
@@ -56,7 +56,9 @@ class ControllerMethodReflector implements IControllerMethodReflector{
// extract everything prefixed by @ and first letter uppercase
preg_match_all('/^\h+\*\h+@(?P<annotation>[A-Z]\w+)(\h+(?P<parameter>\w+))?$/m', $docs, $matches);
- $this->annotations = $matches[1];
+ foreach($matches['annotation'] as $key => $annontation) {
+ $this->annotations[$annontation] = $matches['parameter'][$key];
+ }
// extract type parameter information
preg_match_all('/@param\h+(?P<type>\w+)\h+\$(?P<var>\w+)/', $docs, $matches);
@@ -112,7 +114,22 @@ class ControllerMethodReflector implements IControllerMethodReflector{
* @return bool true if the annotation is found
*/
public function hasAnnotation($name){
- return in_array($name, $this->annotations);
+ return array_key_exists($name, $this->annotations);
+ }
+
+
+ /**
+ * Get optional annotation parameter
+ * @param string $name the name of the annotation
+ * @return string
+ */
+ public function getAnnotationParameter($name){
+ $parameter = '';
+ if($this->hasAnnotation($name)) {
+ $parameter = $this->annotations[$name];
+ }
+
+ return $parameter;
}