Skip to content

Commit 00b73da

Browse files
committed
Merge branch '3.4' into 4.1
* 3.4: fix compatibility with Twig >= 2.6.1 [Form] SA fix fix compatibility with PHPUnit 4.8 remove return type hint for PHP 5 compatibility Component CssSelector tests [DebugClassLoader] Readd findFile() method [Console] Fix composer.json suggest/provide Revert "bug #29597 [DI] fix reporting bindings on overriden services as unused (nicolas-grekas)" Fixed exception wording Fix SwiftMailerHandler to support Monolog's latest reset functionality
2 parents 1874369 + facbaa5 commit 00b73da

15 files changed

+121
-77
lines changed

src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php

+8
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ protected function send($content, array $records)
5959
}
6060
}
6161

62+
/**
63+
* {@inheritdoc}
64+
*/
65+
public function reset()
66+
{
67+
$this->flushMemorySpool();
68+
}
69+
6270
/**
6371
* Flushes the mail queue if a memory spool is used.
6472
*/

src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function parse(Token $token)
6868
$body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
6969

7070
if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
71-
throw new SyntaxError('A message inside a transchoice tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()->getName());
71+
throw new SyntaxError('A message inside a transchoice tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext());
7272
}
7373

7474
$stream->expect(Token::BLOCK_END_TYPE);

src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function parse(Token $token)
6060
$stream->next();
6161
$locale = $this->parser->getExpressionParser()->parseExpression();
6262
} elseif (!$stream->test(Token::BLOCK_END_TYPE)) {
63-
throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext()->getName());
63+
throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
6464
}
6565
}
6666

@@ -69,7 +69,7 @@ public function parse(Token $token)
6969
$body = $this->parser->subparse(array($this, 'decideTransFork'), true);
7070

7171
if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
72-
throw new SyntaxError('A message inside a trans tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()->getName());
72+
throw new SyntaxError('A message inside a trans tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext());
7373
}
7474

7575
$stream->expect(Token::BLOCK_END_TYPE);

src/Symfony/Component/Console/composer.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@
2727
"symfony/process": "~3.4|~4.0",
2828
"psr/log": "~1.0"
2929
},
30+
"provide": {
31+
"psr/log-implementation": "1.0"
32+
},
3033
"suggest": {
3134
"symfony/event-dispatcher": "",
3235
"symfony/lock": "",
3336
"symfony/process": "",
34-
"psr/log-implementation": "For using the console logger"
37+
"psr/log": "For using the console logger"
3538
},
3639
"conflict": {
3740
"symfony/dependency-injection": "<3.4",

src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php

+71
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
namespace Symfony\Component\CssSelector\Tests\XPath;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\CssSelector\Node\ElementNode;
16+
use Symfony\Component\CssSelector\Node\FunctionNode;
17+
use Symfony\Component\CssSelector\Parser\Parser;
1518
use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension;
1619
use Symfony\Component\CssSelector\XPath\Translator;
20+
use Symfony\Component\CssSelector\XPath\XPathExpr;
1721

1822
class TranslatorTest extends TestCase
1923
{
@@ -31,6 +35,73 @@ public function testCssToXPath($css, $xpath)
3135
$this->assertEquals($xpath, $translator->cssToXPath($css, ''));
3236
}
3337

38+
/**
39+
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
40+
*/
41+
public function testCssToXPathPseudoElement()
42+
{
43+
$translator = new Translator();
44+
$translator->registerExtension(new HtmlExtension($translator));
45+
$translator->cssToXPath('e::first-line');
46+
}
47+
48+
/**
49+
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
50+
*/
51+
public function testGetExtensionNotExistsExtension()
52+
{
53+
$translator = new Translator();
54+
$translator->registerExtension(new HtmlExtension($translator));
55+
$translator->getExtension('fake');
56+
}
57+
58+
/**
59+
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
60+
*/
61+
public function testAddCombinationNotExistsExtension()
62+
{
63+
$translator = new Translator();
64+
$translator->registerExtension(new HtmlExtension($translator));
65+
$parser = new Parser();
66+
$xpath = $parser->parse('*')[0];
67+
$combinedXpath = $parser->parse('*')[0];
68+
$translator->addCombination('fake', $xpath, $combinedXpath);
69+
}
70+
71+
/**
72+
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
73+
*/
74+
public function testAddFunctionNotExistsFunction()
75+
{
76+
$translator = new Translator();
77+
$translator->registerExtension(new HtmlExtension($translator));
78+
$xpath = new XPathExpr();
79+
$function = new FunctionNode(new ElementNode(), 'fake');
80+
$translator->addFunction($xpath, $function);
81+
}
82+
83+
/**
84+
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
85+
*/
86+
public function testAddPseudoClassNotExistsClass()
87+
{
88+
$translator = new Translator();
89+
$translator->registerExtension(new HtmlExtension($translator));
90+
$xpath = new XPathExpr();
91+
$translator->addPseudoClass($xpath, 'fake');
92+
}
93+
94+
/**
95+
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
96+
*/
97+
public function testAddAttributeMatchingClassNotExistsClass()
98+
{
99+
$translator = new Translator();
100+
$translator->registerExtension(new HtmlExtension($translator));
101+
$xpath = new XPathExpr();
102+
$translator->addAttributeMatching($xpath, '', '', '');
103+
}
104+
34105
/** @dataProvider getXmlLangTestData */
35106
public function testXmlLang($css, array $elementsId)
36107
{

src/Symfony/Component/Debug/DebugClassLoader.php

+8
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ public static function disable()
123123
}
124124
}
125125

126+
/**
127+
* @return string|null
128+
*/
129+
public function findFile($class)
130+
{
131+
return $this->isFinder ? $this->classLoader[0]->findFile($class) ?: null : null;
132+
}
133+
126134
/**
127135
* Loads the given class or interface.
128136
*

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

-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ class ResolveBindingsPass extends AbstractRecursivePass
3434
*/
3535
public function process(ContainerBuilder $container)
3636
{
37-
$this->usedBindings = $container->getRemovedBindingIds();
38-
3937
try {
4038
parent::process($container);
4139

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

+7-39
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
122122

123123
private $removedIds = array();
124124

125-
private $removedBindingIds = array();
126-
127125
private static $internalTypes = array(
128126
'int' => true,
129127
'float' => true,
@@ -500,8 +498,7 @@ public function set($id, $service)
500498
throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id));
501499
}
502500

503-
$this->removeId($id);
504-
unset($this->removedIds[$id]);
501+
unset($this->definitions[$id], $this->aliasDefinitions[$id], $this->removedIds[$id]);
505502

506503
parent::set($id, $service);
507504
}
@@ -514,7 +511,8 @@ public function set($id, $service)
514511
public function removeDefinition($id)
515512
{
516513
if (isset($this->definitions[$id = (string) $id])) {
517-
$this->removeId($id);
514+
unset($this->definitions[$id]);
515+
$this->removedIds[$id] = true;
518516
}
519517
}
520518

@@ -836,8 +834,7 @@ public function setAlias($alias, $id)
836834
throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias));
837835
}
838836

839-
$this->removeId($alias);
840-
unset($this->removedIds[$alias]);
837+
unset($this->definitions[$alias], $this->removedIds[$alias]);
841838

842839
return $this->aliasDefinitions[$alias] = $id;
843840
}
@@ -850,7 +847,8 @@ public function setAlias($alias, $id)
850847
public function removeAlias($alias)
851848
{
852849
if (isset($this->aliasDefinitions[$alias = (string) $alias])) {
853-
$this->removeId($alias);
850+
unset($this->aliasDefinitions[$alias]);
851+
$this->removedIds[$alias] = true;
854852
}
855853
}
856854

@@ -979,8 +977,7 @@ public function setDefinition($id, Definition $definition)
979977

980978
$id = (string) $id;
981979

982-
$this->removeId($id);
983-
unset($this->removedIds[$id]);
980+
unset($this->aliasDefinitions[$id], $this->removedIds[$id]);
984981

985982
return $this->definitions[$id] = $definition;
986983
}
@@ -1482,18 +1479,6 @@ public static function getInitializedConditionals($value)
14821479
return $services;
14831480
}
14841481

1485-
/**
1486-
* Gets removed binding ids.
1487-
*
1488-
* @return array
1489-
*
1490-
* @internal
1491-
*/
1492-
public function getRemovedBindingIds()
1493-
{
1494-
return $this->removedBindingIds;
1495-
}
1496-
14971482
/**
14981483
* Computes a reasonably unique hash of a value.
14991484
*
@@ -1598,21 +1583,4 @@ private function inVendors($path)
15981583

15991584
return false;
16001585
}
1601-
1602-
private function removeId($id)
1603-
{
1604-
$this->removedIds[$id] = true;
1605-
unset($this->aliasDefinitions[$id]);
1606-
1607-
if (!isset($this->definitions[$id])) {
1608-
return;
1609-
}
1610-
1611-
foreach ($this->definitions[$id]->getBindings() as $binding) {
1612-
list(, $identifier) = $binding->getValues();
1613-
$this->removedBindingIds[$identifier] = true;
1614-
}
1615-
1616-
unset($this->definitions[$id]);
1617-
}
16181586
}

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

-18
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,4 @@ public function testScalarSetter()
111111

112112
$this->assertEquals(array(array('setDefaultLocale', array('fr'))), $definition->getMethodCalls());
113113
}
114-
115-
public function testOverriddenBindings()
116-
{
117-
$container = new ContainerBuilder();
118-
119-
$binding = new BoundArgument('bar');
120-
121-
$container->register('foo', 'stdClass')
122-
->setBindings(array('$foo' => clone $binding));
123-
$container->register('bar', 'stdClass')
124-
->setBindings(array('$foo' => clone $binding));
125-
126-
$container->register('foo', 'stdClass');
127-
128-
(new ResolveBindingsPass())->process($container);
129-
130-
$this->assertInstanceOf('stdClass', $container->get('foo'));
131-
}
132114
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ protected function process(ContainerBuilder $container)
399399

400400
/**
401401
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
402-
* @expectedExceptionMessageRegExp /^Circular reference detected for service "a", path: "a -> c -> b -> a"./
402+
* @expectedExceptionMessageRegExp /^Circular reference detected for service "c", path: "c -> b -> a -> c"./
403403
*/
404404
public function testProcessDetectsChildDefinitionIndirectCircularReference()
405405
{

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ public function testMerge()
559559
$config->setDefinition('baz', new Definition('BazClass'));
560560
$config->setAlias('alias_for_foo', 'foo');
561561
$container->merge($config);
562-
$this->assertEquals(array('foo', 'bar', 'service_container', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
562+
$this->assertEquals(array('service_container', 'foo', 'bar', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
563563

564564
$aliases = $container->getAliases();
565565
$this->assertArrayHasKey('alias_for_foo', $aliases);

src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/instanceof.expected.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ services:
44
class: Symfony\Component\DependencyInjection\ContainerInterface
55
public: true
66
synthetic: true
7-
foo:
8-
class: App\FooService
9-
public: true
107
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
118
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
129
public: true
@@ -19,3 +16,6 @@ services:
1916

2017
shared: false
2118
configurator: c
19+
foo:
20+
class: App\FooService
21+
public: true

src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/prototype.expected.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ services:
44
class: Symfony\Component\DependencyInjection\ContainerInterface
55
public: true
66
synthetic: true
7-
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar:
8-
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar
7+
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
8+
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
99
public: true
1010
tags:
1111
- { name: foo }
1212
- { name: baz }
1313
deprecated: '%service_id%'
14-
lazy: true
1514
arguments: [1]
1615
factory: f
17-
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo:
18-
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Foo
16+
Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar:
17+
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar
1918
public: true
2019
tags:
2120
- { name: foo }
2221
- { name: baz }
2322
deprecated: '%service_id%'
23+
lazy: true
2424
arguments: [1]
2525
factory: f

src/Symfony/Component/Form/Test/Traits/ValidatorExtensionTrait.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@
1818

1919
trait ValidatorExtensionTrait
2020
{
21+
/**
22+
* @var ValidatorInterface|null
23+
*/
2124
protected $validator;
2225

26+
/**
27+
* @return ValidatorExtension
28+
*/
2329
protected function getValidatorExtension()
2430
{
2531
if (!interface_exists(ValidatorInterface::class)) {
@@ -31,9 +37,9 @@ protected function getValidatorExtension()
3137
}
3238

3339
$this->validator = $this->getMockBuilder(ValidatorInterface::class)->getMock();
34-
$metadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->setMethods(array('addPropertyConstraint'))->getMock();
40+
$metadata = $this->getMockBuilder(ClassMetadata::class)->disableOriginalConstructor()->setMethods(['addPropertyConstraint'])->getMock();
3541
$this->validator->expects($this->any())->method('getMetadataFor')->will($this->returnValue($metadata));
36-
$this->validator->expects($this->any())->method('validate')->will($this->returnValue(array()));
42+
$this->validator->expects($this->any())->method('validate')->will($this->returnValue([]));
3743

3844
return new ValidatorExtension($this->validator);
3945
}

src/Symfony/Component/Validator/ContainerConstraintValidatorFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ContainerConstraintValidatorFactory implements ConstraintValidatorFactoryI
2828
public function __construct(ContainerInterface $container)
2929
{
3030
$this->container = $container;
31-
$this->validators = array();
31+
$this->validators = [];
3232
}
3333

3434
/**
@@ -46,7 +46,7 @@ public function getInstance(Constraint $constraint)
4646
$this->validators[$name] = $this->container->get($name);
4747
} else {
4848
if (!class_exists($name)) {
49-
throw new ValidatorException(sprintf('Constraint validator "%s" does not exist or it is not enabled. Check the "validatedBy" method in your constraint class "%s".', $name, \get_class($constraint)));
49+
throw new ValidatorException(sprintf('Constraint validator "%s" does not exist or is not enabled. Check the "validatedBy" method in your constraint class "%s".', $name, \get_class($constraint)));
5050
}
5151

5252
$this->validators[$name] = new $name();

0 commit comments

Comments
 (0)