Commit d822f213 authored by webchick's avatar webchick

Issue #2088651 by pwolanin: Update symfony components to latest 2.3.*.

parent 99670f08
This diff is collapsed.
<?php <?php
// autoload.php generated by Composer // autoload.php @generated by Composer
require_once __DIR__ . '/composer' . '/autoload_real.php'; require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit3a4905090abf2f2252330204ffd02eb8::getLoader(); return ComposerAutoloaderInit0b93b0210b8b39c2a0b13410cd082de9::getLoader();
<?php <?php
// autoload_classmap.php generated by Composer // autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname(dirname($vendorDir)); $baseDir = dirname(dirname($vendorDir));
......
<?php
// autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname(dirname($vendorDir));
return array(
$vendorDir . '/kriswallsmith/assetic/src/functions.php',
$baseDir . '/core/lib/Drupal.php',
);
\ No newline at end of file
<?php <?php
// autoload_namespaces.php generated by Composer // autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname(dirname($vendorDir)); $baseDir = dirname(dirname($vendorDir));
......
<?php <?php
// autoload_real.php generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderInit3a4905090abf2f2252330204ffd02eb8 class ComposerAutoloaderInit0b93b0210b8b39c2a0b13410cd082de9
{ {
private static $loader; private static $loader;
...@@ -19,9 +19,9 @@ public static function getLoader() ...@@ -19,9 +19,9 @@ public static function getLoader()
return self::$loader; return self::$loader;
} }
spl_autoload_register(array('ComposerAutoloaderInit3a4905090abf2f2252330204ffd02eb8', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInit0b93b0210b8b39c2a0b13410cd082de9', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit3a4905090abf2f2252330204ffd02eb8', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInit0b93b0210b8b39c2a0b13410cd082de9', 'loadClassLoader'));
$vendorDir = dirname(__DIR__); $vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir)); $baseDir = dirname(dirname($vendorDir));
...@@ -42,8 +42,10 @@ public static function getLoader() ...@@ -42,8 +42,10 @@ public static function getLoader()
$loader->register(true); $loader->register(true);
require $vendorDir . '/kriswallsmith/assetic/src/functions.php'; $includeFiles = require __DIR__ . '/autoload_files.php';
require $baseDir . '/core/lib/Drupal.php'; foreach ($includeFiles as $file) {
require $file;
}
return $loader; return $loader;
} }
......
<?php <?php
// include_paths.php generated by Composer // include_paths.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__)); $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname(dirname($vendorDir)); $baseDir = dirname(dirname($vendorDir));
......
This source diff could not be displayed because it is too large. You can view the blob instead.
vendor/ vendor/
composer.lock composer.lock
phpunit.xml phpunit.xml
...@@ -177,7 +177,7 @@ public function findFile($class) ...@@ -177,7 +177,7 @@ public function findFile($class)
$classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; $classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
foreach ($this->prefixes as $prefix => $dirs) { foreach ($this->prefixes as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) { if ($class === strstr($class, $prefix)) {
foreach ($dirs as $dir) { foreach ($dirs as $dir) {
if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) { if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
return $dir.DIRECTORY_SEPARATOR.$classPath; return $dir.DIRECTORY_SEPARATOR.$classPath;
......
...@@ -104,6 +104,7 @@ public function handle($level, $message, $file = 'unknown', $line = 0, $context ...@@ -104,6 +104,7 @@ public function handle($level, $message, $file = 'unknown', $line = 0, $context
$stack = array_map( $stack = array_map(
function ($row) { function ($row) {
unset($row['args']); unset($row['args']);
return $row; return $row;
}, },
array_slice(debug_backtrace(false), 0, 10) array_slice(debug_backtrace(false), 0, 10)
...@@ -119,6 +120,11 @@ function ($row) { ...@@ -119,6 +120,11 @@ function ($row) {
} }
if ($this->displayErrors && error_reporting() & $level && $this->level & $level) { if ($this->displayErrors && error_reporting() & $level && $this->level & $level) {
// make sure the ContextErrorException class is loaded (https://bugs.php.net/bug.php?id=65322)
if (!class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
require __DIR__.'/Exception/ContextErrorException.php';
}
throw new ContextErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line), 0, $level, $file, $line, $context); throw new ContextErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line), 0, $level, $file, $line, $context);
} }
......
...@@ -19,18 +19,18 @@ ...@@ -19,18 +19,18 @@
class ContextErrorException extends \ErrorException class ContextErrorException extends \ErrorException
{ {
private $context = array(); private $context = array();
public function __construct($message, $code, $severity, $filename, $lineno, $context = array()) public function __construct($message, $code, $severity, $filename, $lineno, $context = array())
{ {
parent::__construct($message, $code, $severity, $filename, $lineno); parent::__construct($message, $code, $severity, $filename, $lineno);
$this->context = $context; $this->context = $context;
} }
/** /**
* @return array Array of variables that existed when the exception occured * @return array Array of variables that existed when the exception occured
*/ */
public function getContext() public function getContext()
{ {
return $this->context; return $this->context;
} }
} }
...@@ -20,6 +20,31 @@ ...@@ -20,6 +20,31 @@
*/ */
class ErrorHandlerTest extends \PHPUnit_Framework_TestCase class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
{ {
public function testCompileTimeError()
{
// the ContextErrorException must not be loaded for this test to work
if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) {
$this->markTestSkipped('The ContextErrorException class is already loaded.');
}
$handler = ErrorHandler::register(E_ALL | E_STRICT);
$displayErrors = ini_get('display_errors');
ini_set('display_errors', '1');
try {
// trigger compile time error
eval(<<<'PHP'
class _BaseCompileTimeError { function foo() {} }
class _CompileTimeError extends _BaseCompileTimeError { function foo($invalid) {} }
PHP
);
} catch(\Exception $e) {
// if an exception is thrown, the test passed
}
ini_set('display_errors', $displayErrors);
restore_error_handler();
}
public function testConstruct() public function testConstruct()
{ {
......
...@@ -87,6 +87,7 @@ private function resolveDefinition($id, DefinitionDecorator $definition) ...@@ -87,6 +87,7 @@ private function resolveDefinition($id, DefinitionDecorator $definition)
$def->setConfigurator($parentDef->getConfigurator()); $def->setConfigurator($parentDef->getConfigurator());
$def->setFile($parentDef->getFile()); $def->setFile($parentDef->getFile());
$def->setPublic($parentDef->isPublic()); $def->setPublic($parentDef->isPublic());
$def->setLazy($parentDef->isLazy());
// overwrite with values specified in the decorator // overwrite with values specified in the decorator
$changes = $definition->getChanges(); $changes = $definition->getChanges();
...@@ -111,6 +112,9 @@ private function resolveDefinition($id, DefinitionDecorator $definition) ...@@ -111,6 +112,9 @@ private function resolveDefinition($id, DefinitionDecorator $definition)
if (isset($changes['public'])) { if (isset($changes['public'])) {
$def->setPublic($definition->isPublic()); $def->setPublic($definition->isPublic());
} }
if (isset($changes['lazy'])){
$def->setLazy($definition->isLazy());
}
// merge arguments // merge arguments
foreach ($definition->getArguments() as $k => $v) { foreach ($definition->getArguments() as $k => $v) {
......
...@@ -88,6 +88,7 @@ public function __construct(ParameterBagInterface $parameterBag = null) ...@@ -88,6 +88,7 @@ public function __construct(ParameterBagInterface $parameterBag = null)
$this->parameterBag = null === $parameterBag ? new ParameterBag() : $parameterBag; $this->parameterBag = null === $parameterBag ? new ParameterBag() : $parameterBag;
$this->services = array(); $this->services = array();
$this->aliases = array();
$this->scopes = array(); $this->scopes = array();
$this->scopeChildren = array(); $this->scopeChildren = array();
$this->scopedServices = array(); $this->scopedServices = array();
...@@ -183,6 +184,9 @@ public function setParameter($name, $value) ...@@ -183,6 +184,9 @@ public function setParameter($name, $value)
/** /**
* Sets a service. * Sets a service.
* *
* Setting a service to null resets the service: has() returns false and get()
* behaves in the same way as if the service was never created.
*
* @param string $id The service identifier * @param string $id The service identifier
* @param object $service The service instance * @param object $service The service instance
* @param string $scope The scope of the service * @param string $scope The scope of the service
...@@ -213,6 +217,14 @@ public function set($id, $service, $scope = self::SCOPE_CONTAINER) ...@@ -213,6 +217,14 @@ public function set($id, $service, $scope = self::SCOPE_CONTAINER)
if (method_exists($this, $method = 'synchronize'.strtr($id, array('_' => '', '.' => '_')).'Service')) { if (method_exists($this, $method = 'synchronize'.strtr($id, array('_' => '', '.' => '_')).'Service')) {
$this->$method(); $this->$method();
} }
if (self::SCOPE_CONTAINER !== $scope && null === $service) {
unset($this->scopedServices[$scope][$id]);
}
if (null === $service) {
unset($this->services[$id]);
}
} }
/** /**
...@@ -228,7 +240,10 @@ public function has($id) ...@@ -228,7 +240,10 @@ public function has($id)
{ {
$id = strtolower($id); $id = strtolower($id);
return array_key_exists($id, $this->services) || method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_')).'Service'); return array_key_exists($id, $this->services)
|| array_key_exists($id, $this->aliases)
|| method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')
;
} }
/** /**
...@@ -509,7 +524,7 @@ public function isScopeActive($name) ...@@ -509,7 +524,7 @@ public function isScopeActive($name)
*/ */
public static function camelize($id) public static function camelize($id)
{ {
return preg_replace_callback('/(^|_|\.)+(.)/', function ($match) { return ('.' === $match[1] ? '_' : '').strtoupper($match[2]); }, $id); return strtr(ucwords(strtr($id, array('_' => ' ', '.' => '_ '))), array(' ' => ''));
} }
/** /**
......
...@@ -149,6 +149,18 @@ public function setPublic($boolean) ...@@ -149,6 +149,18 @@ public function setPublic($boolean)
return parent::setPublic($boolean); return parent::setPublic($boolean);
} }
/**
* {@inheritDoc}
*
* @api
*/
public function setLazy($boolean)
{
$this->changes['lazy'] = true;
return parent::setLazy($boolean);
}
/** /**
* Gets an argument to pass to the service constructor/factory method. * Gets an argument to pass to the service constructor/factory method.
* *
......
...@@ -490,7 +490,6 @@ private function addServiceConfigurator($id, $definition, $variableName = 'insta ...@@ -490,7 +490,6 @@ private function addServiceConfigurator($id, $definition, $variableName = 'insta
*/ */
private function addService($id, $definition) private function addService($id, $definition)
{ {
$name = Container::camelize($id);
$this->definitionVariables = new \SplObjectStorage(); $this->definitionVariables = new \SplObjectStorage();
$this->referenceVariables = array(); $this->referenceVariables = array();
$this->variableCount = 0; $this->variableCount = 0;
...@@ -555,7 +554,7 @@ private function addService($id, $definition) ...@@ -555,7 +554,7 @@ private function addService($id, $definition)
*$lazyInitializationDoc *$lazyInitializationDoc
* $return * $return
*/ */
{$visibility} function get{$name}Service($lazyInitialization) {$visibility} function get{$this->camelize($id)}Service($lazyInitialization)
{ {
EOF; EOF;
...@@ -656,14 +655,12 @@ private function addServiceSynchronizer($id, Definition $definition) ...@@ -656,14 +655,12 @@ private function addServiceSynchronizer($id, Definition $definition)
return; return;
} }
$name = Container::camelize($id);
return <<<EOF return <<<EOF
/** /**
* Updates the '$id' service. * Updates the '$id' service.
*/ */
protected function synchronize{$name}Service() protected function synchronize{$this->camelize($id)}Service()
{ {
$code } $code }
...@@ -835,7 +832,7 @@ private function addMethodMap() ...@@ -835,7 +832,7 @@ private function addMethodMap()
$code = " \$this->methodMap = array(\n"; $code = " \$this->methodMap = array(\n";
ksort($definitions); ksort($definitions);
foreach ($definitions as $id => $definition) { foreach ($definitions as $id => $definition) {
$code .= ' '.var_export($id, true).' => '.var_export('get'.Container::camelize($id).'Service', true).",\n"; $code .= ' '.var_export($id, true).' => '.var_export('get'.$this->camelize($id).'Service', true).",\n";
} }
return $code . " );\n"; return $code . " );\n";
...@@ -849,7 +846,11 @@ private function addMethodMap() ...@@ -849,7 +846,11 @@ private function addMethodMap()
private function addAliases() private function addAliases()
{ {
if (!$aliases = $this->container->getAliases()) { if (!$aliases = $this->container->getAliases()) {
return ''; if ($this->container->isFrozen()) {
return "\n \$this->aliases = array();\n";
} else {
return '';
}
} }
$code = " \$this->aliases = array(\n"; $code = " \$this->aliases = array(\n";
...@@ -1256,6 +1257,26 @@ private function getServiceCall($id, Reference $reference = null) ...@@ -1256,6 +1257,26 @@ private function getServiceCall($id, Reference $reference = null)
} }
} }
/**
* Convert a service id to a valid PHP method name.
*
* @param string $id
*
* @return string
*
* @throws InvalidArgumentException
*/
private function camelize($id)
{
$name = Container::camelize($id);
if (!preg_match('/^[a-zA-Z0-9_\x7f-\xff]+$/', $name)) {
throw new InvalidArgumentException(sprintf('Service id "%s" cannot be converted to a valid PHP method name.', $id));
}
return $name;
}
/** /**
* Returns the next name to use * Returns the next name to use
* *
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
namespace Symfony\Component\DependencyInjection\LazyProxy\PhpDumper; namespace Symfony\Component\DependencyInjection\LazyProxy\PhpDumper;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Definition;
/** /**
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
namespace Symfony\Component\DependencyInjection\LazyProxy\PhpDumper; namespace Symfony\Component\DependencyInjection\LazyProxy\PhpDumper;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Definition;
/** /**
......
...@@ -143,6 +143,36 @@ public function testProcessHandlesMultipleInheritance() ...@@ -143,6 +143,36 @@ public function testProcessHandlesMultipleInheritance()
$this->assertEquals('foo', $def->getClass()); $this->assertEquals('foo', $def->getClass());
} }
public function testSetLazyOnServiceHasParent()
{
$container = new ContainerBuilder();
$container->register('parent','stdClass');
$container->setDefinition('child1',new DefinitionDecorator('parent'))
->setLazy(true)
;
$this->process($container);
$this->assertTrue($container->getDefinition('child1')->isLazy());
}
public function testSetLazyOnServiceIsParent()
{
$container = new ContainerBuilder();
$container->register('parent','stdClass')
->setLazy(true)
;
$container->setDefinition('child1',new DefinitionDecorator('parent'));
$this->process($container);
$this->assertTrue($container->getDefinition('child1')