-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()) { | ||
|
@@ -371,7 +361,7 @@ protected function describeCallable($callable, array $options = array()) | |
*/ | ||
private function formatRouterConfig(array $array) | ||
{ | ||
if (!count($array)) { | ||
if (!$array) { | ||
return 'NONE'; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
|
@@ -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'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() : '-'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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')); | ||
|
@@ -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')); | ||
|
@@ -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')); | ||
|
@@ -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)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, we used to support 3.0.x in the past There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()) { | ||
|
@@ -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'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same issue here. |
||
$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) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
broken here