-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyInfo] ConstructorExtractor which has higher priority than PhpDocExtractor and ReflectionExtractor #30335
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
Conversation
Is it still WIP? ping @dunglas |
There are still controversial cases, I need more feedback. This discussion. |
/cc @joelwurtz |
I think it make sense to have something like this, however i'm not sure about the current priority system. To be clear, this is how it should be, but for BC purpose adding a new extractor on top of other would maybe induce a different behavior in existing application. What would be really nice is to split extraction for __constructor and attributes list, which is something that would be possible with #30818 (by passing a different extractor to the instantiator, and another one for the property list extraction) For the moment can we add this extractor without adding it to the flow of control (DI) ? So we don't break any behaviour but still allow people to use it ? WDYT @dunglas ? |
src/Symfony/Component/PropertyInfo/DependencyInjection/PropertyInfoConstructorPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/PropertyInfo/DependencyInjection/PropertyInfoConstructorPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/PropertyInfo/Extractor/ConstructorArgumentTypeExtractorInterface.php
Show resolved
Hide resolved
src/Symfony/Component/PropertyInfo/Extractor/ConstructorExtractor.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/PropertyInfo/Extractor/ConstructorArgumentTypeExtractorInterface.php
Show resolved
Hide resolved
src/Symfony/Component/PropertyInfo/Extractor/ConstructorExtractor.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/PropertyInfo/Tests/Extractor/ConstructorExtractorTest.php
Show resolved
Hide resolved
Thank you @joelwurtz for the code review. I applied all the suggestions and removed from FrameworkBundle all the injections so it won't introduce any BC break. |
@karser I haven't had a look at the code, but can you rebase the PR to get rid of the merge commit (we don't merge PR with merge commits). Also, is it still WIP? |
51ebfd7
to
95e2d3f
Compare
@fabpot I removed merges, squashed commits and removed WIP status. |
95e2d3f
to
3c21a3e
Compare
…ctor and ReflectionExtractor
3c21a3e
to
5049e25
Compare
Thank you @karser. |
…uctor (ogizanagi) This PR was merged into the 5.2-dev branch. Discussion ---------- [PropertyInfo] Fix ReflectionExtractor::getTypesFromConstructor | Q | A | ------------- | --- | Branch? | master <!-- see below --> | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | N/A <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | N/A Fixes https://travis-ci.org/github/symfony/symfony/jobs/721953907#L4274-L4296 Relates to #30335 Commits ------- 6423d8a [PropertyInfo] Fix ReflectionExtractor::getTypesFromConstructor
…xtractor` class (HypeMC) This PR was merged into the 7.3 branch. Discussion ---------- [FrameworkBundle][PropertyInfo] Wire the `ConstructorExtractor` class | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - A sort of followup to #30335. The original PR removed the wiring to prevent creating a BC break, see #30128 (comment) & #30335 (comment). This PR proposes adding a new `framework.property_info.with_constructor_extractor` configuration to allow optionally enabling the framework integration. The configuration defaults to `false` to prevent creating a BC break. Only when it's set to `true` will the `ConstructorExtractor` be registered in the container. Commits ------- 2b392b1 [FrameworkBundle][PropertyInfo] Wire the `ConstructorExtractor` class
Supersedes #30056 #30128
In short, when using PhpDocExtractor, it ignores the constructor argument type, although
argument types from the constructor are the only types that are valid for the class instantiation
.This PR adds a separate extractor -
ConstructorExtractor
which is called first (-999) and it attempts to extract the type from constructor only, either from PhpDoc or using reflection.I added
getTypesFromConstructor
toPhpDocExtractor
andReflectionExtractor
- they implementConstructorArgumentTypeExtractorInterface
interface.ConstructorExtractor
aggregates those extractors using compiler pass.So the flow of control looks like this: