8000 Merge branch '2.4' into 2.5 · symfony/symfony@8d75b4b · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d75b4b

Browse files
committed
Merge branch '2.4' into 2.5
* 2.4: [Debug] fixed class lookup when using PSR-0 with a target dir fixed standalone tests fixed standalone tests [Validator] fixed component standalone tests fixed standalone component tests depending on Validator and Form fixed some composer.json to make standalone component tests pass [SecurityBundle] fixed tests when used in standalone Conflicts: src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php src/Symfony/Component/Validator/composer.json
2 parents aa5179b + cff4bbb commit 8d75b4b

File tree

13 files changed

+72
-42
lines changed

13 files changed

+72
-42
lines changed

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"twig/twig": "~1.12"
2222
},
2323
"require-dev": {
24-
"symfony/form": "~2.2",
24+
"symfony/form": "~2.5",
2525
"symfony/http-kernel": "~2.2",
2626
"symfony/routing": "~2.2",
2727
"symfony/templating": "~2.1",

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Console\Command\Command;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Definition;
18+
use Symfony\Component\HttpKernel\Bundle\Bundle;
1819

1920
class AddConsoleCommandPassTest extends \PHPUnit_Framework_TestCase
2021
{
@@ -87,8 +88,32 @@ public function testProcessThrowAnExceptionIfTheServiceIsNotASubclassOfCommand()
8788

8889
$container->compile();
8990
}
91+
92+
public function testHttpKernelRegisterCommandsIngoreCommandAsAService()
93+
{
94+
$container = new ContainerBuilder();
95+
$container->addCompilerPass(new AddConsoleCommandPass());
96+
$definition = new Definition('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\MyCommand');
97+
$definition->addTag('console.command');
98+
$container->setDefinition('my-command', $definition);
99+
$container->compile();
100+
101+
$application = $this->getMock('Symfony\Component\Console\Application');
102+
// Never called, because it's the
103+
// Symfony\Bundle\FrameworkBundle\Console\Application that register
104+
// commands as a service
105+
$application->expects($this->never())->method('add');
106+
107+
$bundle = new ExtensionPresentBundle();
108+
$bundle->setContainer($container);
109+
$bundle->registerCommands($application);
110+
}
90111
}
91112

92113
class MyCommand extends Command
93114
{
94115
}
116+
117+
class ExtensionPresentBundle extends Bundle
118+
{
119+
}

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@
3636
"symfony/console": "~2.0",
3737
"symfony/finder": "~2.0",
3838
"symfony/security": "~2.4",
39-
"symfony/form": "~2.4",
39+
"symfony/form": "~2.5",
4040
"symfony/class-loader": "~2.1",
41+
"symfony/expression-language": "~2.4",
4142
"symfony/process": "~2.0",
42-
"symfony/validator": "~2.1",
43+
"symfony/validator": "~2.5",
4344
"symfony/yaml": "~2.0"
4445
},
4546
"suggest": {

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"require-dev": {
2424
"symfony/browser-kit": "~2.3",
2525
"symfony/form": "~2.3",
26-
"symfony/framework-bundle": "~2.2",
26+
"symfony/framework-bundle": "~2.2,<2.6.0",
2727
"symfony/twig-bundle": "~2.2",
2828
"symfony/process": "~2.0",
2929
"symfony/validator": "~2.2",

src/Symfony/Bundle/TwigBundle/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"require-dev": {
2525
"symfony/stopwatch": "~2.2",
2626
"symfony/dependency-injection": "~2.0",
27+
"symfony/expression-language": "~2.4",
2728
"symfony/config": "~2.2",
2829
"symfony/routing": "~2.1",
2930
"symfony/templating": "~2.1",

src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ private function getClassCandidates($class)
117117
}
118118

119119
if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader) {
120-
foreach ($function[0]->getPrefixes() as $paths) {
120+
foreach ($function[0]->getPrefixes() as $prefix => $paths) {
121121
foreach ($paths as $path) {
122-
$classes = array_merge($classes, $this->findClassInPath($path, $class));
122+
$classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
123123
}
124124
}
125125
}
@@ -131,10 +131,11 @@ private function getClassCandidates($class)
131131
/**
132132
* @param string $path
133133
* @param string $class
134+
* @param string $prefix
134135
*
135136
* @return array
136137
*/
137-
private function findClassInPath($path, $class)
138+
private function findClassInPath($path, $class, $prefix)
138139
{
139140
if (!$path = realpath($path)) {
140141
return array();
@@ -143,7 +144,7 @@ private function findClassInPath($path, $class)
143144
$classes = array();
144145
$filename = $class.'.php';
145146
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
146-
if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName())) {
147+
if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) {
147148
$classes[] = $class;
148149
}
149150
}
@@ -154,27 +155,38 @@ private function findClassInPath($path, $class)
154155
/**
155156
* @param string $path
156157
* @param string $file
158+
* @param string $prefix
157159
*
158160
* @return string|null
159161
*/
160-
private function convertFileToClass($path, $file)
162+
private function convertFileToClass($path, $file, $prefix)
161163
{
162-
$namespacedClass = str_replace(array($path.DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file);
163-
$pearClass = str_replace('\\', '_', $namespacedClass);
164+
$candidates = array(
165+
// namespaced class
166+
$namespacedClass = str_replace(array($path.DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file),
167+
// namespaced class (with target dir)
168+
$namespacedClassTargetDir = $prefix.str_replace(array($path.DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file),
169+
// PEAR class
170+
str_replace('\\', '_', $namespacedClass),
171+
// PEAR class (with target dir)
172+
str_replace('\\', '_', $namespacedClassTargetDir),
173+
);
164174

165175
// We cannot use the autoloader here as most of them use require; but if the class
166176
// is not found, the new autoloader call will require the file again leading to a
167177
// "cannot redeclare class" error.
168-
if (!$this->classExists($namespacedClass) && !$this->classExists($pearClass)) {
169-
require_once $file;
178+
foreach ($candidates as $candidate) {
179+
if ($this->classExists($candidate)) {
180+
return $candidate;
181+
}
170182
}
171183

172-
if ($this->classExists($namespacedClass)) {
173-
return $namespacedClass;
174-
}
184+
require_once $file;
175185

176-
if ($this->classExists($pearClass)) {
177-
return $pearClass;
186+
foreach ($candidates as $candidate) {
187+
if ($this->classExists($candidate)) {
188+
return $candidate;
189+
}
178190
}
179191
}
180192

src/Symfony/Component/Form/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"symfony/property-access": "~2.3"
2424
},
2525
"require-dev": {
26-
"symfony/validator": "~2.4",
26+
"symfony/validator": "~2.5",
2727
"symfony/http-foundation": "~2.2",
2828
"symfony/http-kernel": "~2.4",
2929
"symfony/security-csrf": "~2.4",

src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,4 @@ public function testRegisterCommands()
3232

3333
$this->assertNull($bundle2->registerCommands($app));
3434
}
35-
36-
public function testRegisterCommandsIngoreCommandAsAService()
37-
{
38-
$container = new ContainerBuilder();
39-
$commandClass = 'Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand';
40-
$definition = new Definition($commandClass);
41-
$definition->addTag('console.command');
42-
$container->setDefinition('my-command', $definition);
43-
$container->setAlias('console.command.'.strtolower(str_replace('\\', '_', $commandClass)), 'my-command');
44-
$container->compile();
45-
46-
$application = $this->getMock('Symfony\Component\Console\Application');
47-
// Never called, because it's the
48-
// Symfony\Bundle\FrameworkBundle\Console\Application that register
49-
// commands as a service
50-
$application->expects($this->never())->method('add');
51-
52-
$bundle = new ExtensionPresentBundle();
53-
$bundle->setContainer($container);
54-
$bundle->registerCommands($application);
55-
}
5635
}

src/Symfony/Component/HttpKernel/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"symfony/config": "~2.0",
2929
"symfony/console": "~2.2",
3030
"symfony/dependency-injection": "~2.0",
31+
"symfony/expression-language": "~2.4",
3132
"symfony/finder": "~2.0",
3233
"symfony/process": "~2.0",
3334
"symfony/routing": "~2.2",

src/Symfony/Component/Security/Core/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"symfony/event-dispatcher": "~2.1",
2323
"symfony/expression-language": "~2.4",
2424
"symfony/http-foundation": "~2.4",
25-
"symfony/validator": "~2.2",
25+
"symfony/validator": "~2.5",
2626
"psr/log": "~1.0",
2727
"ircmaxell/password-compat": "1.0.*"
2828
},

src/Symfony/Component/Security/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"require-dev": {
3131
"symfony/routing": "~2.2",
32-
"symfony/validator": "~2.2",
32+
"symfony/validator": "~2.2,<2.5.0",
3333
"doctrine/common": "~2.2",
3434
"doctrine/dbal": "~2.2",
3535
"psr/log": "~1.0",

src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
2424
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
2525

26+
require_once __DIR__.'/../../../Constraints/All.php';
27+
require_once __DIR__.'/../../../Constraints/Callback.php';
28+
require_once __DIR__.'/../../../Constraints/Choice.php';
29+
require_once __DIR__.'/../../../Constraints/Collection.php';
30+
require_once __DIR__.'/../../../Constraints/GroupSequence.php';
31+
require_once __DIR__.'/../../../Constraints/GroupSequenceProvider.php';
32+
require_once __DIR__.'/../../../Constraints/NotNull.php';
33+
require_once __DIR__.'/../../../Constraints/Range.php';
34+
require_once __DIR__.'/../../Fixtures/ConstraintA.php';
35+
2636
class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase
2737
{
2838
public function testLoadClassMetadataReturnsTrueIfSuccessful()

src/Symfony/Component/Validator/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"symfony/yaml": "~2.0",
2626
"symfony/config": "~2.2",
2727
"symfony/property-access": "~2.2",
28+
"symfony/expression-language": "~2.4",
2829
"doctrine/annotations": "~1.0",
2930
"doctrine/cache": "~1.0",
3031
"egulias/email-validator": "~1.0",

0 commit comments

Comments
 (0)
0