Skip to content

Commit 67c4c9b

Browse files
committed
Fix extends object
Access to the base class
1 parent f996c91 commit 67c4c9b

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

autoload/src/Loader.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ class Loader extends LoaderHelper
6363
/**
6464
* Namespace
6565
*
66-
* @var string $namespace
66+
* @var array $namespace
6767
*/
68-
protected $namespace = '';
68+
protected $namespace = [];
6969

7070
public function __construct(array $dir)
7171
{
@@ -91,7 +91,7 @@ protected function action()
9191
spl_autoload_register(array($this, '__autoload'));
9292
}
9393
} else {
94-
echo 'Ohhh NO Autoload exists, you use a PHP version under 5.1.2';
94+
echo 'Ohhh, NO Autoload exists, you use a PHP version under 5.1.2';
9595
}
9696

9797
if (MBT_DEBUG_DISPLAY_AUTOLOAD == true) {
@@ -113,9 +113,9 @@ protected function __autoload($name)
113113
$this->instance = $name;
114114

115115
$classFilePath = '';
116-
if (!empty($this->splitInsatnce(true))) {
116+
if (!empty($this->splitInstance($this, true))) {
117117
// Get namespace as folder path
118-
$classFilePath = str_replace(array("\\", "//"), "/", MBT_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . $this->splitInsatnce(true));
118+
$classFilePath = str_replace(array("\\", "//"), "/", MBT_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . $this->splitInstance($this, true));
119119
}
120120

121121
// Exists a folder with same path as the namespace and is dir
@@ -139,8 +139,8 @@ protected function __autoload($name)
139139
* Then the result example /project/site/mywebsite/testclasses/class.first_class.php
140140
*/
141141
$classFile = '';
142-
if (!empty($this->splitInsatnce())) {
143-
$classFile = $classFilePath . DIRECTORY_SEPARATOR . 'class.' . $this->splitInsatnce() . '.php';
142+
if (!empty($this->splitInstance($this))) {
143+
$classFile = $classFilePath . DIRECTORY_SEPARATOR . 'class.' . $this->splitInstance($this) . '.php';
144144
}
145145

146146
// Check if class file exists

autoload/src/class.LoaderHelper.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ protected function readIndex($mod = false)
125125
*
126126
* @return string
127127
*/
128-
protected function getNamespace($line, $arr)
128+
protected function getNamespace(Loader $obj, $line, $arr)
129129
{
130130
// Get actually namespace
131-
$namespaceRegEx = '/((namespace)+\s*(' . preg_quote($this->splitInsatnce(true)) . ');)/';
131+
$namespaceRegEx = '/((namespace)+\s*(' . preg_quote($this->splitInstance($obj, true)) . ');)/';
132132
if (preg_match_all($namespaceRegEx, $line, $arr)) {
133133
// Debug information
134134
$this->debugInfo[] = '<b>Namespace:</b> <span style="color:blue;">' . $arr[0][0] . '</span>';
@@ -146,10 +146,10 @@ protected function getNamespace($line, $arr)
146146
* @param array $arr
147147
* @param integer $lineNum
148148
*/
149-
protected function getClass($filepath, $line, $arr, $lineNum)
149+
protected function getClass(Loader $obj, $filepath, $line, $arr, $lineNum)
150150
{
151151
// Get actually class
152-
$classRegEx = '/((interface|abstract\s+class|class|trait)+\s+(' . preg_quote($this->splitInsatnce()) . ')(.*)\{?)/';
152+
$classRegEx = '/((interface|abstract\s+class|class|trait)+\s+(' . preg_quote($this->splitInstance($obj)) . ')(.*)\{?)/';
153153

154154
if (preg_match_all($classRegEx, trim($line), $arr)) {
155155

@@ -167,7 +167,7 @@ protected function getClass($filepath, $line, $arr, $lineNum)
167167
// $this->loadIndex($class, $filepath);
168168

169169
// Found true for break
170-
$this->found = true;
170+
$obj->found = true;
171171

172172
// Debug information
173173
$this->debugInfo[] = '<b>NEEDED CLASS</b><br>';
@@ -181,22 +181,22 @@ protected function getClass($filepath, $line, $arr, $lineNum)
181181
/**
182182
* This function split the namespace and class, you can get the only namespace or only classname
183183
*
184-
* @uses splitInsatnce(false) For classname
185-
* @uses splitInsatnce(true) For namespace
184+
* @uses splitInstance(false) For classname
185+
* @uses splitInstance(true) For namespace
186186
*
187187
* @param boolean $namespaceORclass
188188
*
189189
* @return string
190190
*/
191-
protected function splitInsatnce($namespaceORclass = false)
191+
protected function splitInstance(Loader $obj, $namespaceORclass = false)
192192
{
193-
if ($this->instance) {
194-
$this->namespace = explode('\\', $this->instance);
195-
$getLastForName = count($this->namespace) - 1;
196-
$classname = $this->namespace[$getLastForName];
197-
unset($this->namespace[$getLastForName]);
193+
if ($obj->instance) {
194+
$obj->namespace = explode('\\', $obj->instance);
195+
$getLastForName = count($obj->namespace) - 1;
196+
$classname = $obj->namespace[$getLastForName];
197+
unset($obj->namespace[$getLastForName]);
198198
if ($namespaceORclass == true) {
199-
$return = implode('\\', $this->namespace);
199+
$return = implode('\\', $obj->namespace);
200200
} else {
201201
$return = $classname;
202202
}

0 commit comments

Comments
 (0)