Skip to content

Commit a9d0ad8

Browse files
committed
[Autoloader] include_once is not needed on Autoloader::loadClass() with no namespace
1 parent 5fc58f9 commit a9d0ad8

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

system/Autoloader/Autoloader.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@
2222
* An autoloader that uses both PSR4 autoloading, and traditional classmaps.
2323
*
2424
* Given a foo-bar package of classes in the file system at the following paths:
25-
*```
25+
* ```
2626
* /path/to/packages/foo-bar/
2727
* /src
2828
* Baz.php # Foo\Bar\Baz
2929
* Qux/
3030
* Quux.php # Foo\Bar\Qux\Quux
31-
*```
31+
* ```
3232
* you can add the path to the configuration array that is passed in the constructor.
3333
* The Config array consists of 2 primary keys, both of which are associative arrays:
3434
* 'psr4', and 'classmap'.
35-
*```
35+
* ```
3636
* $Config = [
3737
* 'psr4' => [
3838
* 'Foo\Bar' => '/path/to/packages/foo-bar'
@@ -41,17 +41,17 @@
4141
* 'MyClass' => '/path/to/class/file.php'
4242
* ]
4343
* ];
44-
*```
44+
* ```
4545
* Example:
46-
*```
46+
* ```
4747
* <?php
4848
* // our configuration array
4949
* $Config = [ ... ];
5050
* $loader = new \CodeIgniter\Autoloader\Autoloader($Config);
5151
*
5252
* // register the autoloader
5353
* $loader->register();
54-
*```
54+
* ```
5555
*/
5656
class Autoloader
5757
{
@@ -260,9 +260,9 @@ protected function loadInNamespace(string $class)
260260
{
261261
$class = 'Config\\' . $class;
262262
$filePath = APPPATH . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
263-
$filename = $this->includeFile($filePath);
263+
$filename = $this->sanitizeFilename($filePath);
264264

265-
if ($filename)
265+
if (is_file($filename))
266266
{
267267
return $filename;
268268
}
@@ -353,7 +353,9 @@ protected function discoverComposerNamespaces()
353353
return;
354354
}
355355

356-
/** @var ClassLoader $composer */
356+
/**
357+
* @var ClassLoader $composer
358+
*/
357359
$composer = include COMPOSER_PATH;
358360
$paths = $composer->getPrefixesPsr4();
359361
$classes = $composer->getClassMap();

0 commit comments

Comments
 (0)