8000 Merge branch '3.4' into 4.1 · symfony/symfony@00b73da · GitHub
[go: up one dir, main page]

Skip to content 8000

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

File tree

15 files changed

+121
-77
lines changed

15 files changed

+121
-77
lines changed

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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 71 additions & 0 deletions
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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
122122

123123
private $removedIds = array();
124124 10000

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

Lines changed: 0 additions & 18 deletions
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

Lines changed: 1 addition & 1 deletion
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
{

0 commit comments

Comments
 (0)
0