@@ -49,90 +49,65 @@ class AutoloadConfig
4949{
5050
5151 /**
52- * Array of namespaces for autoloading.
52+ * -------------------------------------------------------------------
53+ * Namespaces
54+ * -------------------------------------------------------------------
55+ * This maps the locations of any namespaces in your application to
56+ * their location on the file system. These are used by the autoloader
57+ * to locate files the first time they have been instantiated.
58+ *
59+ * Do not change the name of the CodeIgniter namespace or your application
60+ * will break.
5361 *
5462 * @var array
5563 */
56- public $ psr4 = [];
64+ protected $ corePsr4 = [
65+ 'CodeIgniter ' => SYSTEMPATH ,
66+ 'App ' => APPPATH // To ensure filters, etc still found,
67+ ];
5768
5869 /**
59- * Map of class names and locations
70+ * -------------------------------------------------------------------
71+ * Class Map
72+ * -------------------------------------------------------------------
73+ * The class map provides a map of class names and their exact
74+ * location on the drive. Classes loaded in this manner will have
75+ * slightly faster performance because they will not have to be
76+ * searched for within one or more directories as they would if they
77+ * were being autoloaded through a namespace.
6078 *
6179 * @var array
6280 */
63- public $ classmap = [];
81+ protected $ coreClassmap = [
82+ 'Psr\Log\AbstractLogger ' => SYSTEMPATH . 'ThirdParty/PSR/Log/AbstractLogger.php ' ,
83+ 'Psr\Log\InvalidArgumentException ' => SYSTEMPATH . 'ThirdParty/PSR/Log/InvalidArgumentException.php ' ,
84+ 'Psr\Log\LoggerAwareInterface ' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerAwareInterface.php ' ,
85+ 'Psr\Log\LoggerAwareTrait ' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerAwareTrait.php ' ,
86+ 'Psr\Log\LoggerInterface ' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerInterface.php ' ,
87+ 'Psr\Log\LoggerTrait ' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerTrait.php ' ,
88+ 'Psr\Log\LogLevel ' => SYSTEMPATH . 'ThirdParty/PSR/Log/LogLevel.php ' ,
89+ 'Psr\Log\NullLogger ' => SYSTEMPATH . 'ThirdParty/PSR/Log/NullLogger.php ' ,
90+ 'Laminas\Escaper\Escaper ' => SYSTEMPATH . 'ThirdParty/Escaper/Escaper.php '
91+ ];
6492
6593 //--------------------------------------------------------------------
6694
6795 /**
6896 * Constructor.
97+ *
98+ * Merge the built-in and developer-configured psr4 and classmap,
99+ * with preference to the developer ones.
69100 */
70101 public function __construct ()
71102 {
72- /**
73- * -------------------------------------------------------------------
74- * Namespaces
75- * -------------------------------------------------------------------
76- * This maps the locations of any namespaces in your application
77- * to their location on the file system. These are used by the
78- * Autoloader to locate files the first time they have been instantiated.
79- *
80- * The '/application' and '/system' directories are already mapped for
81- * you. You may change the name of the 'App' namespace if you wish,
82- * but this should be done prior to creating any namespaced classes,
83- * else you will need to modify all of those classes for this to work.
84- *
85- * DO NOT change the name of the CodeIgniter namespace or your application
86- * WILL break. *
87- * Prototype:
88- *
89- * $Config['psr4'] = [
90- * 'CodeIgniter' => SYSPATH
91- * `];
92- */
93- $ this ->psr4 = [
94- 'CodeIgniter ' => realpath (SYSTEMPATH ),
95- ];
96-
97103 if (isset ($ _SERVER ['CI_ENVIRONMENT ' ]) && $ _SERVER ['CI_ENVIRONMENT ' ] === 'testing ' )
98104 {
99105 $ this ->psr4 ['Tests\Support ' ] = SUPPORTPATH ;
100- }
101-
102- /**
103- * -------------------------------------------------------------------
104- * Class Map
105- * -------------------------------------------------------------------
106- * The class map provides a map of class names and their exact
107- * location on the drive. Classes loaded in this manner will have
108- * slightly faster performance because they will not have to be
109- * searched for within one or more directories as they would if they
110- * were being autoloaded through a namespace.
111- *
112- * Prototype:
113- *
114- * $Config['classmap'] = [
115- * 'MyClass' => '/path/to/class/file.php'
116- * ];
117- */
118- $ this ->classmap = [
119- 'Psr\Log\AbstractLogger ' => SYSTEMPATH . 'ThirdParty/PSR/Log/AbstractLogger.php ' ,
120- 'Psr\Log\InvalidArgumentException ' => SYSTEMPATH . 'ThirdParty/PSR/Log/InvalidArgumentException.php ' ,
121- 'Psr\Log\LoggerAwareInterface ' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerAwareInterface.php ' ,
122- 'Psr\Log\LoggerAwareTrait ' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerAwareTrait.php ' ,
123- 'Psr\Log\LoggerInterface ' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerInterface.php ' ,
124- 'Psr\Log\LoggerTrait ' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerTrait.php ' ,
125- 'Psr\Log\LogLevel ' => SYSTEMPATH . 'ThirdParty/PSR/Log/LogLevel.php ' ,
126- 'Psr\Log\NullLogger ' => SYSTEMPATH . 'ThirdParty/PSR/Log/NullLogger.php ' ,
127- 'Laminas\Escaper\Escaper ' => SYSTEMPATH . 'ThirdParty/Escaper/Escaper.php ' ,
128- ];
129-
130- if (isset ($ _SERVER ['CI_ENVIRONMENT ' ]) && $ _SERVER ['CI_ENVIRONMENT ' ] === 'testing ' )
131- {
132106 $ this ->classmap ['CodeIgniter\Log\TestLogger ' ] = SYSTEMPATH . 'Test/TestLogger.php ' ;
133107 $ this ->classmap ['CIDatabaseTestCase ' ] = SYSTEMPATH . 'Test/CIDatabaseTestCase.php ' ;
134108 }
135- }
136109
137- //--------------------------------------------------------------------
110+ $ this ->psr4 = array_merge ($ this ->corePsr4 , $ this ->psr4 );
111+ $ this ->classmap = array_merge ($ this ->coreClassmap , $ this ->classmap );
112+ }
138113}
0 commit comments