Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/autoloader.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
Expand Down Expand Up @@ -63,7 +64,7 @@ public function __construct(array $validRoots) {
*
* @param string $root
*/
public function addValidRoot($root) {
public function addValidRoot(string $root) {
$root = stream_resolve_include_path($root);
$this->validRoots[$root] = true;
}
Expand All @@ -86,12 +87,12 @@ public function enableGlobalClassPath() {
* 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];
/**
Expand Down Expand Up @@ -124,8 +125,9 @@ public function findClass($class) {
/**
* @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;
Expand All @@ -139,8 +141,9 @@ protected function isValidPath($fullPath) {
*
* @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);
Expand Down