Composer\Autoload

ClassLoader::setPsr4()publicWPSCache 1.0

Registers a set of PSR-4 directories for a given namespace, replacing any others previously set for this namespace.

Метод класса: ClassLoader{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$ClassLoader = new ClassLoader();
$ClassLoader->setPsr4( $prefix, $paths );
$prefix(строка) (обязательный)
The prefix/namespace, with trailing '\\'
$paths(list|строка) (обязательный)
The PSR-4 base directories

Код ClassLoader::setPsr4() WPSCache 1.12.0

public function setPsr4($prefix, $paths)
{
    if (!$prefix) {
        $this->fallbackDirsPsr4 = (array) $paths;
    } else {
        $length = strlen($prefix);
        if ('\\' !== $prefix[$length - 1]) {
            throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
        }
        $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
        $this->prefixDirsPsr4[$prefix] = (array) $paths;
    }
}