8000 bug #23856 [DI] Fix dumping abstract with YamlDumper (nicolas-grekas) · symfony/symfony@1b9619c · GitHub
[go: up one dir, main page]

Skip to content
< 8000 header class="HeaderMktg header-logged-out js-details-container js-header Details f4 py-3" role="banner" data-is-top="true" data-color-mode=light data-light-theme=light data-dark-theme=dark>

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 1b9619c

Browse files
bug #23856 [DI] Fix dumping abstract with YamlDumper (nicolas-grekas)
This PR was merged into the 2.7 branch. Discussion ---------- [DI] Fix dumping abstract with YamlDumper | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- c396e8c [DI] Fix dumping abstract with YamlDumper
2 parents c951ca6 + c396e8c commit 1b9619c

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ private function addService($id, $definition)
104104
$code .= sprintf(" factory_class: %s\n", $this->dumper->dump($definition->getFactoryClass(false)));
105105
}
106106

107+
if ($definition->isAbstract()) {
108+
$code .= " abstract: true\n";
109+
}
110+
107111
if ($definition->isLazy()) {
108112
$code .= " lazy: true\n";
109113
}

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

Lines 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

1921
class YamlDumperTest extends TestCase
@@ -77,6 +79,16 @@ public function testAddService()
7779
}
7880
}
7981

82+
public function testDumpLoad()
83+
{
84+
$container = new ContainerBuilder();
85+
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
86+
$loader->load('services_dump_load.yml');
87+
88+
$dumper = new YamlDumper($container);
89+
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services_dump_load.yml', $dumper->dump());
90+
}
91+
8092
private function assertEqualYamlStructure($yaml, $expected, $message = '')
8193
{
8294
$this->assertEquals(Yaml::parse($expected), Yaml::parse($yaml), $message);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
services:
3+
foo:
4+
abstract: true

0 commit comments

Comments
 (0)
0