Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-12-28 12:21:14 +0300
committerThomas Müller <thomas.mueller@tmit.eu>2015-12-28 12:21:14 +0300
commiteb509bcbe6d6b97133a7b4dfba81325e92500aed (patch)
treeea48a8a74bf2c11b774ca40242d7c774703e9824 /lib
parent245dac7e81e0192a4de7e51652c94b19f036a2ed (diff)
parentb2df7b6b8ae420766f1ce0a7b22e153f9ee1b23e (diff)
Merge pull request #17333 from owncloud/php7-scalar-types-controllers
Prefer scalar type hints over phpdoc annotation
Diffstat (limited to 'lib')
-rw-r--r--lib/private/appframework/utility/controllermethodreflector.php22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/private/appframework/utility/controllermethodreflector.php b/lib/private/appframework/utility/controllermethodreflector.php
index 63cf5ac24f0..1118332f930 100644
--- a/lib/private/appframework/utility/controllermethodreflector.php
+++ b/lib/private/appframework/utility/controllermethodreflector.php
@@ -60,16 +60,18 @@ class ControllerMethodReflector implements IControllerMethodReflector{
// extract type parameter information
preg_match_all('/@param\h+(?P<type>\w+)\h+\$(?P<var>\w+)/', $docs, $matches);
- // this is just a fix for PHP 5.3 (array_combine raises warning if called with
- // two empty arrays
- if($matches['var'] === array() && $matches['type'] === array()) {
- $this->types = array();
- } else {
- $this->types = array_combine($matches['var'], $matches['type']);
- }
+ $this->types = array_combine($matches['var'], $matches['type']);
- // get method parameters
foreach ($reflection->getParameters() as $param) {
+ // extract type information from PHP 7 scalar types and prefer them
+ // over phpdoc annotations
+ if (method_exists($param, 'getType')) {
+ $type = $param->getType();
+ if ($type !== null) {
+ $this->types[$param->getName()] = (string) $type;
+ }
+ }
+
if($param->isOptional()) {
$default = $param->getDefaultValue();
} else {
@@ -82,9 +84,9 @@ class ControllerMethodReflector implements IControllerMethodReflector{
/**
* Inspects the PHPDoc parameters for types
- * @param string $parameter the parameter whose type comments should be
+ * @param string $parameter the parameter whose type comments should be
* parsed
- * @return string|null type in the type parameters (@param int $something)
+ * @return string|null type in the type parameters (@param int $something)
* would return int or null if not existing
*/
public function getType($parameter) {