diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2018-02-19 10:50:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-19 10:50:38 +0100 |
commit | bffdcd76f081b16cffe85001dab339bfe57cd267 (patch) | |
tree | 7a2b1a6f00aca6c12a795ade3e06a1cc0e1cd508 /lib | |
parent | 9c33ebad5d4fc930bb2fc05f31306954e44d1cac (diff) | |
parent | 5819e5e5b33ccfc9060ff92a428cf7815e551caa (diff) | |
download | nextcloud-server-bffdcd76f081b16cffe85001dab339bfe57cd267.tar.gz nextcloud-server-bffdcd76f081b16cffe85001dab339bfe57cd267.zip |
Merge pull request #8334 from nextcloud/lib-strict-typing
Make lib/autoloader.php strictly typed and p…
Diffstat (limited to 'lib')
-rw-r--r-- | lib/autoloader.php | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/autoloader.php b/lib/autoloader.php index efab84b44f9..eca326ffc14 100644 --- a/lib/autoloader.php +++ b/lib/autoloader.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -63,7 +64,7 @@ class Autoloader { * * @param string $root */ - public function addValidRoot($root) { + public function addValidRoot(string $root) { $root = stream_resolve_include_path($root); $this->validRoots[$root] = true; } @@ -86,12 +87,12 @@ class Autoloader { * get the possible paths for a class * * @param string $class - * @return array|bool an array of possible paths or false if the class is not part of ownCloud + * @return array an array of possible paths */ - public function findClass($class) { + public function findClass(string $class): array { $class = trim($class, '\\'); - $paths = array(); + $paths = []; if ($this->useGlobalClassPath && array_key_exists($class, \OC::$CLASSPATH)) { $paths[] = \OC::$CLASSPATH[$class]; /** @@ -124,8 +125,9 @@ class Autoloader { /** * @param string $fullPath * @return bool + * @throws AutoloadNotAllowedException */ - protected function isValidPath($fullPath) { + protected function isValidPath(string $fullPath): bool { foreach ($this->validRoots as $root => $true) { if (substr($fullPath, 0, strlen($root) + 1) === $root . '/') { return true; @@ -139,8 +141,9 @@ class Autoloader { * * @param string $class * @return bool + * @throws AutoloadNotAllowedException */ - public function load($class) { + public function load(string $class): bool { $pathsToRequire = null; if ($this->memoryCache) { $pathsToRequire = $this->memoryCache->get($class); |