Skip to content

Commit

Permalink
Removed deprecations in DependencyInjection component
Browse files Browse the repository at this point in the history
  • Loading branch information
dosten authored and fabpot committed May 16, 2015
1 parent 5d7f909 commit 76ff5a9
Show file tree
Hide file tree
Showing 80 changed files with 23 additions and 1,508 deletions.
Expand Up @@ -26,9 +26,6 @@ public function __construct()
$this->services =
$this->scopedServices =
$this->scopeStacks = array();

$this->set('service_container', $this);

$this->scopes = array();
$this->scopeChildren = array();
}
Expand Down
Expand Up @@ -210,25 +210,9 @@ private function getContainerDefinitionData(Definition $definition, $omitTags =
'lazy' => $definition->isLazy(),
);

if (method_exists($definition, 'isSynchronized')) {
$data['synchronized'] = $definition->isSynchronized(false);
}

$data['abstract'] = $definition->isAbstract();
$data['file'] = $definition->getFile();

if ($definition->getFactoryClass(false)) {
$data['factory_class'] = $definition->getFactoryClass(false);
}

if ($definition->getFactoryService(false)) {
$data['factory_service'] = $definition->getFactoryService(false);
}

if ($definition->getFactoryMethod(false)) {
$data['factory_method'] = $definition->getFactoryMethod(false);
}

if ($factory = $definition->getFactory()) {
if (is_array($factory)) {
if ($factory[0] instanceof Reference) {
Expand Down
Expand Up @@ -110,7 +110,7 @@ protected function describeContainerService($service, array $options = array())
} elseif ($service instanceof Definition) {
$this->describeContainerDefinition($service, $childOptions);
} else {
$this->write(sprintf("**`%s`:** `%s`", $options['id'], get_class($service)));
$this->write(sprintf('**`%s`:** `%s`', $options['id'], get_class($service)));
}
}

Expand Down Expand Up @@ -182,28 +182,12 @@ protected function describeContainerDefinition(Definition $definition, array $op
."\n".'- Lazy: '.($definition->isLazy() ? 'yes' : 'no')
;

if (method_exists($definition, 'isSynchronized')) {
$output .= "\n".'- Synchronized: '.($definition->isSynchronized(false) ? 'yes' : 'no');
}

$output .= "\n".'- Abstract: '.($definition->isAbstract() ? 'yes' : 'no');

if ($definition->getFile()) {
$output .= "\n".'- File: `'.$definition->getFile().'`';
}

if ($definition->getFactoryClass(false)) {
$output .= "\n".'- Factory Class: `'.$definition->getFactoryClass(false).'`';
}

if ($definition->getFactoryService(false)) {
$output .= "\n".'- Factory Service: `'.$definition->getFactoryService(false).'`';
}

if ($definition->getFactoryMethod(false)) {
$output .= "\n".'- Factory Method: `'.$definition->getFactoryMethod(false).'`';
}

if ($factory = $definition->getFactory()) {
if (is_array($factory)) {
if ($factory[0] instanceof Reference) {
Expand Down
Expand Up @@ -207,7 +207,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
foreach ($definition->getTag($showTag) as $key => $tag) {
$tagValues = array();
foreach ($tagsNames as $tagName) {
$tagValues[] = isset($tag[$tagName]) ? $tag[$tagName] : "";
$tagValues[] = isset($tag[$tagName]) ? $tag[$tagName] : '';
}
if (0 === $key) {
$table->addRow(array_merge(array($serviceId), $tagValues, array($definition->getClass())));
Expand All @@ -220,10 +220,10 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
}
} elseif ($definition instanceof Alias) {
$alias = $definition;
$table->addRow(array_merge(array($serviceId, sprintf('alias for "%s"', $alias)), $tagsCount ? array_fill(0, $tagsCount, "") : array()));
$table->addRow(array_merge(array($serviceId, sprintf('alias for "%s"', $alias)), $tagsCount ? array_fill(0, $tagsCount, '') : array()));
} else {
// we have no information (happens with "service_container")
$table->addRow(array_merge(array($serviceId, get_class($definition)), $tagsCount ? array_fill(0, $tagsCount, "") : array()));
$table->addRow(array_merge(array($serviceId, get_class($definition)), $tagsCount ? array_fill(0, $tagsCount, '') : array()));
}
}

Expand All @@ -240,7 +240,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
: array();

$description[] = sprintf('<comment>Service Id</comment> %s', isset($options['id']) ? $options['id'] : '-');
$description[] = sprintf('<comment>Class</comment> %s', $definition->getClass() ?: "-");
$description[] = sprintf('<comment>Class</comment> %s', $definition->getClass() ?: '-');

$tags = $definition->getTags();
if (count($tags)) {
Expand All @@ -260,27 +260,12 @@ protected function describeContainerDefinition(Definition $definition, array $op
$description[] = sprintf('<comment>Public</comment> %s', $definition->isPublic() ? 'yes' : 'no');
$description[] = sprintf('<comment>Synthetic</comment> %s', $definition->isSynthetic() ? 'yes' : 'no');
$description[] = sprintf('<comment>Lazy</comment> %s', $definition->isLazy() ? 'yes' : 'no');
if (method_exists($definition, 'isSynchronized')) {
$description[] = sprintf('<comment>Synchronized</comment> %s', $definition->isSynchronized(false) ? 'yes' : 'no');
}
$description[] = sprintf('<comment>Abstract</comment> %s', $definition->isAbstract() ? 'yes' : 'no');

if ($definition->getFile()) {
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ? $definition->getFile() : '-');
}

if ($definition->getFactoryClass(false)) {
$description[] = sprintf('<comment>Factory Class</comment> %s', $definition->getFactoryClass(false));
}

if ($definition->getFactoryService(false)) {
$description[] = sprintf('<comment>Factory Service</comment> %s', $definition->getFactoryService(false));
}

if ($definition->getFactoryMethod(false)) {
$description[] = sprintf('<comment>Factory Method</comment> %s', $definition->getFactoryMethod(false));
}

if ($factory = $definition->getFactory()) {
if (is_array($factory)) {
if ($factory[0] instanceof Reference) {
Expand Down
Expand Up @@ -329,20 +329,6 @@ private function getContainerDefinitionDocument(Definition $definition, $id = nu

$serviceXML->setAttribute('class', $definition->getClass());

if (method_exists($definition, 'getFactoryMethod')) {
if ($definition->getFactoryClass(false)) {
$serviceXML->setAttribute('factory-class', $definition->getFactoryClass(false));
}

if ($definition->getFactoryService(false)) {
$serviceXML->setAttribute('factory-service', $definition->getFactoryService(false));
}

if ($definition->getFactoryMethod(false)) {
$serviceXML->setAttribute('factory-method', $definition->getFactoryMethod(false));
}
}

if ($factory = $definition->getFactory()) {
$serviceXML->appendChild($factoryXML = $dom->createElement('factory'));

Expand All @@ -364,9 +350,6 @@ private function getContainerDefinitionDocument(Definition $definition, $id = nu
$serviceXML->setAttribute('public', $definition->isPublic() ? 'true' : 'false');
$serviceXML->setAttribute('synthetic', $definition->isSynthetic() ? 'true' : 'false');
$serviceXML->setAttribute('lazy', $definition->isLazy() ? 'true' : 'false');
if (method_exists($definition, 'isSynchronized')) {
$serviceXML->setAttribute('synchronized', $definition->isSynchronized(false) ? 'true' : 'false');
}
$serviceXML->setAttribute('abstract', $definition->isAbstract() ? 'true' : 'false');
$serviceXML->setAttribute('file', $definition->getFile());

Expand Down
Expand Up @@ -66,24 +66,6 @@ public function getDescribeContainerBuilderTestData()
return $this->getContainerBuilderDescriptionTestData(ObjectsProvider::getContainerBuilders());
}

/**
* @dataProvider provideLegacySynchronizedServiceDefinitionTestData
* @group legacy
*/
public function testLegacyDescribeSynchronizedServiceDefinition(Definition $definition, $expectedDescription)
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

$this->assertDescription($expectedDescription, $definition);
}

public function provideLegacySynchronizedServiceDefinitionTestData()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

return $this->getDescriptionTestData(ObjectsProvider::getLegacyContainerDefinitions());
}

/** @dataProvider getDescribeContainerDefinitionTestData */
public function testDescribeContainerDefinition(Definition $definition, $expectedDescription)
{
Expand Down
Expand Up @@ -112,39 +112,6 @@ public static function getContainerDefinitions()
);
}

/**
* @deprecated since version 2.7, to be removed in 3.0
* @internal
*/
public static function getLegacyContainerDefinitions()
{
$definition1 = new Definition('Full\\Qualified\\Class1');
$definition2 = new Definition('Full\\Qualified\\Class2');

return array(
'legacy_synchronized_service_definition_1' => $definition1
->setPublic(true)
->setSynthetic(false)
->setLazy(true)
->setSynchronized(true)
->setAbstract(true)
->setFactoryClass('Full\\Qualified\\FactoryClass', 'get')
->setFactoryMethod('get'),
'legacy_synchronized_service_definition_2' => $definition2
->setPublic(false)
->setSynthetic(true)
->setFile('/path/to/file')
->setLazy(false)
->setSynchronized(false)
->setAbstract(false)
->addTag('tag1', array('attr1' => 'val1', 'attr2' => 'val2'))
->addTag('tag1', array('attr3' => 'val3'))
->addTag('tag2')
->setFactoryService('factory.service')
->setFactoryMethod('get'),
);
}

public static function getContainerAliases()
{
return array(
Expand Down
Expand Up @@ -6,7 +6,6 @@
"public": true,
"synthetic": false,
"lazy": true,
"synchronized": false,
"abstract": true,
"file": null,
"factory_class": "Full\\Qualified\\FactoryClass",
Expand Down
Expand Up @@ -12,7 +12,6 @@ definition_1
- Public: yes
- Synthetic: no
- Lazy: yes
- Synchronized: no
- Abstract: yes
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`
Expand Down
Expand Up @@ -2,7 +2,7 @@
<container>
<alias id="alias_1" service="service_1" public="true"/>
<alias id="alias_2" service="service_2" public="false"/>
<definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" synchronized="false" abstract="true" file="">
<definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" abstract="true" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/>
</definition>
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerBuilder"/>
Expand Down
Expand Up @@ -6,7 +6,6 @@
"public": true,
"synthetic": false,
"lazy": true,
"synchronized": false,
"abstract": true,
"file": null,
"factory_class": "Full\\Qualified\\FactoryClass",
Expand All @@ -21,7 +20,6 @@
"public": false,
"synthetic": true,
"lazy": false,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
Expand Down
Expand Up @@ -12,7 +12,6 @@ definition_1
- Public: yes
- Synthetic: no
- Lazy: yes
- Synchronized: no
- Abstract: yes
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`
Expand All @@ -25,7 +24,6 @@ definition_2
- Public: no
- Synthetic: yes
- Lazy: no
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
- Factory Service: `factory.service`
Expand Down
Expand Up @@ -2,10 +2,10 @@
<container>
<alias id="alias_1" service="service_1" public="true"/>
<alias id="alias_2" service="service_2" public="false"/>
<definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" synchronized="false" abstract="true" file="">
<definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" abstract="true" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/>
</definition>
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file">
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" abstract="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
<tags>
<tag name="tag1">
Expand Down
Expand Up @@ -6,7 +6,6 @@
"public": false,
"synthetic": true,
"lazy": false,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
Expand Down
Expand Up @@ -12,7 +12,6 @@ definition_2
- Public: no
- Synthetic: yes
- Lazy: no
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
- Factory Service: `factory.service`
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<container>
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file">
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" abstract="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
<tags>
<tag name="tag1">
Expand Down
Expand Up @@ -6,7 +6,6 @@
"public": false,
"synthetic": true,
"lazy": false,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
Expand All @@ -20,7 +19,6 @@
"public": false,
"synthetic": true,
"lazy": false,
"synchronized": false,
"abstract": false,
"file": "\/path\/to\/file",
"factory_service": "factory.service",
Expand Down
Expand Up @@ -12,7 +12,6 @@ definition_2
- Public: no
- Synthetic: yes
- Lazy: no
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
- Factory Service: `factory.service`
Expand All @@ -30,7 +29,6 @@ definition_2
- Public: no
- Synthetic: yes
- Lazy: no
- Synchronized: no
- Abstract: no
- File: `/path/to/file`
- Factory Service: `factory.service`
Expand Down
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<container>
<tag name="tag1">
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file">
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" abstract="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
</definition>
</tag>
<tag name="tag2">
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file">
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" abstract="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
</definition>
</tag>
Expand Down
Expand Up @@ -4,7 +4,6 @@
"public": true,
"synthetic": false,
"lazy": true,
"synchronized": false,
"abstract": true,
"file": null,
"factory_class": "Full\\Qualified\\FactoryClass",
Expand Down
Expand Up @@ -3,7 +3,6 @@
- Public: yes
- Synthetic: no
- Lazy: yes
- Synchronized: no
- Abstract: yes
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`
Expand Up @@ -5,7 +5,6 @@
<comment>Public</comment> yes
<comment>Synthetic</comment> no
<comment>Lazy</comment> yes
<comment>Synchronized</comment> no
<comment>Abstract</comment> yes
<comment>Factory Class</comment> Full\Qualified\FactoryClass
<comment>Factory Method</comment> get

0 comments on commit 76ff5a9

Please sign in to comment.