Skip to content

Commit 68b0014

Browse files
Merge branch '4.4' into 5.0
* 4.4: [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 4e48dc4 + caa124e commit 68b0014

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
@@ -29,6 +29,10 @@ class InlineServiceConfigurator extends AbstractConfigurator
2929
use Traits\ParentTrait;
3030
use Traits\TagTrait;
3131

32+
private $id = '[inline]';
33+
private $allowParent = true;
34+
private $path = null;
35+
3236
public function __construct(Definition $definition)
3337
{
3438
$this->definition = $definition;

Loader/YamlFileLoader.php

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

346346
if (isset($service['alias'])) {
347347
$this->container->setAlias($id, $alias = new Alias($service['alias']));
348-
if (\array_key_exists('public', $service)) {
348+
if (isset($service['public'])) {
349349
$alias->setPublic($service['public']);
350350
} elseif (isset($defaults['public'])) {
351351
$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)