8000 Cast result to int before adding to it · symfony/symfony@e893708 · GitHub
[go: up one dir, main page]

Skip to content

Commit e893708

Browse files
committed
Cast result to int before adding to it
This fixes the occasional warning about non-numeric values when using PHP 7.1
1 parent 9b9f1be commit e893708

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true)
370370
}
371371

372372
if (!$arg->hasAttribute('key')) {
373-
$key = !$arguments ? 0 : max(array_keys($arguments)) + 1;
373+
$key = !$arguments ? 0 : (int) max(array_keys($arguments)) + 1;
374374
} else {
375375
$key = $arg->getAttribute('key');
376376
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
3+
<services>
4+
<service id="foo" class="Foo">
5+
<argument key="type">foo</argument>
6+
<argument>bar</argument>
7+
</service>
8+
</services>
9+
</container>

src/Symfony/Component/Depen 8000 dencyInjection/Tests/Loader/XmlFileLoaderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,4 +577,14 @@ public function testAutowire()
577577

578578
$this->assertTrue($container->getDefinition('bar')->isAutowired());
579579
}
580+
581+
public function testArgumentWithKeyOutsideCollection()
582+
{
583+
$container = new ContainerBuilder();
584+
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
585+
$loader->load('with_key_outside_collection.xml');
586+
587+
588+
$this->assertSame(array('type' => 'foo', 1 => 'bar'), $container->getDefinition('foo')->getArguments());
589+
}
580590
}

0 commit comments

Comments
 (0)
0