8000 [FrameworkBundle] Fix debug:container --show-arguments missing cases by chalasr · Pull Request #21290 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBund 8000 le] Fix debug:container --show-arguments missing cases #21290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function describeContainerService($service, array $options = array(),
if ($service instanceof Alias) {
$this->describeContainerAlias($service, $options, $builder);
} elseif ($service instanceof Definition) {
$this->writeData($this->getContainerDefinitionData($service), $options);
$this->writeData($this->getContainerDefinitionData($service, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments']), $options);
} else {
$this->writeData(get_class($service), $options);
}
Expand All @@ -99,6 +99,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
{
$serviceIds = isset($options['tag']) && $options['tag'] ? array_keys($builder->findTaggedServiceIds($options['tag'])) : $builder->getServiceIds();
$showPrivate = isset($options['show_private']) && $options['show_private'];
$omitTags = isset($options['omit_tags']) && $options['omit_tags'];
$showArguments = isset($options['show_arguments']) && $options['show_arguments'];
$data = array('definitions' => array(), 'aliases' => array(), 'services' => array());

Expand All @@ -109,7 +110,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
$data['aliases'][$serviceId] = $this->getContainerAliasData($service);
} elseif ($service instanceof Definition) {
if (($showPrivate || $service->isPublic())) {
$data['definitions'][$serviceId] = $this->getContainerDefinitionData($service, false, $showArguments);
$data['definitions'][$serviceId] = $this->getContainerDefinitionData($service, $omitTags, $showArguments);
}
} else {
$data['services'][$serviceId] = get_class($service);
Expand All @@ -124,7 +125,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
*/
protected function describeContainerDefinition(Definition $definition, array $options = array())
{
$this->writeData($this->getContainerDefinitionData($definition, isset($options['omit_tags']) && $options['omit_tags']), $options);
$this->writeData($this->getContainerDefinitionData($definition, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments']), $options);
}

/**
Expand All @@ -137,7 +138,7 @@ protected function describeContainerAlias(Alias $alias, array $options = array()
}

$this->writeData(
array($this->getContainerAliasData($alias), $this->getContainerDefinitionData($builder->getDefinition((string) $alias))),
array($this->getContainerAliasData($alias), $this->getContainerDefinitionData($builder->getDefinition((string) $alias), isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments'])),
array_merge($options, array('id' => (string) $alias))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function describeContainerService($service, array $options = array(),
throw new \InvalidArgumentException('An "id" option must be provided.');
}

$childOptions = array('id' => $options['id'], 'as_array' => true);
$childOptions = array_merge($options, array('id' => $options['id'], 'as_array' => true));

if ($service instanceof Alias) {
$this->describeContainerAlias($service, $childOptions, $builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ protected function describeContainerDefinition(Definition $definition, array $op
$tableRows[] = array('Service ID', isset($options['id']) ? $options['id'] : '-');
$tableRows[] = array('Class', $definition->getClass() ?: '-');

$tags = $definition->getTags();
if (count($tags)) {
$omitTags = isset($options['omit_tags']) && $options['omit_tags'];
if (!$omitTags && ($tags = $definition->getTags())) {
$tagInformation = array();
foreach ($tags as $tagName => $tagData) {
foreach ($tagData as $tagParameters) {
Expand Down Expand Up @@ -327,6 +327,22 @@ protected function describeContainerDefinition(Definition $definition, array $op
}
}

$showArguments = isset($options['show_arguments']) && $options['show_arguments'];
$argumentsInformation = array();
if ($showArguments && ($arguments = $definition->getArguments())) {
foreach ($arguments as $argument) {
if ($argument instanceof Reference) {
$argumentsInformation[] = sprintf('Service(%s)', (string) $argument);
} elseif ($argument instanceof Definition) {
$argumentsInformation[] = 'Inlined Service';
} else {
$argumentsInformation[] = $argument;
}
}

$tableRows[] = array('Arguments', implode("\n", $argumentsInformation));
}

$options['output']->table($tableHeaders, $tableRows);
}

Expand Down
Original file line number Diff line number Diff line change
Expand 8000 Up @@ -68,7 +68,7 @@ protected function describeContainerService($service, array $options = array(),
throw new \InvalidArgumentException('An "id" option must be provided.');
}

$this->writeDocument($this->getContainerServiceDocument($service, $options['id'], $builder));
$this->writeDocument($this->getContainerServiceDocument($service, $options['id'], $builder, isset($options['show_arguments']) && $options['show_arguments']));
}

/**
Expand All @@ -84,7 +84,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
*/
protected function describeContainerDefinition(Definition $definition, array $options = array())
{
$this->writeDocument($this->getContainerDefinitionDocument($definition, isset($options['id']) ? $options['id'] : null, isset($options['omit_tags']) && $options['omit_tags']));
$this->writeDocument($this->getContainerDefinitionDocument($definition, isset($options['id']) ? $options['id'] : null, isset($options['omit_tags']) && $options['omit_tags'], isset($options['show_arguments']) && $options['show_arguments']));
}

/**
Expand Down Expand Up @@ -284,7 +284,7 @@ private function getContainerServiceDocument($service, $id, ContainerBuilder $bu
if ($service instanceof Alias) {
$dom->appendChild($dom->importNode($this->getContainerAliasDocument($service, $id)->childNodes->item(0), true));
if ($builder) {
$dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($builder->getDefinition((string) $service), (string) $service)->childNodes->item(0), true));
$dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($builder->getDefinition((string) $service), (string) $service, false, $showArguments)->childNodes->item(0), true));
}
} elseif ($service instanceof Definition) {
$dom->appendChild($dom->importNode($this->getContainerDefinitionDocument($service, $id, false, $showArguments)->childNodes->item(0), true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ public function getDescribeContainerDefinitionTestData()
return $this->getDescriptionTestData(ObjectsProvider::getContainerDefinitions());
}

/** @dataProvider getDescribeContainerDefinitionWithArgumentsShownTestData */
public function testDescribeContainerDefinitionWithArgumentsShown(Definition $definition, $expectedDescription)
{
$this->assertDescription($expectedDescription, $definition, array('show_arguments' => true));
}

public function getDescribeContainerDefinitionWithArgumentsShownTestData()
{
$definitions = ObjectsProvider::getContainerDefinitions();
$definitionsWithArgs = array();

foreach ($definitions as $key => $definition) {
$definitionsWithArgs[str_replace('definition_', 'definition_arguments_', $key)] = $definition;
}

return $this->getDescriptionTestData($definitionsWithArgs);
}

/** @dataProvider getDescribeContainerAliasTestData */
public function testDescribeContainerAlias(Alias $alias, $expectedDescription)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"class": "Full\\Qualified\\Class1",
"public": true,
"synthetic": false,
"lazy": true,
"shared": true,
"abstract": true,
"autowire": false,
"autowiring_types": [],
"arguments": [
{
"type": "service",
"id": "definition2"
},
"%parameter%",
{
"class": "inline_service",
"public": true,
"synthetic": false,
"lazy": false,
"shared": true,
"abstract": false,
"autowire": false,
"autowiring_types": [],
"arguments": [
"arg1",
"arg2"
],
"file": null,
"tags": []
}
],
"file": null,
"factory_class": "Full\\Qualified\\FactoryClass",
"factory_method": "get",
"tags": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- Class: `Full\Qualified\Class1`
- Public: yes
- Synthetic: no
- Lazy: yes
- Shared: yes
- Abstract: yes
- Autowired: no
- Arguments: yes
- Factory Class: `Full\Qualified\FactoryClass`
- Factory Method: `get`
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
------------------ -----------------------------
 Option   Value 
------------------ -----------------------------
Service ID -
Class Full\Qualified\Class1
Tags -
Public yes
Synthetic no
Lazy yes
Shared yes
Abstract yes
Autowired no
Autowiring Types -
Factory Class Full\Qualified\FactoryClass
Factory Method get
Arguments Service(definition2)
%parameter%
Inlined Service
------------------ -----------------------------

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<definition class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" file="">
<factory class="Full\Qualified\FactoryClass" method="get"/>
<argument type="service" id="definition2"/>
<argument>%parameter%</argument>
<argument>
<definition class="inline_service" public="true" synthetic="false" lazy="false" shared="true" abstract="false" autowired="false" file="">
<argument>arg1</argument>
<argument>arg2</argument>
</definition>
</argument>
</definition>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"class": "Full\\Qualified\\Class2",
"public": false,
"synthetic": true,
"lazy": false,
"shared": true,
"abstract": false,
"autowire": false,
"autowiring_types": [],
"arguments": [],
"file": "\/path\/to\/file",
"factory_service": "factory.service",
"factory_method": "get",
"calls": [
"setMailer"
],
"tags": [
{
"name": "tag1",
"parameters": {
"attr1": "val1",
"attr2": "val2"
}
},
{
"name": "tag1",
"parameters": {
"attr3": "val3"
}
},
{
"name": "tag2",
"parameters": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- Class: `Full\Qualified\Class2`
- Public: no
- Synthetic: yes
- Lazy: no
- Shared: yes
- Abstract: no
- Autowired: no
- Arguments: no
- File: `/path/to/file`
- Factory Service: `factory.service`
- Factory Method: `get`
- Call: `setMailer`
- Tag: `tag1`
- Attr1: val1
- Attr2: val2
- Tag: `tag1`
- Attr3: val3
- Tag: `tag2`
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
------------------ ---------------------------------
 Option   Value 
------------------ ---------------------------------
Service ID -
Class Full\Qualified\Class2
Tags tag1 (attr1: val1, attr2: val2)
tag1 (attr3: val3)
tag2
Calls setMailer
Public no
Synthetic yes
Lazy no
Shared yes
Abstract no
Autowired no
Autowiring Types -
Required File /path/to/file
Factory Service factory.service 93E5
Factory Method get
------------------ ---------------------------------

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<definition class="Full\Qualified\Class2" public="false" synthetic="true" lazy="false" shared="true" abstract="false" autowired="false" file="/path/to/file">
<factory service="factory.service" method="get"/>
<calls>
<call method="setMailer"/>
</calls>
<tags>
<tag name="tag1">
<parameter name="attr1">val1</parameter>
<parameter name="attr2">val2</parameter>
</tag>
<tag name="tag1">
<parameter name="attr3">val3</parameter>
</tag>
<tag name="tag2"/>
</tags>
</definition>
0