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
This commit is contained in:
commit
d1c754d8ca
|
@ -102,7 +102,7 @@
|
|||
"phpdocumentor/reflection-docblock": "^3.0"
|
||||
},
|
||||
"conflict": {
|
||||
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.1",
|
||||
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2",
|
||||
"phpdocumentor/type-resolver": "<0.2.0",
|
||||
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0"
|
||||
},
|
||||
|
|
|
@ -118,6 +118,14 @@ class YamlDumper extends Dumper
|
|||
$code .= sprintf(" autowiring_types:\n%s", $autowiringTypesCode);
|
||||
}
|
||||
|
||||
if ($definition->isAutoconfigured()) {
|
||||
$code .= " autoconfigure: true\n";
|
||||
}
|
||||
|
||||
if ($definition->isAbstract()) {
|
||||
$code .= " abstract: true\n";
|
||||
}
|
||||
|
||||
if ($definition->isLazy()) {
|
||||
$code .= " lazy: true\n";
|
||||
}
|
||||
|
|
|
@ -12,9 +12,11 @@
|
|||
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Dumper\YamlDumper;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
|
||||
|
@ -65,6 +67,16 @@ class YamlDumperTest extends TestCase
|
|||
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services24.yml', $dumper->dump());
|
||||
}
|
||||
|
||||
public function testDumpLoad()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
$loader->load('services_dump_load.yml');
|
||||
|
||||
$dumper = new YamlDumper($container);
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services_dump_load.yml', $dumper->dump());
|
||||
}
|
||||
|
||||
public function testInlineServices()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
services:
|
||||
service_container:
|
||||
class: Symfony\Component\DependencyInjection\ContainerInterface
|
||||
synthetic: true
|
||||
foo:
|
||||
autoconfigure: true
|
||||
abstract: true
|
||||
Psr\Container\ContainerInterface:
|
||||
alias: service_container
|
||||
public: false
|
||||
Symfony\Component\DependencyInjection\ContainerInterface:
|
||||
alias: service_container
|
||||
public: false
|
|
@ -92,6 +92,7 @@ class PhpDocExtractorTest extends TestCase
|
|||
array('donotexist', null, null, null),
|
||||
array('staticGetter', null, null, null),
|
||||
array('staticSetter', null, null, null),
|
||||
array('emptyVar', null, null, null),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ class ReflectionExtractorTest extends TestCase
|
|||
'B',
|
||||
'Guid',
|
||||
'g',
|
||||
'emptyVar',
|
||||
'foo',
|
||||
'foo2',
|
||||
'foo3',
|
||||
|
@ -172,37 +173,63 @@ class ReflectionExtractorTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function testIsReadable()
|
||||
/**
|
||||
* @dataProvider getReadableProperties
|
||||
*/
|
||||
public function testIsReadable($property, $expected)
|
||||
{
|
||||
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'bar', array()));
|
||||
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'baz', array()));
|
||||
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'parent', array()));
|
||||
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'a', array()));
|
||||
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'b', array()));
|
||||
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'c', array()));
|
||||
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'd', array()));
|
||||
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'e', array()));
|
||||
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'f', array()));
|
||||
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'Id', array()));
|
||||
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'id', array()));
|
||||
$this->assertTrue($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'Guid', array()));
|
||||
$this->assertFalse($this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'guid', array()));
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->extractor->isReadable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property, array())
|
||||
);
|
||||
}
|
||||
|
||||
public function testIsWritable()
|
||||
public function getReadableProperties()
|
||||
{
|
||||
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'bar', array()));
|
||||
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'baz', array()));
|
||||
$this->assertTrue($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'parent', array()));
|
||||
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'a', array()));
|
||||
$this->assertTrue($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'b', array()));
|
||||
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'c', array()));
|
||||
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'd', array()));
|
||||
$this->assertTrue($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'e', array()));
|
||||
$this->assertTrue($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'f', array()));
|
||||
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'Id', array()));
|
||||
$this->assertTrue($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'Guid', array()));
|
||||
$this->assertFalse($this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', 'guid', array()));
|
||||
return array(
|
||||
array('bar', false),
|
||||
array('baz', false),
|
||||
array('parent', true),
|
||||
array('a', true),
|
||||
array('b', false),
|
||||
array('c', true),
|
||||
array('d', true),
|
||||
array('e', false),
|
||||
array('f', false),
|
||||
array('Id', true),
|
||||
array('id', true),
|
||||
array('Guid', true),
|
||||
array('guid', false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getWritableProperties
|
||||
*/
|
||||
public function testIsWritable($property, $expected)
|
||||
{
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->extractor->isWritable('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property, array())
|
||||
);
|
||||
}
|
||||
|
||||
public function getWritableProperties()
|
||||
{
|
||||
return array(
|
||||
array('bar', false),
|
||||
array('baz', false),
|
||||
array('parent', true),
|
||||
array('a', false),
|
||||
array('b', true),
|
||||
array('c', false),
|
||||
array('d', false),
|
||||
array('e', true),
|
||||
array('f', true),
|
||||
array('Id', false),
|
||||
array('Guid', true),
|
||||
array('guid', false),
|
||||
);
|
||||
}
|
||||
|
||||
public function testSingularize()
|
||||
|
|
|
@ -68,6 +68,13 @@ class Dummy extends ParentDummy
|
|||
*/
|
||||
public $g;
|
||||
|
||||
/**
|
||||
* This should not be removed.
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
public $emptyVar;
|
||||
|
||||
public static function getStatic()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
"doctrine/annotations": "~1.0"
|
||||
},
|
||||
"conflict": {
|
||||
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.1",
|
||||
"phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2",
|
||||
"phpdocumentor/type-resolver": "<0.2.0",
|
||||
"symfony/dependency-injection": "<3.3"
|
||||
},
|
||||
|
|
Reference in New Issue