Skip to content

Commit d1c754d

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 00897c0 + 72791d6 commit d1c754d

File tree

8 files changed

+98
-29
lines changed

8 files changed

+98
-29
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"phpdocumentor/reflection-docblock": "^3.0"
103103
},
104104
"conflict": {
105-
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.1",
105+
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2",
106106
"phpdocumentor/type-resolver": "<0.2.0",
107107
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0"
108108
},

src/Symfony/Component/DependencyInjection/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
}

src/Symfony/Component/DependencyInjection/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

src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function typesProvider()
9292
array('donotexist', null, null, null),
9393
array('staticGetter', null, null, null),
9494
array('staticSetter', null, null, null),
95+
array('emptyVar', null, null, null),
9596
);
9697
}
9798

src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function testGetProperties()
4141
'B',
4242
'Guid',
4343
'g',
44+
'emptyVar',
4445
'foo',
4546
'foo2',
4647
'foo3',
@@ -172,37 +173,63 @@ public function php71TypesProvider()
172173
);
173174
}
174175

175-
public function testIsReadable()
176+
/**
177+
* @dataProvider getReadableProperties
178+
*/
179+
public function testIsReadable($property, $expected)
180+
{
181+
$this->assertSame(
182+
$expected,
183+
$this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property, array())
184+
);
185+
}
186+
187+
public function getReadableProperties()
188+
{
189+
return array(
190+
array('bar', false),
191+
array('baz', false),
192+
array('parent', true),
193+
array('a', true),
194+
array('b', false),
195+
array('c', true),
196+
array('d', true),
197+
array('e', false),
198+
array('f', false),
199+
array('Id', true),
200+
array('id', true),
201+
array('Guid', true),
202+
array('guid', false),
203+
);
204+
}
205+
206+
/**
207+
* @dataProvider getWritableProperties
208+
*/
209+
public function testIsWritable($property, $expected)
176210
{
177-
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'bar', array()));
178-
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'baz', array()));
179-
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'parent', array()));
180-
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'a', array()));
181-
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'b', array()));
182-
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'c', array()));
183-
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'd', array()));
184-
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'e', array()));
185-
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'f', array()));
186-
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'Id', array()));
187-
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'id', array()));
188-
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'Guid', array()));
189-
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'guid', array()));
211+
$this->assertSame(
212+
$expected,
213+
$this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property, array())
214+
);
190215
}
191216

192-
public function testIsWritable()
217+
public function getWritableProperties()
193218
{
194-
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'bar', array()));
195-
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'baz', array()));
196-
$this->assertTrue($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'parent', array()));
197-
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'a', array()));
198-
$this->assertTrue($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'b', array()));
199-
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'c', array()));
200-
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'd', array()));
201-
$this->assertTrue($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'e', array()));
202-
$this->assertTrue($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'f', array()));
203-
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'Id', array()));
204-
$this->assertTrue($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'Guid', array()));
205-
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'guid', array()));
219+
return array(
220+
array('bar', false),
221+
array('baz', false),
222+
array('parent', true),
223+
array('a', false),
224+
array('b', true),
225+
array('c', false),
226+
array('d', false),
227+
array('e', true),
228+
array('f', true),
229+
array('Id', false),
230+
array('Guid', true),
231+
array('guid', false),
232+
);
206233
}
207234

208235
public function testSingularize()

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ class Dummy extends ParentDummy
6868
*/
6969
public $g;
7070

71+
/**
72+
* This should not be removed.
73+
*
74+
* @var
75+
*/
76+
public $emptyVar;
77+
7178
public static function getStatic()
7279
{
7380
}

src/Symfony/Component/PropertyInfo/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"doctrine/annotations": "~1.0"
3535
},
3636
"conflict": {
37-
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.1",
37+
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2",
3838
"phpdocumentor/type-resolver": "<0.2.0",
3939
"symfony/dependency-injection": "<3.3"
4040
},

0 commit comments

Comments
 (0)