summaryrefslogtreecommitdiffstats
path: root/lib/private/AppFramework
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-02-21 14:06:51 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2018-02-21 19:55:49 +0100
commitaa060f5332ecabbd94cc1511c0b254a30cc7beb6 (patch)
tree156f1a91f07f34560c5c43eed8301593386c4772 /lib/private/AppFramework
parent7c6cc013ebec7bbdecbf9f5567d620fcfbb37212 (diff)
downloadnextcloud-server-aa060f5332ecabbd94cc1511c0b254a30cc7beb6.tar.gz
nextcloud-server-aa060f5332ecabbd94cc1511c0b254a30cc7beb6.zip
Strict OCP\AppFramework\Utility\IControllerMethodReflector
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/AppFramework')
-rw-r--r--lib/private/AppFramework/Utility/ControllerMethodReflector.php20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/private/AppFramework/Utility/ControllerMethodReflector.php b/lib/private/AppFramework/Utility/ControllerMethodReflector.php
index 7c777c52c12..0f9d406ab73 100644
--- a/lib/private/AppFramework/Utility/ControllerMethodReflector.php
+++ b/lib/private/AppFramework/Utility/ControllerMethodReflector.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -42,7 +43,7 @@ class ControllerMethodReflector implements IControllerMethodReflector {
* @param object $object an object or classname
* @param string $method the method which we want to inspect
*/
- public function reflect($object, $method){
+ public function reflect($object, string $method){
$reflection = new \ReflectionMethod($object, $method);
$docs = $reflection->getDocComment();
@@ -50,7 +51,7 @@ class ControllerMethodReflector implements IControllerMethodReflector {
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] === ')') {
+ if(isset($annotationValue[0]) && $annotationValue[0] === '(' && $annotationValue[\strlen($annotationValue) - 1] === ')') {
$cutString = substr($annotationValue, 1, -1);
$cutString = str_replace(' ', '', $cutString);
$splittedArray = explode(',', $cutString);
@@ -78,10 +79,9 @@ class ControllerMethodReflector implements IControllerMethodReflector {
}
}
+ $default = null;
if($param->isOptional()) {
$default = $param->getDefaultValue();
- } else {
- $default = null;
}
$this->parameters[$param->name] = $default;
}
@@ -94,18 +94,18 @@ class ControllerMethodReflector implements IControllerMethodReflector {
* @return string|null type in the type parameters (@param int $something)
* would return int or null if not existing
*/
- public function getType($parameter) {
+ public function getType(string $parameter) {
if(array_key_exists($parameter, $this->types)) {
return $this->types[$parameter];
- } else {
- return null;
}
+
+ return null;
}
/**
* @return array the arguments of the method with key => default value
*/
- public function getParameters() {
+ public function getParameters(): array {
return $this->parameters;
}
@@ -114,7 +114,7 @@ class ControllerMethodReflector implements IControllerMethodReflector {
* @param string $name the name of the annotation
* @return bool true if the annotation is found
*/
- public function hasAnnotation($name) {
+ public function hasAnnotation(string $name): bool {
return array_key_exists($name, $this->annotations);
}
@@ -125,7 +125,7 @@ class ControllerMethodReflector implements IControllerMethodReflector {
* @param string $key the string of the annotation
* @return string
*/
- public function getAnnotationParameter($name, $key) {
+ public function getAnnotationParameter(string $name, string $key): string {
if(isset($this->annotations[$name][$key])) {
return $this->annotations[$name][$key];
}