Skip to content

Commit

Permalink
Fix StaticConstructorLoader decorator (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-andreyev committed May 24, 2020
1 parent 02927ba commit c53daca
Showing 1 changed file with 116 additions and 2 deletions.
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 <dmitry.balabka@gmail.com>
*/
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);
}
}

0 comments on commit c53daca

Please sign in to comment.