Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[ClassLoader] Deprecated the component #21353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions 3 UPGRADE-3.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ UPGRADE FROM 3.2 to 3.3
ClassLoader
-----------

* The ApcClassLoader, WinCacheClassLoader and XcacheClassLoader classes have been deprecated
in favor of the `--apcu-autoloader` option introduced in composer 1.3
* The component is deprecated and will be removed in 4.0. Use Composer instead.

DependencyInjection
-------------------
Expand Down
3 changes: 1 addition & 2 deletions 3 UPGRADE-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ UPGRADE FROM 3.x to 4.0
ClassLoader
-----------

* The ApcClassLoader, WinCacheClassLoader and XcacheClassLoader classes have been removed
in favor of the `--apcu-autoloader` option introduced in composer 1.3
* The component has been removed. Use Composer instead.

Console
-------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;

use Composer\Autoload\ClassLoader;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
use Symfony\Component\ClassLoader\ClassLoader;

class ControllerNameParserTest extends TestCase
{
Expand All @@ -22,17 +22,14 @@ class ControllerNameParserTest extends TestCase
protected function setUp()
{
$this->loader = new ClassLoader();
$this->loader->addPrefixes(array(
'TestBundle' => __DIR__.'/../Fixtures',
'TestApplication' => __DIR__.'/../Fixtures',
));
$this->loader->add('TestBundle', __DIR__.'/../Fixtures');
$this->loader->add('TestApplication', __DIR__.'/../Fixtures');
$this->loader->register();
}

protected function tearDown()
{
spl_autoload_unregister(array($this->loader, 'loadClass'));

$this->loader->unregister();
$this->loader = null;
}

Expand Down
3 changes: 1 addition & 2 deletions 3 src/Symfony/Component/ClassLoader/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ CHANGELOG
3.3.0
-----

* The ApcClassLoader, WinCacheClassLoader and XcacheClassLoader classes have been deprecated
in favor of the `--apcu-autoloader` option introduced in composer 1.3
* deprecated the component: use Composer instead

3.0.0
-----
Expand Down
4 changes: 4 additions & 0 deletions 4 src/Symfony/Component/ClassLoader/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Component\ClassLoader;

@trigger_error('The '.__NAMESPACE__.'\ClassLoader class is deprecated since version 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);

/**
* ClassLoader implements an PSR-0 class loader.
*
Expand All @@ -36,6 +38,8 @@
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
*
* @deprecated since version 3.3, to be removed in 4.0.
*/
class ClassLoader
{
Expand Down
4 changes: 4 additions & 0 deletions 4 src/Symfony/Component/ClassLoader/ClassMapGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@

namespace Symfony\Component\ClassLoader;

@trigger_error('The '.__NAMESPACE__.'\ClassMapGenerator class is deprecated since version 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);

/**
* ClassMapGenerator.
*
* @author Gyula Sallai <salla016@gmail.com>
*
* @deprecated since version 3.3, to be removed in 4.0.
*/
class ClassMapGenerator
{
Expand Down
4 changes: 4 additions & 0 deletions 4 src/Symfony/Component/ClassLoader/MapClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@

namespace Symfony\Component\ClassLoader;

@trigger_error('The '.__NAMESPACE__.'\MapClassLoader class is deprecated since version 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);

/**
* A class loader that uses a mapping file to look up paths.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 3.3, to be removed in 4.0.
*/
class MapClassLoader
{
Expand Down
4 changes: 4 additions & 0 deletions 4 src/Symfony/Component/ClassLoader/Psr4ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@

namespace Symfony\Component\ClassLoader;

@trigger_error('The '.__NAMESPACE__.'\Psr4ClassLoader class is deprecated since version 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);

/**
* A PSR-4 compatible class loader.
*
* See http://www.php-fig.org/psr/psr-4/
*
* @author Alexander M. Turek <me@derrabus.de>
*
* @deprecated since version 3.3, to be removed in 4.0.
*/
class Psr4ClassLoader
{
Expand Down
3 changes: 3 additions & 0 deletions 3 src/Symfony/Component/ClassLoader/Tests/ClassLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

use Symfony\Component\ClassLoader\ClassLoader;

/**
* @group legacy
*/
class ClassLoaderTest extends \PHPUnit_Framework_TestCase
{
public function testGetPrefixes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

use Symfony\Component\ClassLoader\ClassMapGenerator;

/**
* @group legacy
*/
class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

use Symfony\Component\ClassLoader\Psr4ClassLoader;

/**
* @group legacy
*/
class Psr4ClassLoaderTest extends \PHPUnit_Framework_TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\Debug\Tests\FatalErrorHandler;

use Symfony\Component\Debug\Exception\FatalErrorException;
use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader;
use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
use Symfony\Component\Debug\DebugClassLoader;
use Composer\Autoload\ClassLoader as ComposerClassLoader;
Expand Down Expand Up @@ -69,12 +68,10 @@ public function testHandleClassNotFound($error, $translatedMessage, $autoloader

public function provideClassNotFoundData()
{
$prefixes = array('Symfony\Component\Debug\Exception\\' => realpath(__DIR__.'/../../Exception'));
$autoloader = new ComposerClassLoader();
$autoloader->add('Symfony\Component\Debug\Exception\\', realpath(__DIR__.'/../../Exception'));

$symfonyAutoloader = new SymfonyClassLoader();
$symfonyAutoloader->addPrefixes($prefixes);

$debugClassLoader = new DebugClassLoader(array($symfonyAutoloader, 'loadClass'));
$debugClassLoader = new DebugClassLoader(array($autoloader, 'loadClass'));

return array(
array(
Expand Down Expand Up @@ -130,7 +127,7 @@ public function provideClassNotFoundData()
'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found',
),
"Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\Bar\".\nDid you forget a \"use\" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException\"?",
array($symfonyAutoloader, 'loadClass'),
array($autoloader, 'loadClass'),
),
array(
array(
Expand Down
1 change: 0 additions & 1 deletion 1 src/Symfony/Component/Debug/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2"
},
"require-dev": {
"symfony/class-loader": "~2.8|~3.0",
"symfony/http-kernel": "~2.8|~3.0"
},
"autoload": {
Expand Down
25 changes: 16 additions & 9 deletions 25 src/Symfony/Component/HttpKernel/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,29 @@ protected function getScript($request)
{
$kernel = str_replace("'", "\\'", serialize($this->kernel));
$request = str_replace("'", "\\'", serialize($request));

$r = new \ReflectionClass('\\Symfony\\Component\\ClassLoader\\ClassLoader');
$requirePath = str_replace("'", "\\'", $r->getFileName());
$symfonyPath = str_replace("'", "\\'", dirname(dirname(dirname(__DIR__))));
$errorReporting = error_reporting();

$requires = '';
foreach (get_declared_classes() as $class) {
if (0 === strpos($class, 'ComposerAutoloaderInit')) {
$r = new \ReflectionClass($class);
$file = dirname(dirname($r->getFileName())).'/autoload.php';
if (file_exists($file)) {
$requires .= "require_once '".str_replace("'", "\\'", $file)."';\n";
}
}
}

if (!$requires) {
throw new \RuntimeException('Composer autoloader not found.');
}

$code = <<<EOF
<?php

error_reporting($errorReporting);

require_once '$requirePath';

\$loader = new Symfony\Component\ClassLoader\ClassLoader();
\$loader->addPrefix('Symfony', '$symfonyPath');
\$loader->register();
$requires

\$kernel = unserialize('$kernel');
\$request = unserialize('$request');
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.