Skip to content

Commit bc1ad7c

Browse files
Merge branch '5.0'
* 5.0: [appveyor] bump cache [Twig][Mime] Removed extra quotes in missing package exception message [DI] µfix Allowing empty secrets to be set [DI] add missing property declarations in InlineServiceConfigurator [DI] fix detecting short service syntax in yaml Supress error from fread when reading a unix pipe [HttpClient] Fix scoped client without query option configuration [Workflow] Use a strict comparison when retrieving raw marking in MarkingStore [Workflow] Use a strict comparison when retrieving raw markin in MarkingStore
2 parents b31c35d + 68b0014 commit bc1ad7c

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

Loader/Configurator/AliasConfigurator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class AliasConfigurator extends AbstractServiceConfigurator
2020
{
2121
const FACTORY = 'alias';
2222

23+
use Traits\DeprecateTrait;
2324
use Traits\PublicTrait;
2425

2526
public function __construct(ServicesConfigurator $parent, Alias $alias)

Loader/Configurator/InlineServiceConfigurator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ class InlineServiceConfigurator extends AbstractConfigurator
3232
use Traits\PropertyTrait;
3333
use Traits\TagTrait;
3434

35+
private $id = '[inline]';
36+
private $allowParent = true;
37+
private $path = null;
38+
3539
public function __construct(Definition $definition)
3640
{
3741
$this->definition = $definition;

Loader/YamlFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private function parseDefaults(array &$content, string $file): array
300300
private function isUsingShortSyntax(array $service): bool
301301
{
302302
foreach ($service as $key => $value) {
303-
if (\is_string($key) && ('' === $key || '$' !== $key[0])) {
303+
if (\is_string($key) && ('' === $key || ('$' !== $key[0] && false === strpos($key, '\\')))) {
304304
return false;
305305
}
306306
}
@@ -346,7 +346,7 @@ private function parseDefinition(string $id, $service, string $file, array $defa
346346

347347
if (isset($service['alias'])) {
348348
$this->container->setAlias($id, $alias = new Alias($service['alias']));
349-
if (\array_key_exists('public', $service)) {
349+
if (isset($service['public'])) {
350350
$alias->setPublic($service['public']);
351351
} elseif (isset($defaults['public'])) {
352352
$alias->setPublic($defaults['public']);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
foo_bar: [1, 2]
3+
4+
bar_foo:
5+
$a: 'a'
6+
App\Foo: 'foo'

Tests/Loader/YamlFileLoaderTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,17 @@ public function testLoadServices()
205205
$this->assertEquals(['decorated', 'decorated.pif-pouf', 5, ContainerInterface::IGNORE_ON_INVALID_REFERENCE], $services['decorator_service_with_name_and_priority_and_on_invalid']->getDecoratedService());
206206
}
207207

208+
public function testLoadShortSyntax()
209+
{
210+
$container = new ContainerBuilder();
211+
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
212+
$loader->load('services_short_syntax.yml');
213+
$services = $container->getDefinitions();
214+
215+
$this->assertSame([1, 2], $services['foo_bar']->getArguments());
216+
$this->assertSame(['$a' => 'a', 'App\Foo' => 'foo'], $services['bar_foo']->getArguments());
217+
}
218+
208219
public function testDeprecatedAliases()
209220
{
210221
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)