Skip to content

Commit 364ccd6

Browse files
committed
fixes#19 now StaticConstructorLoader provides same interface/contract as ClassLoader and proxies all methods call to target
1 parent 11b507f commit 364ccd6

File tree

1 file changed

+97
-2
lines changed

1 file changed

+97
-2
lines changed

src/StaticConstructorLoader/StaticConstructorLoader.php

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
* @author Dmitrijs Balabka <dmitry.balabka@gmail.com>
1414
*/
15-
final class StaticConstructorLoader
15+
final class StaticConstructorLoader extends ClassLoader /* extending for an contract */
1616
{
1717
/**
1818
* @var ClassLoader
@@ -53,12 +53,107 @@ public function __construct(ClassLoader $classLoader)
5353
array_map('spl_autoload_register', $loadersToRestore, $flagTrue, $flagTrue);
5454
}
5555

56-
public function loadClass(string $className): ?bool
56+
public function loadClass($className): ?bool
5757
{
5858
$result = $this->classLoader->loadClass($className);
5959
if ($result === true && $className !== StaticConstructorInterface::class && is_a($className, StaticConstructorInterface::class, true)) {
6060
$className::__constructStatic();
6161
}
6262
return $result;
6363
}
64+
65+
public function getPrefixes()
66+
{
67+
return $this->classLoader->getPrefixes();
68+
}
69+
70+
public function getPrefixesPsr4()
71+
{
72+
return $this->classLoader->getPrefixesPsr4();
73+
}
74+
75+
public function getFallbackDirs()
76+
{
77+
return $this->classLoader->getFallbackDirs();
78+
}
79+
80+
public function getFallbackDirsPsr4()
81+
{
82+
return $this->classLoader->getFallbackDirsPsr4();
83+
}
84+
85+
public function getClassMap()
86+
{
87+
return $this->classLoader->getClassMap();
88+
}
89+
90+
public function addClassMap(array $classMap)
91+
{
92+
$this->classLoader->addClassMap($classMap);
93+
}
94+
95+
public function add($prefix, $paths, $prepend = false)
96+
{
97+
$this->classLoader->add($prefix, $paths, $prepend);
98+
}
99+
100+
public function addPsr4($prefix, $paths, $prepend = false)
101+
{
102+
$this->classLoader->addPsr4($prefix, $paths, $prepend);
103+
}
104+
105+
public function set($prefix, $paths)
106+
{
107+
$this->classLoader->set($prefix, $paths);
108+
}
109+
110+
public function setPsr4($prefix, $paths)
111+
{
112+
$this->classLoader->setPsr4($prefix, $paths);
113+
}
114+
115+
public function setUseIncludePath($useIncludePath)
116+
{
117+
$this->classLoader->setUseIncludePath($useIncludePath);
118+
}
119+
120+
public function getUseIncludePath()
121+
{
122+
return $this->classLoader->getUseIncludePath();
123+
}
124+
125+
public function setClassMapAuthoritative($classMapAuthoritative)
126+
{
127+
$this->classLoader->setClassMapAuthoritative($classMapAuthoritative);
128+
}
129+
130+
public function isClassMapAuthoritative()
131+
{
132+
return $this->classLoader->isClassMapAuthoritative();
133+
}
134+
135+
public function setApcuPrefix($apcuPrefix)
136+
{
137+
$this->classLoader->setApcuPrefix($apcuPrefix);
138+
}
139+
140+
public function getApcuPrefix()
141+
{
142+
return $this->classLoader->getApcuPrefix();
143+
}
144+
145+
public function register($prepend = false)
146+
{
147+
$this->classLoader->register($prepend);
148+
}
149+
150+
public function unregister()
151+
{
152+
$this->classLoader->unregister();
153+
}
154+
155+
public function findFile($class)
156+
{
157+
return $this->classLoader->findFile($class);
158+
}
64159
}

0 commit comments

Comments
 (0)