Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3d54c3b

Browse filesBrowse files
bug #23854 [DI] Fix YamlDumper not dumping abstract and autoconfigure (nicolas-grekas)
This PR was merged into the 3.3 branch. Discussion ---------- [DI] Fix YamlDumper not dumping abstract and autoconfigure | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 685ff0e [DI] Fix YamlDumper not dumping abstract and autoconfigure
2 parents a670b2b + 685ff0e commit 3d54c3b
Copy full SHA for 3d54c3b

File tree

3 files changed

+34
-0
lines changed
Filter options

3 files changed

+34
-0
lines changed

‎src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ private function addService($id, $definition)
116116
$code .= sprintf(" autowiring_types:\n%s", $autowiringTypesCode);
117117
}
118118

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

‎src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
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\Dumper\YamlDumper;
18+
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
1719
use Symfony\Component\Yaml\Yaml;
1820
use Symfony\Component\Yaml\Parser;
1921

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

69+
public function testDumpLoad()
70+
{
71+
$container = new ContainerBuilder();
72+
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
73+
$loader->load('services_dump_load.yml');
74+
75+
$dumper = new YamlDumper($container);
76+
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services_dump_load.yml', $dumper->dump());
77+
}
78+
6779
private function assertEqualYamlStructure($expected, $yaml, $message = '')
6880
{
6981
$parser = new Parser();
+14Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.