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
118 changes: 116 additions & 2 deletions src/StaticConstructorLoader/StaticConstructorLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @author Dmitrijs Balabka <[email protected]>
*/
final class StaticConstructorLoader
final class StaticConstructorLoader extends ClassLoader /* extending for an contract */
{
/**
* @var ClassLoader
Expand Down Expand Up @@ -53,12 +53,126 @@ public function __construct(ClassLoader $classLoader)
array_map('spl_autoload_register', $loadersToRestore, $flagTrue, $flagTrue);
}

public function loadClass(string $className): ?bool
public function loadClass($className): ?bool
{
$result = $this->classLoader->loadClass($className);
if ($result === true && $className !== StaticConstructorInterface::class && is_a($className, StaticConstructorInterface::class, true)) {
$className::__constructStatic();
}
return $result;
}

/** @codeCoverageIgnore */
public function getPrefixes()
{
return $this->classLoader->getPrefixes();
}

/** @codeCoverageIgnore */
public function getPrefixesPsr4()
{
return $this->classLoader->getPrefixesPsr4();
}

/** @codeCoverageIgnore */
public function getFallbackDirs()
{
return $this->classLoader->getFallbackDirs();
}

/** @codeCoverageIgnore */
public function getFallbackDirsPsr4()
{
return $this->classLoader->getFallbackDirsPsr4();
}

/** @codeCoverageIgnore */
public function getClassMap()
{
return $this->classLoader->getClassMap();
}

/** @codeCoverageIgnore */
public function addClassMap(array $classMap)
{
$this->classLoader->addClassMap($classMap);
}

/** @codeCoverageIgnore */
public function add($prefix, $paths, $prepend = false)
{
$this->classLoader->add($prefix, $paths, $prepend);
}

/** @codeCoverageIgnore */
public function addPsr4($prefix, $paths, $prepend = false)
{
$this->classLoader->addPsr4($prefix, $paths, $prepend);
}

/** @codeCoverageIgnore */
public function set($prefix, $paths)
{
$this->classLoader->set($prefix, $paths);
}

/** @codeCoverageIgnore */
public function setPsr4($prefix, $paths)
{
$this->classLoader->setPsr4($prefix, $paths);
}

/** @codeCoverageIgnore */
public function setUseIncludePath($useIncludePath)
{
$this->classLoader->setUseIncludePath($useIncludePath);
}

/** @codeCoverageIgnore */
public function getUseIncludePath()
{
return $this->classLoader->getUseIncludePath();
}

/** @codeCoverageIgnore */
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classLoader->setClassMapAuthoritative($classMapAuthoritative);
}

/** @codeCoverageIgnore */
public function isClassMapAuthoritative()
{
return $this->classLoader->isClassMapAuthoritative();
}

/** @codeCoverageIgnore */
public function setApcuPrefix($apcuPrefix)
{
$this->classLoader->setApcuPrefix($apcuPrefix);
}

/** @codeCoverageIgnore */
public function getApcuPrefix()
{
return $this->classLoader->getApcuPrefix();
}

/** @codeCoverageIgnore */
public function register($prepend = false)
{
$this->classLoader->register($prepend);
}

/** @codeCoverageIgnore */
public function unregister()
{
$this->classLoader->unregister();
}

/** @codeCoverageIgnore */
public function findFile($class)
{
return $this->classLoader->findFile($class);
}
}