Merge branch '4.2'

* 4.2:
  the string "0" is a valid service identifier
  remove unreachable code
This commit is contained in:
Fabien Potencier 2019-01-16 10:27:39 +01:00
commit 1aecafc442
3 changed files with 7 additions and 7 deletions

View File

@ -49,12 +49,8 @@ class TransNodeTest extends TestCase
protected function getVariableGetterWithStrictCheck($name) protected function getVariableGetterWithStrictCheck($name)
{ {
if (Environment::VERSION_ID > 20404) {
return sprintf('(isset($context["%s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%1$s" does not exist.\', 0, $this->source); })())', $name);
}
if (Environment::MAJOR_VERSION >= 2) { if (Environment::MAJOR_VERSION >= 2) {
return sprintf('(isset($context["%s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%1$s" does not exist.\', 0, $this->getSourceContext()); })())', $name); return sprintf('(isset($context["%s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%1$s" does not exist.\', 0, $this->source); })())', $name);
} }
return sprintf('($context["%s"] ?? $this->getContext($context, "%1$s"))', $name); return sprintf('($context["%s"] ?? $this->getContext($context, "%1$s"))', $name);

View File

@ -497,7 +497,7 @@ class XmlFileLoader extends FileLoader
switch ($arg->getAttribute('type')) { switch ($arg->getAttribute('type')) {
case 'service': case 'service':
if (!$arg->getAttribute('id')) { if ('' === $arg->getAttribute('id')) {
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service" has no or empty "id" attribute in "%s".', $name, $file)); throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service" has no or empty "id" attribute in "%s".', $name, $file));
} }
@ -561,7 +561,7 @@ class XmlFileLoader extends FileLoader
* @param \DOMNode $node * @param \DOMNode $node
* @param mixed $name * @param mixed $name
* *
* @return array * @return \DOMElement[]
*/ */
private function getChildren(\DOMNode $node, $name) private function getChildren(\DOMNode $node, $name)
{ {

View File

@ -61,5 +61,9 @@
</service> </service>
<service id="alias_for_foo" alias="foo" /> <service id="alias_for_foo" alias="foo" />
<service id="another_alias_for_foo" alias="foo" public="false" /> <service id="another_alias_for_foo" alias="foo" public="false" />
<service id="0" class="FooClass" />
<service id="1" class="FooClass">
<argument type="service" id="0" />
</service>
</services> </services>
</container> </container>