Skip to content

Commit 508602d

Browse files
committed
Merge branch '4.2'
* 4.2: bump required Twig version fix compatibility with Twig >= 2.6.1 [Form] SA fix fix compatibility with PHPUnit 4.8 remove return type hint for PHP 5 compatibility SCA: minor code tweaks 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 cdbf40b + 6d37740 commit 508602d

File tree

18 files changed

+125
-82
lines changed

18 files changed

+125
-82
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
@@ -72,7 +72,7 @@ public function parse(Token $token)
7272
$body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
7373

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

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

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function parse(Token $token)
6767
$stream->next();
6868
$locale = $this->parser->getExpressionParser()->parseExpression();
6969
} elseif (!$stream->test(Token::BLOCK_END_TYPE)) {
70-
throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext()->getName());
70+
throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
7171
}
7272
}
7373

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

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

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

src/Symfony/Bridge/Twig/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": "^7.1.3",
2020
"symfony/contracts": "^1.0.2",
21-
"twig/twig": "^1.36.1|^2.6.1"
21+
"twig/twig": "^1.37.1|^2.6.2"
2222
},
2323
"require-dev": {
2424
"symfony/asset": "~3.4|~4.0",

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
585585
$metadataStoreDefinition->replaceArgument(2, $transitionsMetadataDefinition);
586586

587587
// Create places
588-
$places = array_map(function (array $place) {
589-
return $place['name'];
590-
}, $workflow['places']);
588+
$places = array_column($workflow['places'], 'name');
591589

592590
// Create a Definition
593591
$definitionDefinition = new Definition(Workflow\Definition::class);

src/Symfony/Component/Console/composer.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@
2828
"symfony/process": "~3.4|~4.0",
2929
"psr/log": "~1.0"
3030
},
31+
"provide": {
32+
"psr/log-implementation": "1.0"
33+
},
3134
"suggest": {
3235
"symfony/event-dispatcher": "",
3336
"symfony/lock": "",
3437
"symfony/process": "",
35-
"psr/log-implementation": "For using the console logger"
38+
"psr/log": "For using the console logger"
3639
},
3740
"conflict": {
3841
"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
@@ -128,6 +128,14 @@ public static function disable()
128128
}
129129
}
130130

131+
/**
132+
* @return string|null
133+
*/
134+
public function findFile($class)
135+
{
136+
return $this->isFinder ? $this->classLoader[0]->findFile($class) ?: null : null;
137+
}
138+
131139
/**
132140
* Loads the given class or interface.
133141
*

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
@@ -124,8 +124,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
124124

125125
private $removedIds = array();
126126

127-
private $removedBindingIds = array();
128-
129127
private static $internalTypes = array(
130128
'int' => true,
131129
'float' => true,
@@ -502,8 +500,7 @@ public function set($id, $service)
502500
throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id));
503501
}
504502

505-
$this->removeId($id);
506-
unset($this->removedIds[$id]);
503+
unset($this->definitions[$id], $this->aliasDefinitions[$id], $this->removedIds[$id]);
507504

508505
parent::set($id, $service);
509506
}
@@ -516,7 +513,8 @@ public function set($id, $service)
516513
public function removeDefinition($id)
517514
{
518515
if (isset($this->definitions[$id = (string) $id])) {
519-
$this->removeId($id);
516+
unset($this->definitions[$id]);
517+
$this->removedIds[$id] = true;
520518
}
521519
}
522520

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

841-
$this->removeId($alias);
842-
unset($this->removedIds[$alias]);
839+
unset($this->definitions[$alias], $this->removedIds[$alias]);
843840

844841
return $this->aliasDefinitions[$alias] = $id;
845842
}
@@ -852,7 +849,8 @@ public function setAlias($alias, $id)
852849
public function removeAlias($alias)
853850
{
854851
if (isset($this->aliasDefinitions[$alias = (string) $alias])) {
855-
$this->removeId($alias);
852+
unset($this->aliasDefinitions[$alias]);
853+
$this->removedIds[$alias] = true;
856854
}
857855
}
858856

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

982980
$id = (string) $id;
983981

984-
$this->removeId($id);
985-
unset($this->removedIds[$id]);
982+
unset($this->aliasDefinitions[$id], $this->removedIds[$id]);
986983

987984
return $this->definitions[$id] = $definition;
988985
}
@@ -1511,18 +1508,6 @@ public static function getInitializedConditionals($value)
15111508
return $services;
15121509
}
15131510

1514-
/**
1515-
* Gets removed binding ids.
1516-
*
1517-
* @return array
1518-
*
1519-
* @internal
1520-
*/
1521-
public function getRemovedBindingIds()
1522-
{
1523-
return $this->removedBindingIds;
1524-
}
1525-
15261511
/**
15271512
* Computes a reasonably unique hash of a value.
15281513
*
@@ -1631,21 +1616,4 @@ private function inVendors($path)
16311616

16321617
return false;
16331618
}
1634-
1635-
private function removeId($id)
1636-
{
1637-
$this->removedIds[$id] = true;
1638-
unset($this->aliasDefinitions[$id]);
1639-
1640-
if (!isset($this->definitions[$id])) {
1641-
return;
1642-
}
1643-
1644-
foreach ($this->definitions[$id]->getBindings() as $binding) {
1645-
list(, $identifier) = $binding->getValues();
1646-
$this->removedBindingIds[$identifier] = true;
1647-
}
1648-
1649-
unset($this->definitions[$id]);
1650-
}
16511619
}

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

-18
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,6 @@ public function testScalarSetter()
112112
$this->assertEquals(array(array('setDefaultLocale', array('fr'))), $definition->getMethodCalls());
113113
}
114114

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-
}
132-
133115
public function testTupleBinding()
134116
{
135117
$container = new ContainerBuilder();

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

0 commit comments

Comments
 (0)