Thanks to visit codestin.com
Credit goes to github.com

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

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Jan 19, 2017

Q A
Branch? 2.8
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

As pointed out by @ogizanagi in #21315 (comment), some code in FrameworkBundle's descriptors is useless because the bundle works only with DI 2.8.


$tableRows[] = array('Autowiring Types', $autowiringTypesInformation);
$autowiringTypes = $definition->getAutowiringTypes();
if (count($autowiringTypes)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

As pointed out multiple times on some other PRs by @nicolas-grekas , the count is useless and seems to be avoided thus in the Symfony codebase. Could you take advantage of this PR to change it here too?
Could also be inlined using a ternary without loosing readability here IMHO.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indded.

@ogizanagi
Copy link
Contributor

Status: Reviewed

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('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

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

@@ -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

@@ -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

@dunglas
Copy link
Member Author

dunglas commented Jan 19, 2017

Removed some useless counts.

@@ -269,8 +258,8 @@ private function getContainerDefinitionData(Definition $definition, $omitTags =

if (!$omitTags) {
$data['tags'] = array();
if (count($definition->getTags())) {
foreach ($definition->getTags() as $tagName => $tagData) {
if ($tags = $definition->getTags()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This if becomes useless too.

@nicolas-grekas nicolas-grekas added this to the 2.8 milestone Jan 24, 2017
@nicolas-grekas
Copy link
Member

👍

@fabpot
Copy link
Member

fabpot commented Jan 24, 2017

Does it mean that @stof comments were wrong or fixed but Github does not show that? Sorry, I haven't re-read the PR.

@dunglas
Copy link
Member Author

dunglas commented Jan 24, 2017

@fabpot yes but we need to be very careful when merging to other branches (I can do the merge if you want).

@fabpot
Copy link
Member

fabpot commented Jan 24, 2017

@dunglas Ok, I Iet you merge this one and then merge to other branches, that will be much easier.

@dunglas dunglas merged commit c759345 into symfony:2.8 Jan 28, 2017
dunglas added a commit that referenced this pull request Jan 28, 2017
…dunglas)

This PR was merged into the 2.8 branch.

Discussion
----------

[FrameworkBundle] Remove useless checks in descriptors

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

As pointed out by @ogizanagi in #21315 (comment), some code in FrameworkBundle's descriptors is useless because the bundle works only with DI 2.8.

Commits
-------

c759345 [FrameworkBundle] Remove useless checks in descriptors
@dunglas dunglas deleted the simplify_def branch January 28, 2017 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants