Commit 73b7d8da authored by webchick's avatar webchick

Issue #1834594 by effulgentsia, Rob Loach: Update dependencies (Symfony and Twig).

parent d06d55ce
......@@ -3,15 +3,15 @@
"description": "Drupal is an open source content management platform powering millions of websites and applications.",
"license": "GPL-2.0+",
"require": {
"symfony/class-loader": "2.1.*",
"symfony/dependency-injection": "2.1.*",
"symfony/event-dispatcher": "2.1.*",
"symfony/http-foundation": "2.1.*",
"symfony/http-kernel": "2.1.*",
"symfony/routing": "2.1.*",
"symfony/serializer": "2.1.*",
"symfony/yaml": "2.1.*",
"twig/twig": "1.8.*",
"symfony/class-loader": "<2.4@dev",
"symfony/dependency-injection": "<2.4@dev",
"symfony/event-dispatcher": "<2.4@dev",
"symfony/http-foundation": "<2.4@dev",
"symfony/http-kernel": "<2.4@dev",
"symfony/routing": "<2.4@dev",
"symfony/serializer": "<2.4@dev",
"symfony/yaml": "<2.4@dev",
"twig/twig": "1.*",
"doctrine/common": "2.3.*",
"guzzle/http": "3.*",
"kriswallsmith/assetic": "1.1.*"
......
This diff is collapsed.
......@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit::getLoader();
return ComposerAutoloaderInitac017267abab05dbc458e3a320f5ad98::getLoader();
......@@ -6,4 +6,5 @@
$baseDir = dirname($vendorDir);
return array(
'SessionHandlerInterface' => $baseDir . '/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php',
);
......@@ -2,19 +2,27 @@
// autoload_real.php generated by Composer
require __DIR__ . '/ClassLoader.php';
class ComposerAutoloaderInit
class ComposerAutoloaderInitac017267abab05dbc458e3a320f5ad98
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== static::$loader) {
return static::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitac017267abab05dbc458e3a320f5ad98', 'loadClassLoader'));
static::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitac017267abab05dbc458e3a320f5ad98', 'loadClassLoader'));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
......
This diff is collapsed.
{
"name": "doctrine/common",
"type": "library","version":"2.3.0-RC2",
"type": "library",
"description": "Common Library for Doctrine projects",
"keywords": ["collections", "spl", "eventmanager", "annotations", "persistence"],
"homepage": "http://www.doctrine-project.org",
......
......@@ -52,6 +52,24 @@ final class DocLexer extends Lexer
const T_NULL = 111;
const T_COLON = 112;
protected $noCase = array(
'@' => self::T_AT,
',' => self::T_COMMA,
'(' => self::T_OPEN_PARENTHESIS,
')' => self::T_CLOSE_PARENTHESIS,
'{' => self::T_OPEN_CURLY_BRACES,
'}' => self::T_CLOSE_CURLY_BRACES,
'=' => self::T_EQUALS,
':' => self::T_COLON,
'\\' => self::T_NAMESPACE_SEPARATOR
);
protected $withCase = array(
'true' => self::T_TRUE,
'false' => self::T_FALSE,
'null' => self::T_NULL
);
/**
* {@inheritdoc}
*/
......@@ -83,61 +101,30 @@ protected function getType(&$value)
{
$type = self::T_NONE;
// Checking numeric value
if (is_numeric($value)) {
return (strpos($value, '.') !== false || stripos($value, 'e') !== false)
? self::T_FLOAT : self::T_INTEGER;
}
if ($value[0] === '"') {
$value = str_replace('""', '"', substr($value, 1, strlen($value) - 2));
return self::T_STRING;
} else {
switch (strtolower($value)) {
case '@':
return self::T_AT;
case ',':
return self::T_COMMA;
case '(':
return self::T_OPEN_PARENTHESIS;
case ')':
return self::T_CLOSE_PARENTHESIS;
case '{':
return self::T_OPEN_CURLY_BRACES;
case '}':
return self::T_CLOSE_CURLY_BRACES;
case '=':
return self::T_EQUALS;
case '\\':
return self::T_NAMESPACE_SEPARATOR;
case 'true':
return self::T_TRUE;
}
case 'false':
return self::T_FALSE;
if (isset($this->noCase[$value])) {
return $this->noCase[$value];
}
case 'null':
return self::T_NULL;
if ($value[0] === '_' || $value[0] === '\\' || ctype_alpha($value[0])) {
return self::T_IDENTIFIER;
}
case ':':
return self::T_COLON;
$lowerValue = strtolower($value);
default:
if (ctype_alpha($value[0]) || $value[0] === '_' || $value[0] === '\\') {
return self::T_IDENTIFIER;
}
if (isset($this->withCase[$lowerValue])) {
return $this->withCase[$lowerValue];
}
break;
}
// Checking numeric value
if (is_numeric($value)) {
return (strpos($value, '.') !== false || stripos($value, 'e') !== false)
? self::T_FLOAT : self::T_INTEGER;
}
return $type;
......
......@@ -102,7 +102,7 @@ protected function getFilename($id)
*/
protected function doDelete($id)
{
return unlink($this->getFilename($id));
return @unlink($this->getFilename($id));
}
/**
......@@ -116,7 +116,7 @@ protected function doFlush()
$iterator = new \RegexIterator($iterator, $pattern);
foreach ($iterator as $name => $file) {
unlink($name);
@unlink($name);
}
return true;
......
......@@ -36,7 +36,7 @@ class Version
/**
* Current Doctrine Version
*/
const VERSION = '2.3.0-RC2';
const VERSION = '2.3.0';
/**
* Compares a Doctrine version with the current one.
......
......@@ -42,28 +42,35 @@
class ApcClassLoader
{
private $prefix;
private $classFinder;
/**
* The class loader object being decorated.
*
* @var \Symfony\Component\ClassLoader\ClassLoader
* A class loader object that implements the findFile() method.
*/
protected $decorated;
/**
* Constructor.
*
* @param string $prefix A prefix to create a namespace in APC
* @param object $classFinder An object that implements findFile() method.
* @param string $prefix The APC namespace prefix to use.
* @param object $decorated A class loader object that implements the findFile() method.
*
* @api
*/
public function __construct($prefix, $classFinder)
public function __construct($prefix, $decorated)
{
if (!extension_loaded('apc')) {
throw new \RuntimeException('Unable to use ApcClassLoader as APC is not enabled.');
}
if (!method_exists($classFinder, 'findFile')) {
if (!method_exists($decorated, 'findFile')) {
throw new \InvalidArgumentException('The class finder must implement a "findFile" method.');
}
$this->prefix = $prefix;
$this->classFinder = $classFinder;
$this->decorated = $decorated;
}
/**
......@@ -110,9 +117,18 @@ public function loadClass($class)
public function findFile($class)
{
if (false === $file = apc_fetch($this->prefix.$class)) {
apc_store($this->prefix.$class, $file = $this->classFinder->findFile($class));
apc_store($this->prefix.$class, $file = $this->decorated->findFile($class));
}
return $file;
}
/**
* Passes through all unknown calls onto the decorated object.
*/
public function __call($method, $args)
{
return call_user_func_array(array($this->decorated, $method), $args);
}
}
......@@ -20,6 +20,7 @@ class ClassCollectionLoader
{
private static $loaded;
private static $seen;
private static $useTokenizer = true;
/**
* Loads a list of classes and caches them in one big file.
......@@ -103,14 +104,14 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
$c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($class->getFileName()));
// add namespace declaration for global code
// fakes namespace declaration for global code
if (!$class->inNamespace()) {
$c = "\nnamespace\n{\n".self::stripComments($c)."\n}\n";
} else {
$c = self::fixNamespaceDeclarations('<?php '.$c);
$c = preg_replace('/^\s*<\?php/', '', $c);
$c = "\nnamespace\n{\n".$c."\n}\n";
}
$c = self::fixNamespaceDeclarations('<?php '.$c);
$c = preg_replace('/^\s*<\?php/', '', $c);
$content .= $c;
}
......@@ -135,7 +136,11 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
*/
public static function fixNamespaceDeclarations($source)
{
if (!function_exists('token_get_all')) {
if (!function_exists('token_get_all') || !self::$useTokenizer) {
if (preg_match('/namespace(.*?)\s*;/', $source)) {
$source = preg_replace('/namespace(.*?)\s*;/', "namespace$1\n{", $source)."}\n";
}
return $source;
}
......@@ -200,43 +205,12 @@ private static function writeCacheFile($file, $content)
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
}
/**
* Removes comments from a PHP source string.
*
* We don't use the PHP php_strip_whitespace() function
* as we want the content to be readable and well-formatted.
*
* @param string $source A PHP string
*
* @return string The PHP string with the comments removed
*/
private static function stripComments($source)
{
if (!function_exists('token_get_all')) {
return $source;
}
$output = '';
foreach (token_get_all($source) as $token) {
if (is_string($token)) {
$output .= $token;
} elseif (!in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
$output .= $token[1];
}
}
// replace multiple new lines with a single newline
$output = preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $output);
return $output;
}
/**
* Gets an ordered array of passed classes including all their dependencies.
*
* @param array $classes
*
* @return array An array of sorted \ReflectionClass instances (dependencies added if needed)
* @return \ReflectionClass[] An array of sorted \ReflectionClass instances (dependencies added if needed)
*
* @throws \InvalidArgumentException When a class can't be loaded
*/
......@@ -317,4 +291,12 @@ private static function getTraits(\ReflectionClass $class)
return $classes;
}
/**
* This method is only useful for testing.
*/
public static function enableTokenizer($bool)
{
self::$useTokenizer = (Boolean) $bool;
}
}
......@@ -64,9 +64,6 @@ Resources
You can run the unit tests with the following command:
phpunit
If you also want to run the unit tests that depend on other Symfony
Components, install dev dependencies before running PHPUnit:
php composer.phar install --dev
$ cd path/to/Symfony/Component/ClassLoader/
$ composer.phar install --dev
$ phpunit
......@@ -117,60 +117,93 @@ public function getDifferentOrdersForTraits()
);
}
public function testFixNamespaceDeclarations()
/**
* @dataProvider getFixNamespaceDeclarationsData
*/
public function testFixNamespaceDeclarations($source, $expected)
{
$source = <<<EOF
<?php
$this->assertEquals('<?php '.$expected, ClassCollectionLoader::fixNamespaceDeclarations('<?php '.$source));
}
namespace Foo;
class Foo {}
namespace Bar ;
class Foo {}
namespace Foo\Bar;
class Foo {}
namespace Foo\Bar\Bar
{
class Foo {}
}
namespace
{
class Foo {}
}
EOF;
/**
* @dataProvider getFixNamespaceDeclarationsData
*/
public function testFixNamespaceDeclarationsWithoutTokenizer($source, $expected)
{
ClassCollectionLoader::enableTokenizer(false);
$this->assertEquals('<?php '.$expected, ClassCollectionLoader::fixNamespaceDeclarations('<?php '.$source));
ClassCollectionLoader::enableTokenizer(true);
}
$expected = <<<EOF
<?php
public function getFixNamespaceDeclarationsData()
{
return array(
array("namespace;\nclass Foo {}\n", "namespace\n{\nclass Foo {}\n}\n"),
array("namespace Foo;\nclass Foo {}\n", "namespace Foo\n{\nclass Foo {}\n}\n"),
array("namespace Bar ;\nclass Foo {}\n", "namespace Bar\n{\nclass Foo {}\n}\n"),
array("namespace Foo\Bar;\nclass Foo {}\n", "namespace Foo\Bar\n{\nclass Foo {}\n}\n"),
array("namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n", "namespace Foo\Bar\Bar\n{\nclass Foo {}\n}\n"),
array("namespace\n{\nclass Foo {}\n}\n", "namespace\n{\nclass Foo {}\n}\n"),
);
}
namespace Foo
{
class Foo {}
}
namespace Bar
/**
* @expectedException InvalidArgumentException
*/
public function testUnableToLoadClassException()
{
if (is_file($file = sys_get_temp_dir().'/foo.php')) {
unlink($file);
}
ClassCollectionLoader::load(array('SomeNotExistingClass'), sys_get_temp_dir(), 'foo', false);
}
public function testCommentStripping()
{
if (is_file($file = sys_get_temp_dir().'/bar.php')) {
unlink($file);
}
spl_autoload_register($r = function ($class) {
require_once __DIR__.'/Fixtures/'.str_replace(array('\\', '_'), '/', $class).'.php';
});
ClassCollectionLoader::load(array('Namespaced\\WithComments', 'Pearlike_WithComments'), sys_get_temp_dir(), 'bar', false);
spl_autoload_unregister($r);
$this->assertEquals(<<<EOF
<?php