WordPress at Your Fingertips
function is not described


ClassLoader::setPsr4() public WC 1.0

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

{} It's a method of the class: ClassLoader{}

No Hooks.


null. Nothing.


$ClassLoader = new ClassLoader();
$ClassLoader->setPsr4( $prefix, $paths );
$prefix(string) (required)
The prefix/namespace, with trailing '\\'
$paths(array|string) (required)
The PSR-4 base directories

Code of ClassLoader::setPsr4() WC 5.5.2

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;