Skip to content

[FrameworkBundle] Remove useless checks in descriptors #21341

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 28, 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 @@ -217,29 +217,18 @@ private function getContainerDefinitionData(Definition $definition, $omitTags =
'public' => $definition->isPublic(),
'synthetic' => $definition->isSynthetic(),
'lazy' => $definition->isLazy(),
'shared' => $definition->isShared(),
'synchronized' => $definition->isSynchronized(false),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

broken here

'abstract' => $definition->isAbstract(),
'autowire' => $definition->isAutowired(),
'autowiring_types' => array(),
'file' => $definition->getFile(),
);

if (method_exists($definition, 'isShared')) {
$data['shared'] = $definition->isShared();
foreach ($definition->getAutowiringTypes() as $autowiringType) {
$data['autowiring_types'][] = $autowiringType;
}

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

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

if (method_exists($definition, 'isAutowired')) {
$data['autowire'] = $definition->isAutowired();

$data['autowiring_types'] = array();
foreach ($definition->getAutowiringTypes() as $autowiringType) {
$data['autowiring_types'][] = $autowiringType;
}
}

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

if ($definition->getFactoryClass(false)) {
$data['factory_class'] = $definition->getFactoryClass(false);
}
Expand Down Expand Up @@ -269,11 +258,9 @@ private function getContainerDefinitionData(Definition $definition, $omitTags =

if (!$omitTags) {
$data['tags'] = array();
if (count($definition->getTags())) {
foreach ($definition->getTags() as $tagName => $tagData) {
foreach ($tagData as $parameters) {
$data['tags'][] = array('name' => $tagName, 'parameters' => $parameters);
}
foreach ($definition->getTags() as $tagName => $tagData) {
foreach ($tagData as $parameters) {
$data['tags'][] = array('name' => $tagName, 'parameters' => $parameters);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,24 +183,14 @@ protected function describeContainerDefinition(Definition $definition, array $op
."\n".'- Public: '.($definition->isPublic() ? 'yes' : 'no')
."\n".'- Synthetic: '.($definition->isSynthetic() ? 'yes' : 'no')
."\n".'- Lazy: '.($definition->isLazy() ? 'yes' : 'no')
."\n".'- Shared: '.($definition->isShared() ? 'yes' : 'no')
."\n".'- Synchronized: '.($definition->isSynchronized(false) ? 'yes' : 'no')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

broken here

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

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

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

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

if (method_exists($definition, 'isAutowired')) {
$output .= "\n".'- Autowired: '.($definition->isAutowired() ? 'yes' : 'no');

foreach ($definition->getAutowiringTypes() as $autowiringType) {
$output .= "\n".'- Autowiring Type: `'.$autowiringType.'`';
}
foreach ($definition->getAutowiringTypes() as $autowiringType) {
$output .= "\n".'- Autowiring Type: `'.$autowiringType.'`';
}

if ($definition->getFile()) {
Expand Down Expand Up @@ -371,7 +361,7 @@ protected function describeCallable($callable, array $options = array())
*/
private function formatRouterConfig(array $array)
{
if (!count($array)) {
if (!$array) {
return 'NONE';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ 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)) {
if ($tags = $definition->getTags()) {
$tagInformation = '';
foreach ($tags as $tagName => $tagData) {
foreach ($tagData as $tagParameters) {
Expand All @@ -281,24 +280,12 @@ protected function describeContainerDefinition(Definition $definition, array $op
$tableRows[] = array('Public', $definition->isPublic() ? 'yes' : 'no');
$tableRows[] = array('Synthetic', $definition->isSynthetic() ? 'yes' : 'no');
$tableRows[] = array('Lazy', $definition->isLazy() ? 'yes' : 'no');

if (method_exists($definition, 'isSynchronized')) {
$tableRows[] = array('Synchronized', $definition->isSynchronized(false) ? 'yes' : 'no');
}
$tableRows[] = array('Synchronized', $definition->isSynchronized(false) ? 'yes' : 'no');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

broken here

$tableRows[] = array('Abstract', $definition->isAbstract() ? 'yes' : 'no');
$tableRows[] = array('Autowired', $definition->isAutowired() ? 'yes' : 'no');

if (method_exists($definition, 'isAutowired')) {
$tableRows[] = array('Autowired', $definition->isAutowired() ? 'yes' : 'no');

$autowiringTypes = $definition->getAutowiringTypes();
if (count($autowiringTypes)) {
$autowiringTypesInformation = implode(', ', $autowiringTypes);
} else {
$autowiringTypesInformation = '-';
}

$tableRows[] = array('Autowiring Types', $autowiringTypesInformation);
}
$autowiringTypes = $definition->getAutowiringTypes();
$tableRows[] = array('Autowiring Types', $autowiringTypes ? implode(', ', $autowiringTypes) : '-');

if ($definition->getFile()) {
$tableRows[] = array('Required File', $definition->getFile() ? $definition->getFile() : '-');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private function getRouteDocument(Route $route, $name = null)
$methodXML->appendChild(new \DOMText($method));
}

if (count($route->getDefaults())) {
if ($route->getDefaults()) {
$routeXML->appendChild($defaultsXML = $dom->createElement('defaults'));
foreach ($route->getDefaults() as $attribute => $value) {
$defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
Expand All @@ -198,7 +198,7 @@ private function getRouteDocument(Route $route, $name = null)

$requirements = $route->getRequirements();
unset($requirements['_scheme'], $requirements['_method']);
if (count($requirements)) {
if ($requirements) {
$routeXML->appendChild($requirementsXML = $dom->createElement('requirements'));
foreach ($requirements as $attribute => $pattern) {
$requirementsXML->appendChild($requirementXML = $dom->createElement('requirement'));
Expand All @@ -207,7 +207,7 @@ private function getRouteDocument(Route $route, $name = null)
}
}

if (count($route->getOptions())) {
if ($route->getOptions()) {
$routeXML->appendChild($optionsXML = $dom->createElement('options'));
foreach ($route->getOptions() as $name => $value) {
$optionsXML->appendChild($optionXML = $dom->createElement('option'));
Expand Down Expand Up @@ -331,18 +331,16 @@ 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->getFactoryClass(false)) {
$serviceXML->setAttribute('factory-class', $definition->getFactoryClass(false));
}

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's wrong. FactoryClass, FactoryService and FactoryMethod are removed in 3.0. So this must still be conditional here (and the code should be removed when dropping support for DI 2.8)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stof We're in the 2.8 branch and it requires only Symfony 2.8 (it doesn't work with 3.0). It must indeed be dropped when merging in 3.0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, we used to support 3.0.x in the past

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After double checking:

It should be as is in 2.8, conditional in 3.0 and 3.1 and finally dropped in 3.2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check when and why we dropped support for 3.0 here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it has never been supported. The DI dependency was bumped to 2.8 (with no explicit support for 3.0) in 73f0ee2 without obvious reasons and stayed as is since 2 years.

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

if ($factory = $definition->getFactory()) {
Expand All @@ -366,24 +364,14 @@ 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, 'isShared')) {
$serviceXML->setAttribute('shared', $definition->isShared() ? 'true' : 'false');
}
if (method_exists($definition, 'isSynchronized')) {
$serviceXML->setAttribute('synchronized', $definition->isSynchronized(false) ? 'true' : 'false');
}
$serviceXML->setAttribute('shared', $definition->isShared() ? 'true' : 'false');
$serviceXML->setAttribute('synchronized', $definition->isSynchronized(false) ? 'true' : 'false');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same issue here. isSynchronized is removed in 3.0

$serviceXML->setAttribute('abstract', $definition->isAbstract() ? 'true' : 'false');

if (method_exists($definition, 'isAutowired')) {
$serviceXML->setAttribute('autowired', $definition->isAutowired() ? 'true' : 'false');
}

$serviceXML->setAttribute('autowired', $definition->isAutowired() ? 'true' : 'false');
$serviceXML->setAttribute('file', $definition->getFile());

if (!$omitTags) {
$tags = $definition->getTags();

if (count($tags) > 0) {
if ($tags = $definition->getTags()) {
$serviceXML->appendChild($tagsXML = $dom->createElement('tags'));
foreach ($tags as $tagName => $tagData) {
foreach ($tagData as $parameters) {
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy