diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-02-21 20:38:14 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-02-21 20:38:14 +0100 |
commit | 48597758938f474579f9ff1b21884f6bfb7c8c8f (patch) | |
tree | 8ebf46cd726b409125602048a08db94ce89e4260 /lib/private/AppFramework/Utility | |
parent | aa060f5332ecabbd94cc1511c0b254a30cc7beb6 (diff) | |
download | nextcloud-server-48597758938f474579f9ff1b21884f6bfb7c8c8f.tar.gz nextcloud-server-48597758938f474579f9ff1b21884f6bfb7c8c8f.zip |
Don't try to match on false
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/AppFramework/Utility')
-rw-r--r-- | lib/private/AppFramework/Utility/ControllerMethodReflector.php | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/lib/private/AppFramework/Utility/ControllerMethodReflector.php b/lib/private/AppFramework/Utility/ControllerMethodReflector.php index 0f9d406ab73..ef4a1959d66 100644 --- a/lib/private/AppFramework/Utility/ControllerMethodReflector.php +++ b/lib/private/AppFramework/Utility/ControllerMethodReflector.php @@ -47,28 +47,30 @@ class ControllerMethodReflector implements IControllerMethodReflector { $reflection = new \ReflectionMethod($object, $method); $docs = $reflection->getDocComment(); - // extract everything prefixed by @ and first letter uppercase - preg_match_all('/^\h+\*\h+@(?P<annotation>[A-Z]\w+)((?P<parameter>.*))?$/m', $docs, $matches); - foreach($matches['annotation'] as $key => $annontation) { - $annotationValue = $matches['parameter'][$key]; - if(isset($annotationValue[0]) && $annotationValue[0] === '(' && $annotationValue[\strlen($annotationValue) - 1] === ')') { - $cutString = substr($annotationValue, 1, -1); - $cutString = str_replace(' ', '', $cutString); - $splittedArray = explode(',', $cutString); - foreach($splittedArray as $annotationValues) { - list($key, $value) = explode('=', $annotationValues); - $this->annotations[$annontation][$key] = $value; + if ($docs !== false) { + // extract everything prefixed by @ and first letter uppercase + preg_match_all('/^\h+\*\h+@(?P<annotation>[A-Z]\w+)((?P<parameter>.*))?$/m', $docs, $matches); + foreach ($matches['annotation'] as $key => $annontation) { + $annotationValue = $matches['parameter'][$key]; + if (isset($annotationValue[0]) && $annotationValue[0] === '(' && $annotationValue[\strlen($annotationValue) - 1] === ')') { + $cutString = substr($annotationValue, 1, -1); + $cutString = str_replace(' ', '', $cutString); + $splittedArray = explode(',', $cutString); + foreach ($splittedArray as $annotationValues) { + list($key, $value) = explode('=', $annotationValues); + $this->annotations[$annontation][$key] = $value; + } + continue; } - continue; + + $this->annotations[$annontation] = [$annotationValue]; } - $this->annotations[$annontation] = [$annotationValue]; + // extract type parameter information + preg_match_all('/@param\h+(?P<type>\w+)\h+\$(?P<var>\w+)/', $docs, $matches); + $this->types = array_combine($matches['var'], $matches['type']); } - // extract type parameter information - preg_match_all('/@param\h+(?P<type>\w+)\h+\$(?P<var>\w+)/', $docs, $matches); - $this->types = array_combine($matches['var'], $matches['type']); - foreach ($reflection->getParameters() as $param) { // extract type information from PHP 7 scalar types and prefer them // over phpdoc annotations |