Skip to content

Commit 6ff62cc

Browse files
committed
Merge branch '2.4' into 2.5
* 2.4: fix typos [HttpKernel] add use statement for phpdoc Disabled the PHPUnit self-update on Travis [ClassLoader] simplified phpdoc [ClassLoader] Add a __call() method to XcacheClassLoader fix some minor typos in tests [Yaml] fixed mapping keys containing a quoted # Added fixture to test parsing of hash keys ending with a space and # [Filesystem Component] mkdir race condition fix #11626 [Validator] reverted permissions change on translation files Fixed Factory services not within the ServiceReferenceGraph. [CssSelector] Fix URL to SimonSapin/cssselect repo [Validator] Fixed wrong translation keys/messages for Collection constraint. The error messages for a missing field and an unexpected field did not match the Contraint class [YAML] resolve variables in inlined YAML Disallow abstract definitions from doctrine event listener registration Conflicts: src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php src/Symfony/Component/Yaml/Inline.php
2 parents 06de353 + e99dfdf commit 6ff62cc

File tree

66 files changed

+465
-229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+465
-229
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ before_script:
2323
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
2424
- sudo locale-gen fr_FR.UTF-8 && sudo update-locale
2525
- COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install
26-
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "5.3.3" ]; then phpunit --self-update; fi;'
26+
# - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "5.3.3" ]; then phpunit --self-update; fi;'
2727

2828
script:
2929
- ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; phpunit --exclude-group tty,benchmark {};'

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,17 @@ public function process(ContainerBuilder $container)
6969
return $a > $b ? -1 : 1;
7070
};
7171

72-
7372
if (!empty($taggedSubscribers)) {
7473
$subscribersPerCon = $this->groupByConnection($taggedSubscribers);
7574
foreach ($subscribersPerCon as $con => $subscribers) {
7675
$em = $this->getEventManager($con);
7776

7877
uasort($subscribers, $sortFunc);
7978
foreach ($subscribers as $id => $instance) {
79+
if ($container->getDefinition($id)->isAbstract()) {
80+
throw new \InvalidArgumentException(sprintf('The abstract service "%s" cannot be tagged as a doctrine event subscriber.', $id));
81+
}
82+
8083
$em->addMethodCall('addEventSubscriber', array(new Reference($id)));
8184
}
8285
}
@@ -89,6 +92,10 @@ public function process(ContainerBuilder $container)
8992

9093
uasort($listeners, $sortFunc);
9194
foreach ($listeners as $id => $instance) {
95+
if ($container->getDefinition($id)->isAbstract()) {
96+
throw new \InvalidArgumentException(sprintf('The abstract service "%s" cannot be tagged as a doctrine event listener.', $id));
97+
}
98+
9299
$em->addMethodCall('addEventListener', array(
93100
array_unique($instance['event']),
94101
isset($instance['lazy']) && $instance['lazy'] ? $id : new Reference($id),

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,42 @@
1313

1414
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterEventListenersAndSubscribersPass;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Definition;
1617

1718
class RegisterEventListenersAndSubscribersPassTest extends \PHPUnit_Framework_TestCase
1819
{
20+
/**
21+
* @expectedException InvalidArgumentException
22+
*/
23+
public function testExceptionOnAbstractTaggedSubscriber()
24+
{
25+
$container = $this->createBuilder();
26+
27+
$abstractDefinition = new Definition('stdClass');
28+
$abstractDefinition->setAbstract(true);
29+
$abstractDefinition->addTag('doctrine.event_subscriber');
30+
31+
$container->setDefinition('a', $abstractDefinition);
32+
33+
$this->process($container);
34+
}
35+
36+
/**
37+
* @expectedException InvalidArgumentException
38+
*/
39+
public function testExceptionOnAbstractTaggedListener()
40+
{
41+
$container = $this->createBuilder();
42+
43+
$abstractDefinition = new Definition('stdClass');
44+
$abstractDefinition->setAbstract(true);
45+
$abstractDefinition->addTag('doctrine.event_listener', array('event' => 'test'));
46+
47+
$container->setDefinition('a', $abstractDefinition);
48+
49+
$this->process($container);
50+
}
51+
1952
public function testProcessEventListenersWithPriorities()
2053
{
2154
$container = $this->createBuilder();

src/Symfony/Component/ClassLoader/ApcClassLoader.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* ApcClassLoader implements a wrapping autoloader cached in APC for PHP 5.3.
1616
*
1717
* It expects an object implementing a findFile method to find the file. This
18-
* allow using it as a wrapper around the other loaders of the component (the
18+
* allows using it as a wrapper around the other loaders of the component (the
1919
* ClassLoader and the UniversalClassLoader for instance) but also around any
2020
* other autoloader following this convention (the Composer one for instance)
2121
*
@@ -46,7 +46,7 @@ class ApcClassLoader
4646
/**
4747
* The class loader object being decorated.
4848
*
49-
* @var \Symfony\Component\ClassLoader\ClassLoader
49+
* @var object
5050
* A class loader object that implements the findFile() method.
5151
*/
5252
protected $decorated;
@@ -133,5 +133,4 @@ public function __call($method, $args)
133133
{
134134
return call_user_func_array(array($this->decorated, $method), $args);
135135
}
136-
137136
}

src/Symfony/Component/ClassLoader/XcacheClassLoader.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\ClassLoader;
1313

1414
/**
15-
* XcacheClassLoader implements a wrapping autoloader cached in Xcache for PHP 5.3.
15+
* XcacheClassLoader implements a wrapping autoloader cached in XCache for PHP 5.3.
1616
*
1717
* It expects an object implementing a findFile method to find the file. This
1818
* allows using it as a wrapper around the other loaders of the component (the
@@ -43,31 +43,35 @@
4343
class XcacheClassLoader
4444
{
4545
private $prefix;
46-
private $classFinder;
46+
47+
/**
48+
* @var object A class loader object that implements the findFile() method
49+
*/
50+
private $decorated;
4751

4852
/**
4953
* Constructor.
5054
*
51-
* @param string $prefix A prefix to create a namespace in Xcache
52-
* @param object $classFinder An object that implements findFile() method.
55+
* @param string $prefix The XCache namespace prefix to use.
56+
* @param object $decorated A class loader object that implements the findFile() method.
5357
*
5458
* @throws \RuntimeException
5559
* @throws \InvalidArgumentException
5660
*
5761
* @api
5862
*/
59-
public function __construct($prefix, $classFinder)
63+
public function __construct($prefix, $decorated)
6064
{
61-
if (!extension_loaded('Xcache')) {
62-
throw new \RuntimeException('Unable to use XcacheClassLoader as Xcache is not enabled.');
65+
if (!extension_loaded('xcache')) {
66+
throw new \RuntimeException('Unable to use XcacheClassLoader as XCache is not enabled.');
6367
}
6468

65-
if (!method_exists($classFinder, 'findFile')) {
69+
if (!method_exists($decorated, 'findFile')) {
6670
throw new \InvalidArgumentException('The class finder must implement a "findFile" method.');
6771
}
6872

6973
$this->prefix = $prefix;
70-
$this->classFinder = $classFinder;
74+
$this->decorated = $decorated;
7175
}
7276

7377
/**
@@ -116,10 +120,18 @@ public function findFile($class)
116120
if (xcache_isset($this->prefix.$class)) {
117121
$file = xcache_get($this->prefix.$class);
118122
} else {
119-
$file = $this->classFinder->findFile($class);
123+
$file = $this->decorated->findFile($class);
120124
xcache_set($this->prefix.$class, $file);
121125
}
122126

123127
return $file;
124128
}
129+
130+
/**
131+
* Passes through all unknown calls onto the decorated object.
132+
*/
133+
public function __call($method, $args)
134+
{
135+
return call_user_func_array(array($this->decorated, $method), $args);
136+
}
125137
}

src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Config\Definition\Builder;
1313

1414
/**
15-
* Abstract class that contain common code of integer and float node definition.
15+
* Abstract class that contains common code of integer and float node definitions.
1616
*
1717
* @author David Jeanmonod <david.jeanmonod@gmail.com>
1818
*/

src/Symfony/Component/CssSelector/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Resources
3535
This component is a port of the Python lxml library, which is copyright Infrae
3636
and distributed under the BSD license.
3737

38-
Current code is a port of https://github.com/SimonSapin/cssselect@v0.7.1
38+
Current code is a port of https://github.com/SimonSapin/cssselect/releases/tag/v0.7.1
3939

4040
You can run the unit tests with the following command:
4141

src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ public function process(ContainerBuilder $container)
6969

7070
$this->currentId = $id;
7171
$this->currentDefinition = $definition;
72+
7273
$this->processArguments($definition->getArguments());
74+
if ($definition->getFactoryService()) {
75+
$this->processArguments(array(new Reference($definition->getFactoryService())));
76+
}
7377

7478
if (!$this->onlyConstructorArguments) {
7579
$this->processArguments($definition->getMethodCalls());

src/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,26 @@ public function testProcessDoesNotSaveDuplicateReferences()
9797
$this->assertCount(2, $graph->getNode('a')->getInEdges());
9898
}
9999

100+
public function testProcessDetectsFactoryReferences()
101+
{
102+
$container = new ContainerBuilder();
103+
104+
$container
105+
->register('foo', 'stdClass')
106+
->setFactoryClass('stdClass')
107+
->setFactoryMethod('getInstance');
108+
109+
$container
110+
->register('bar', 'stdClass')
111+
->setFactoryService('foo')
112+
->setFactoryMethod('getInstance');
113+
114+
$graph = $this->process($container);
115+
116+
$this->assertTrue($graph->hasNode('foo'));
117+
$this->assertCount(1, $graph->getNode('foo')->getInEdges());
118+
}
119+
100120
protected function process(ContainerBuilder $container)
101121
{
102122
$pass = new RepeatedPass(array(new AnalyzeServiceReferencesPass()));

src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ public function testProcessWithAliases()
4848
$this->process($container);
4949
}
5050

51+
/**
52+
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
53+
*/
54+
public function testProcessWithFactory()
55+
{
56+
$container = new ContainerBuilder();
57+
58+
$container
59+
->register('a', 'stdClass')
60+
->setFactoryService('b')
61+
->setFactoryMethod('getInstance');
62+
63+
$container
64+
->register('b', 'stdClass')
65+
->setFactoryService('a')
66+
->setFactoryMethod('getInstance');
67+
68+
$this->process($container);
69+
}
70+
5171
/**
5272
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
5373
*/
@@ -61,6 +81,25 @@ public function testProcessDetectsIndirectCircularReference()
6181
$this->process($container);
6282
}
6383

84+
/**
85+
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
86+
*/
87+
public function testProcessDetectsIndirectCircularReferenceWithFactory()
88+
{
89+
$container = new ContainerBuilder();
90+
91+
$container->register('a')->addArgument(new Reference('b'));
92+
93+
$container
94+
->register('b', 'stdClass')
95+
->setFactoryService('c')
96+
->setFactoryMethod('getInstance');
97+
98+
$container->register('c')->addArgument(new Reference('a'));
99+
100+
$this->process($container);
101+
}
102+
64103
/**
65104
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
66105
*/

0 commit comments

Comments
 (0)