8000 [ClassLoader] removed deprecated UniversalClassLoader and DebugClassL… · symfony/symfony@5921cd9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5921cd9

Browse files
author
Hugo Hamon
committed
[ClassLoader] removed deprecated UniversalClassLoader and DebugClassLoader.
1 parent a179b90 commit 5921cd9

12 files changed

+51
-708
lines changed

src/Symfony/Component/ClassLoader/ApcClassLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
*
1717
* It expects an object implementing a findFile method to find the file. This
1818
* allows using it as a wrapper around the other loaders of the component (the
19-
* ClassLoader and the UniversalClassLoader for instance) but also around any
20-
* other autoloader following this convention (the Composer one for instance)
19+
* ClassLoader for instance) but also around any other autoloaders following
20+
* this convention (the Composer one for instance).
2121
*
2222
* $loader = new ClassLoader();
2323
*
2424
* // register classes with namespaces
25-
* $loader->add('Symfony\Component', __DIR__.'/component');
26-
* $loader->add('Symfony', __DIR__.'/framework');
25+
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
26+
* $loader->addPrefix('Symfony', __DIR__.'/framework');
2727
*
2828
* $cachedLoader = new ApcClassLoader('my_prefix', $loader);
2929
*

src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@
2727
*
2828
* Example usage:
2929
*
30-
* require 'vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
30+
* require 'vendor/symfony/src/Symfony/Component/ClassLoader/ClassLoader.php';
3131
* require 'vendor/symfony/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php';
3232
*
3333
* use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
3434
*
3535
* $loader = new ApcUniversalClassLoader('apc.prefix.');
3636
*
3737
* // register classes with namespaces
38-
* $loader->registerNamespaces(array(
38+
* $loader->addPrefixes(array(
3939
* 'Symfony\Component' => __DIR__.'/component',
4040
* 'Symfony' => __DIR__.'/framework',
4141
* 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'),
4242
* ));
4343
*
4444
* // register a library using the PEAR naming convention
45-
* $loader->registerPrefixes(array(
45+
* $loader->addPrefixes(array(
4646
* 'Swift_' => __DIR__.'/Swift',
4747
* ));
4848
*
@@ -60,7 +60,7 @@
6060
*
6161
* @api
6262
*/
63-
class ApcUniversalClassLoader extends UniversalClassLoader
63+
class ApcUniversalClassLoader extends ClassLoader
6464
{
6565
private $prefix;
6666

src/Symfony/Component/ClassLoader/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
3.0.0
5+
-----
6+
7+
* The DebugClassLoader class has been removed
8+
* The UniversalClassLoader class has been removed
9+
410
2.7.0
511
-----
612

src/Symfony/Component/ClassLoader/DebugClassLoader.php

Lines changed: 0 additions & 121 deletions
This file was deleted.

src/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
*
1717
* @author Fabien Potencier <fabien@symfony.com>
1818
*/
19-
class DebugUniversalClassLoader extends UniversalClassLoader
19+
class DebugUniversalClassLoader extends ClassLoader
2020
{
2121
/**
22-
* Replaces all regular UniversalClassLoader instances by a DebugUniversalClassLoader ones.
22+
* Replaces all regular ClassLoader instances by a DebugUniversalClassLoader ones.
2323
*/
2424
public static function enable()
2525
{
@@ -32,13 +32,11 @@ public static function enable()
3232
}
3333

3434
foreach ($functions as $function) {
35-
if (is_array($function) && $function[0] instanceof UniversalClassLoader) {
35+
if (is_array($function) && $function[0] instanceof ClassLoader) {
3636
$loader = new static();
37-
$loader->registerNamespaceFallbacks($function[0]->getNamespaceFallbacks());
38-
$loader->registerPrefixFallbacks($function[0]->getPrefixFallbacks());
39-
$loader->registerNamespaces($function[0]->getNamespaces());
40-
$loader->registerPrefixes($function[0]->getPrefixes());
41-
$loader->useIncludePath($function[0]->getUseIncludePath());
37+
$loader->addPrefixes('', $function[0]->getFallbackDirs());
38+
$loader->addPrefixes($function[0]->getPrefixes());
39+
$loader->setUseIncludePath($function[0]->getUseIncludePath());
4240

4341
$function[0] = $loader;
4442
}

src/Symfony/Component/ClassLoader/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ standard or the PEAR naming convention.
1010
First, register the autoloader:
1111

1212
```php
13-
require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
13+
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php';
1414

15-
use Symfony\Component\ClassLoader\UniversalClassLoader;
15+
use Symfony\Component\ClassLoader\ClassLoader;
1616

17-
$loader = new UniversalClassLoader();
17+
$loader = new ClassLoader();
1818
$loader->register();
1919
```
2020

2121
Then, register some namespaces with the `registerNamespace()` method:
2222

2323
```php
24-
$loader->registerNamespace('Symfony', __DIR__.'/src');
25-
$loader->registerNamespace('Monolog', __DIR__.'/vendor/monolog/src');
24+
$loader->addPrefix('Symfony', __DIR__.'/src');
25+
$loader->addPrefix('Monolog', __DIR__.'/vendor/monolog/src');
2626
```
2727

28-
The `registerNamespace()` method takes a namespace prefix and a path where to
29-
look for the classes as arguments.
28+
The `addPrefix()` method takes a namespace prefix and a path where to look for
29+
the classes as arguments.
3030

3131
You can also register a sub-namespaces:
3232

3333
```php
34-
$loader->registerNamespace('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib');
34+
$loader->addPrefix('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib');
3535
```
3636

3737
The order of registration is significant and the first registered namespace
@@ -40,14 +40,14 @@ takes precedence over later registered one.
4040
You can also register more than one path for a given namespace:
4141

4242
```php
43-
$loader->registerNamespace('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src'));
43+
$loader->addPrefix('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src'));
4444
```
4545

46-
Alternatively, you can use the `registerNamespaces()` method to register more
46+
Alternatively, you can use the `addPrefixes()` method to register more
4747
than one namespace at once:
4848

4949
```php
50-
$loader->registerNamespaces(array(
50+
$loader->addPrefixes(array(
5151
'Symfony' => array(__DIR__.'/src', __DIR__.'/symfony/src'),
5252
'Doctrine\\Common' => __DIR__.'/vendor/doctrine-common/lib',
5353
'Doctrine' => __DIR__.'/vendor/doctrine/lib',
@@ -59,7 +59,7 @@ For better performance, you can use the APC based version of the universal
5959
class loader:
6060

6161
```php
62-
require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
62+
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php';
6363
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php';
6464

6565
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;

src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected function tearDown()
3838
public function testConstructor()
3939
{
4040
$loader = new ApcUniversalClassLoader('test.prefix.');
41-
$loader->registerNamespace('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
41+
$loader->addPrefix('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
4242

4343
$this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apc_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument');
4444
}
@@ -49,8 +49,8 @@ public function testConstructor()
4949
public function testLoadClass($className, $testClassName, $message)
5050
{
5151
$loader = new ApcUniversalClassLoader('test.prefix.');
52-
$loader->registerNamespace('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
53-
$loader->registerPrefix('Apc_Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
52+
$loader->addPrefix('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
53+
$loader->addPrefix('Apc_Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
5454
$loader->loadClass($testClassName);
5555
$this->assertTrue(class_exists($className), $message);
5656
}
@@ -69,10 +69,9 @@ public function getLoadClassTests()
6969
public function testLoadClassFromFallback($className, $testClassName, $message)
7070
{
7171
$loader = new ApcUniversalClassLoader('test.prefix.fallback');
72-
$loader->registerNamespace('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
73-
$loader->registerPrefix('Apc_Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
74-
$loader->registerNamespaceFallbacks(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/fallback'));
75-
$loader->registerPrefixFallbacks(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/fallback'));
72+
$loader->addPrefix('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
73+
$loader->addPrefix('Apc_Pearlike_', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
74+
$loader->addPrefix('', array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/fallback'));
7675
$loader->loadClass($testClassName);
7776
$this->assertTrue(class_exists($className), $message);
7877
}
@@ -93,7 +92,7 @@ public function getLoadClassFromFallbackTests()
9392
public function testLoadClassNamespaceCollision($namespaces, $className, $message)
9493
{
9594
$loader = new ApcUniversalClassLoader('test.prefix.collision.');
96-
$loader->registerNamespaces($namespaces);
95+
$loader->addPrefixes($namespaces);
9796

9897
$loader->loadClass($className);
9998

@@ -144,7 +143,7 @@ public function getLoadClassNamespaceCollisionTests()
144143
public function testLoadClassPrefixCollision($prefixes, $className, $message)
145144
{
146145
$loader = new ApcUniversalClassLoader('test.prefix.collision.');
147-
$loader->registerPrefixes($prefixes);
146+
$loader->addPrefixes($prefixes);
148147

149148
$loader->loadClass($className);
150149
$this->assertTrue(class_exists($className), $message);

0 commit comments

Comments
 (0)
0