Commit 1003720c authored by alexpott's avatar alexpott

Issue #2414235 by hussainweb, dawehner: Upgrade to Symfony 2.6.4

parent 0baa9b26
This diff is collapsed.
......@@ -47,7 +47,7 @@ public function testProcessOutbound() {
'SCRIPT_FILENAME' => \Drupal::root() . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::create('/subdir', 'GET', [], [], [], $server);
$request = Request::create('/subdir/', 'GET', [], [], [], $server);
$request->attributes->set(RouteObjectInterface::ROUTE_NAME, '<front>');
$request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/'));
......
......@@ -159,7 +159,7 @@ protected function setupRequestStack($subdir) {
'SCRIPT_FILENAME' => $this->root . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::create('/subdir');
$request = Request::create('/subdir/');
}
else {
$request = Request::create('/');
......
This diff is collapsed.
......@@ -17,11 +17,19 @@
* It expects an object implementing a findFile method to find the file. This
* allows using it as a wrapper around the other loaders of the component (the
* ClassLoader and the UniversalClassLoader for instance) but also around any
* other autoloader following this convention (the Composer one for instance)
* other autoloaders following this convention (the Composer one for instance).
*
* // with a Symfony autoloader
* use Symfony\Component\ClassLoader\ClassLoader;
*
* $loader = new ClassLoader();
* $loader->addPrefix('Symfony\Component', __DIR__.'/component');
* $loader->addPrefix('Symfony', __DIR__.'/framework');
*
* // or with a Composer autoloader
* use Composer\Autoload\ClassLoader;
*
* // register classes with namespaces
* $loader = new ClassLoader();
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
......@@ -44,10 +52,9 @@ class ApcClassLoader
private $prefix;
/**
* The class loader object being decorated.
* A class loader object that implements the findFile() method.
*
* @var object
* A class loader object that implements the findFile() method.
*/
protected $decorated;
......
......@@ -59,6 +59,8 @@
* @author Kris Wallsmith <kris@symfony.com>
*
* @api
*
* @deprecated Deprecated since version 2.4, to be removed in 3.0. Use the ApcClassLoader class instead.
*/
class ApcUniversalClassLoader extends UniversalClassLoader
{
......
......@@ -4,6 +4,9 @@ CHANGELOG
2.4.0
-----
* deprecated the UniversalClassLoader in favor of the ClassLoader class instead
* deprecated the ApcUniversalClassLoader in favor of the ApcClassLoader class instead
* deprecated the DebugUniversalClassLoader in favor of the DebugClassLoader class from the Debug component
* deprecated the DebugClassLoader as it has been moved to the Debug component instead
2.3.0
......
......@@ -353,14 +353,17 @@ private static function resolveDependencies(array $tree, $node, \ArrayObject $re
$unresolved = new \ArrayObject();
}
$nodeName = $node->getName();
$unresolved[$nodeName] = $node;
foreach ($tree[$nodeName] as $dependency) {
if (!$resolved->offsetExists($dependency->getName())) {
self::resolveDependencies($tree, $dependency, $resolved, $unresolved);
if (isset($tree[$nodeName])) {
$unresolved[$nodeName] = $node;
foreach ($tree[$nodeName] as $dependency) {
if (!$resolved->offsetExists($dependency->getName())) {
self::resolveDependencies($tree, $dependency, $resolved, $unresolved);
}
}
$resolved[$nodeName] = $node;
unset($unresolved[$nodeName]);
}
$resolved[$nodeName] = $node;
unset($unresolved[$nodeName]);
return $resolved;
}
......
......@@ -12,7 +12,7 @@
namespace Symfony\Component\ClassLoader;
/**
* ClassLoader implements an PSR-0 class loader
* ClassLoader implements an PSR-0 class loader.
*
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
*
......@@ -76,7 +76,7 @@ public function addPrefixes(array $prefixes)
}
/**
* Registers a set of classes
* Registers a set of classes.
*
* @param string $prefix The classes prefix
* @param array|string $paths The location(s) of the classes
......
......@@ -20,14 +20,14 @@
}
/**
* ClassMapGenerator
* ClassMapGenerator.
*
* @author Gyula Sallai <salla016@gmail.com>
*/
class ClassMapGenerator
{
/**
* Generate a class map file
* Generate a class map file.
*
* @param array|string $dirs Directories or a single path to search in
* @param string $file The name of the class map file
......@@ -45,7 +45,7 @@ public static function dump($dirs, $file)
}
/**
* Iterate over all files in the given directory searching for classes
* Iterate over all files in the given directory searching for classes.
*
* @param \Iterator|string $dir The directory to search in or an iterator
*
......@@ -81,7 +81,7 @@ public static function createMap($dir)
}
/**
* Extract the classes in the given file
* Extract the classes in the given file.
*
* @param string $path The file to check
*
......
......@@ -82,7 +82,7 @@ public function unregister()
}
/**
* Finds a file by class name
* Finds a file by class name.
*
* @param string $class A class name to resolve to file
*
......
......@@ -15,6 +15,8 @@
* Checks that the class is actually declared in the included file.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated Deprecated since version 2.4, to be removed in 3.0. Use the DebugClassLoader provided by the Debug component instead.
*/
class DebugUniversalClassLoader extends UniversalClassLoader
{
......
Copyright (c) 2004-2014 Fabien Potencier
Copyright (c) 2004-2015 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
......@@ -77,7 +77,7 @@ public function loadClass($class)
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend
* @param bool $prepend
*/
public function register($prepend = false)
{
......
......@@ -4,34 +4,34 @@ ClassLoader Component
ClassLoader loads your project classes automatically if they follow some
standard PHP conventions.
The Universal ClassLoader is able to autoload classes that implement the PSR-0
The ClassLoader object is able to autoload classes that implement the PSR-0
standard or the PEAR naming convention.
First, register the autoloader:
```php
require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php';
use Symfony\Component\ClassLoader\UniversalClassLoader;
use Symfony\Component\ClassLoader\ClassLoader;
$loader = new UniversalClassLoader();
$loader = new ClassLoader();
$loader->register();
```
Then, register some namespaces with the `registerNamespace()` method:
Then, register some namespaces with the `addPrefix()` method:
```php
$loader->registerNamespace('Symfony', __DIR__.'/src');
$loader->registerNamespace('Monolog', __DIR__.'/vendor/monolog/src');
$loader->addPrefix('Symfony', __DIR__.'/src');
$loader->addPrefix('Monolog', __DIR__.'/vendor/monolog/src');
```
The `registerNamespace()` method takes a namespace prefix and a path where to
The `addPrefix()` method takes a namespace prefix and a path where to
look for the classes as arguments.
You can also register a sub-namespaces:
```php
$loader->registerNamespace('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib');
$loader->addPrefix('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib');
```
The order of registration is significant and the first registered namespace
......@@ -40,14 +40,14 @@ takes precedence over later registered one.
You can also register more than one path for a given namespace:
```php
$loader->registerNamespace('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src'));
$loader->addPrefix('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src'));
```
Alternatively, you can use the `registerNamespaces()` method to register more
Alternatively, you can use the `addPrefixes()` method to register more
than one namespace at once:
```php
$loader->registerNamespaces(array(
$loader->addPrefixes(array(
'Symfony' => array(__DIR__.'/src', __DIR__.'/symfony/src'),
'Doctrine\\Common' => __DIR__.'/vendor/doctrine-common/lib',
'Doctrine' => __DIR__.'/vendor/doctrine/lib',
......@@ -55,16 +55,20 @@ $loader->registerNamespaces(array(
));
```
For better performance, you can use the APC based version of the universal
class loader:
For better performance, you can use the APC class loader:
```php
require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php';
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ClassLoader.php';
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcClassLoader.php';
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
use Symfony\Component\ClassLoader\ClassLoader;
use Symfony\Component\ClassLoader\ApcClassLoader;
$loader = new ApcUniversalClassLoader('apc.prefix.');
$loader = new ClassLoader();
$loader->addPrefix('Symfony', __DIR__.'/src');
$loader = new ApcClassLoader('apc.prefix.', $loader);
$loader->register();
```
Furthermore, the component provides tools to aggregate classes into a single
......
......@@ -146,6 +146,38 @@ public function getDifferentOrdersForTraits()
);
}
public function testFixClassWithTraitsOrdering()
{
if (PHP_VERSION_ID < 50400) {
$this->markTestSkipped('Requires PHP > 5.4');
return;
}
require_once __DIR__.'/Fixtures/ClassesWithParents/CTrait.php';
require_once __DIR__.'/Fixtures/ClassesWithParents/F.php';
require_once __DIR__.'/Fixtures/ClassesWithParents/G.php';
$classes = array(
'ClassesWithParents\\F',
'ClassesWithParents\\G',
);
$expected = array(
'ClassesWithParents\\CTrait',
'ClassesWithParents\\F',
'ClassesWithParents\\G',
);
$r = new \ReflectionClass('Symfony\Component\ClassLoader\ClassCollectionLoader');
$m = $r->getMethod('getOrderedClasses');
$m->setAccessible(true);
$ordered = $m->invoke('Symfony\Component\ClassLoader\ClassCollectionLoader', $classes);
$this->assertEquals($expected, array_map(function ($class) { return $class->getName(); }, $ordered));
}
/**
* @dataProvider getFixNamespaceDeclarationsData
*/
......
......@@ -16,7 +16,7 @@
class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
{
/**
* @var string $workspace
* @var string|null
*/
private $workspace = null;
......
......@@ -13,10 +13,12 @@
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
class LegacyApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
if (!extension_loaded('apc')) {
$this->markTestSkipped('The apc extension is not available.');
}
......
......@@ -13,8 +13,13 @@
use Symfony\Component\ClassLoader\UniversalClassLoader;
class UniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
class LegacyUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
}
/**
* @dataProvider getLoadClassTests
*/
......
......@@ -57,6 +57,8 @@
* @author Fabien Potencier <fabien@symfony.com>
*
* @api
*
* @deprecated Deprecated since version 2.4, to be removed in 3.0. Use the ClassLoader class instead.
*/
class UniversalClassLoader
{
......@@ -68,7 +70,7 @@ class UniversalClassLoader
/**
* Turns on searching the include for class files. Allows easy loading
* of installed PEAR packages
* of installed PEAR packages.
*
* @param bool $useIncludePath
*/
......@@ -173,7 +175,7 @@ public function registerPrefixFallback($dir)
}
/**
* Registers an array of namespaces
* Registers an array of namespaces.
*