Skip to content

Commit 96992f8

Browse files
samsonasikpaulbalandan
authored andcommitted
4.1.0: remove Autoloader::loadLegacy() method
1 parent 9ba38f4 commit 96992f8

5 files changed

Lines changed: 14 additions & 70 deletions

File tree

system/Autoloader/Autoloader.php

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,7 @@ public function loadClass(string $class)
225225
$class = trim($class, '\\');
226226
$class = str_ireplace('.php', '', $class);
227227

228-
$mapped_file = $this->loadInNamespace($class);
229-
230-
// Nothing? One last chance by looking
231-
// in common CodeIgniter folders.
232-
if (! $mapped_file)
233-
{
234-
$mapped_file = $this->loadLegacy($class);
235-
}
236-
237-
return $mapped_file;
228+
return $this->loadInNamespace($class);
238229
}
239230

240231
//--------------------------------------------------------------------
@@ -287,45 +278,6 @@ protected function loadInNamespace(string $class)
287278

288279
//--------------------------------------------------------------------
289280

290-
/**
291-
* Attempts to load the class from common locations in previous
292-
* version of CodeIgniter, namely 'app/Libraries', and
293-
* 'app/Models'.
294-
*
295-
* @param string $class The class name. This typically should NOT have a namespace.
296-
*
297-
* @return mixed The mapped file name on success, or boolean false on failure
298-
*/
299-
protected function loadLegacy(string $class)
300-
{
301-
// If there is a namespace on this class, then
302-
// we cannot load it from traditional locations.
303-
if (strpos($class, '\\') !== false)
304-
{
305-
return false;
306-
}
307-
308-
$paths = [
309-
APPPATH . 'Controllers/',
310-
APPPATH . 'Libraries/',
311-
APPPATH . 'Models/',
312-
];
313-
314-
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
315-
316-
foreach ($paths as $path)
317-
{
318-
if ($file = $this->includeFile($path . $class))
319-
{
320-
return $file;
321-
}
322-
}
323-
324-
return false;
325-
}
326-
327-
//--------------------------------------------------------------------
328-
329281
/**
330282
* A central way to include a file. Split out primarily for testing purposes.
331283
*

tests/system/Autoloader/AutoloaderTest.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,7 @@ public function testloadClassConfigNotFound()
186186
$this->assertFalse($this->loader->loadClass('NotFound'));
187187
}
188188

189-
public function testLoadLegacy()
190-
{
191-
// should not be able to find a folder
192-
$this->assertFalse((bool) $this->loader->loadClass(__DIR__));
193-
// should be able to find these because we said so in the Autoloader
194-
$this->assertTrue((bool) $this->loader->loadClass('Home'));
195-
// should not be able to find these - don't exist
196-
$this->assertFalse((bool) $this->loader->loadClass('anotherLibrary'));
197-
$this->assertFalse((bool) $this->loader->loadClass('\nester\anotherLibrary'));
198-
// should not be able to find these legacy classes - namespaced
199-
$this->assertFalse($this->loader->loadClass('Controllers\Home'));
200-
}
189+
//--------------------------------------------------------------------
201190

202191
public function testSanitizationSimply()
203192
{

user_guide_src/source/changelogs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ See all the changes.
1212
.. toctree::
1313
:titlesonly:
1414

15+
next
16+
v4.1.0
1517
v4.0.5
1618
v4.0.4
1719
v4.0.3
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Version 4.1.0
2+
====================================================
3+
4+
Release Date: Not released
5+
6+
**4.1.0 release of CodeIgniter4**
7+
8+
Removed:
9+
10+
- `Autoloader::loadLegacy()` method was previously used for migration non-namespaced classes transition to CodeIgniter v4. Since `4.1.0`, this support removed.

user_guide_src/source/concepts/autoloader.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,6 @@ third-party libraries that are not namespaced::
7676

7777
The key of each row is the name of the class that you want to locate. The value is the path to locate it at.
7878

79-
Legacy Support
80-
==============
81-
82-
If neither of the above methods finds the class, and the class is not namespaced, the autoloader will look in the
83-
**/app/Libraries** and **/app/Models** directories to attempt to locate the files. This provides
84-
a measure to help ease the transition from previous versions.
85-
86-
There are no configuration options for legacy support.
87-
8879
Composer Support
8980
================
9081

0 commit comments

Comments
 (0)