Skip to content

[FrameworkBundle] PropertyInfo support #15966

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

Closed
wants to merge 6 commits into from

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Sep 28, 2015

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

*
* @return array
*/
private function findAndSortTaggedServices($tagName, ContainerBuilder $container)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any way to factorize this method as you use it in all compiler pass. Might be useful for others.

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 would be better to have it in a separate class but in the Serializer class the behavior is not exactly the same (an error is thrown if normalizer is added, this is not desirable here).

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

@dunglas
Copy link
Member Author

dunglas commented Sep 29, 2015

Issues raised by @stof fixed.

@dunglas
Copy link
Member Author

dunglas commented Sep 30, 2015

ping @symfony/deciders

</service>

<!-- Extractor -->
<service id="property_info.reflection_extractor" public="false">
Copy link
Contributor

Choose a reason for hiding this comment

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

missing property class

<service id="property_info.reflection_extractor" class="Symfony\Component\PropertyInfo\ReflectionExtractor" public="false"  >

@dunglas
Copy link
Member Author

dunglas commented Oct 5, 2015

Thank you for your review @aitboudad... I'll fix all those issues and test it in real conditions.

Status: Needs Work

@dunglas
Copy link
Member Author

dunglas commented Oct 6, 2015

Status: Needs Review

}
}

if (0 === count($sortedServices)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if (empty($sortedServices)) {
    return array();
}
// or maybe even
if (!$sortedServices) {
    return array();
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Why not count?

Copy link
Contributor

Choose a reason for hiding this comment

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

Count is (IIRC) less efficient if it comes to just checking that array is not empty, it would use more memory to check (run thought whole array) just to be sure it contains something, while empty checks are much more simple.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the explanation.

@dunglas dunglas force-pushed the fwbundle_propertyinfo branch from 22d5d95 to 790dd5a Compare October 10, 2015 09:16
@dunglas
Copy link
Member Author

dunglas commented Oct 10, 2015

Rebased.


$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', array('findTaggedServiceIds'));

$container->expects($this->atLeastOnce())
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest we avoid checking number of calls with stubs and use $this->any() instead. It's not important how many times a stubbed method is called. It's important that if it's called, it returns the stubbed value. Relying on number of calls to stubbed methods makes refactorings harder. It ties tests to the implementation.

There's a similar case in the next test.

@fabpot
Copy link
Member

fabpot commented Oct 19, 2015

Thank you @dunglas.

@fabpot fabpot closed this in 87f83f7 Oct 19, 2015
@dunglas dunglas deleted the fwbundle_propertyinfo branch October 19, 2015 12:08
@fabpot fabpot mentioned this pull request Nov 16, 2015
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.

8 participants