Skip to content

Commit aaee887

Browse files
Merge branch '3.3' into 3.4
* 3.3: [DI] Fix dumping abstract with YamlDumper restrict reflection doc block [DI] Fix YamlDumper not dumping abstract and autoconfigure
2 parents e1adb50 + 65e0c7e commit aaee887

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

Dumper/YamlDumper.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ private function addService($id, $definition)
118118
$code .= sprintf(" autowiring_types:\n%s", $autowiringTypesCode);
119119
}
120120

121+
if ($definition->isAutoconfigured()) {
122+
$code .= " autoconfigure: true\n";
123+
}
124+
125+
if ($definition->isAbstract()) {
126+
$code .= " abstract: true\n";
127+
}
128+
121129
if ($definition->isLazy()) {
122130
$code .= " lazy: true\n";
123131
}

Tests/Dumper/YamlDumperTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Config\FileLocator;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Definition;
1718
use Symfony\Component\DependencyInjection\Dumper\YamlDumper;
19+
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
1820
use Symfony\Component\Yaml\Yaml;
1921
use Symfony\Component\Yaml\Parser;
2022

@@ -65,6 +67,16 @@ public function testDumpAutowireData()
6567
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services24.yml', $dumper->dump());
6668
}
6769

70+
public function testDumpLoad()
71+
{
72+
$container = new ContainerBuilder();
73+
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
74+
$loader->load('services_dump_load.yml');
75+
76+
$dumper = new YamlDumper($container);
77+
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services_dump_load.yml', $dumper->dump());
78+
}
79+
6880
public function testInlineServices()
6981
{
7082
$container = new ContainerBuilder();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
services:
3+
service_container:
4+
class: Symfony\Component\DependencyInjection\ContainerInterface
5+
synthetic: true
6+
foo:
7+
autoconfigure: true
8+
abstract: true
9+
Psr\Container\ContainerInterface:
10+
alias: service_container
11+
public: false
12+
Symfony\Component\DependencyInjection\ContainerInterface:
13+
alias: service_container
14+
public: false

0 commit comments

Comments
 (0)