Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[PropertyInfo] Added support for extract type from default value#27570
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[PropertyInfo] Added support for extract type from default value#27570
Uh oh!
There was an error while loading.Please reload this page.
Conversation
fabpot left a comment
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.
with a minor comment
| returnnull; | ||
| } | ||
| $map =array( |
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.
What about storing this as a static property on the class instead?
tsantos84Jun 27, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Sure. Actually, quite obvious.
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.
Can even be aprivate const as it targets master.
src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| 'double' => Type::BUILTIN_TYPE_FLOAT, | ||
| ); | ||
| $type =gettype($defaultValues[$property]); |
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.
I think it's safer to pass (return null) if the type is null.
Most of the time, it will mean that the property isn't initialized (and it may be initialized in the constructor, with null values not allowed). Even whennull is intended, it's very unlikely that it will be the only type allowed.
Returning an array means that next extractors in the chain will be skipped, it shouldn't be the case if the value isnull (another extractor may find the relevant type).
tsantos84 commentedJul 3, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@dunglas, anymore work should be done here? |
| */ | ||
| publicfunctiontestExtractWithDefaultValue($property,$type) | ||
| { | ||
| $this->assertEquals($type,$this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\DefaultValue',$property,array())); |
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.
DefaultValue::class
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.
Done, but there are a lot of FQN refers in the test class. It's ok?
Uh oh!
There was an error while loading.Please reload this page.
tsantos84 commentedJul 10, 2018
Hi@dunglas, Anymore work to do here? |
sroze left a comment
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.
Very nice 👍
| */ | ||
| publicstatic$defaultArrayMutatorPrefixes =array('add','remove'); | ||
| privatestatic$mapTypes =array( |
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.
Could be aconst right?
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.
Sure.
Uh oh!
There was an error while loading.Please reload this page.
tsantos84 commentedSep 18, 2018
Could someone point me how to fix the broken tests on PHP 7.1? I didn't find out how these last changes has impacted on other SF components. |
dunglas commentedSep 18, 2018
Failures look unrelated with your changes. |
tsantos84 commentedSep 18, 2018
Nice. Thank you. |
fabpot commentedOct 10, 2018
@tsantos84 Can you rebase this PR to get rid of the merge commits (this is a requirement before I can merge)? Thank you. |
tsantos84 commentedOct 21, 2018
@fabpot, I've got all this commits after rebasing the branch. Is this the expected result? Sounds weird for me. I've never use rebase before to be honest. |
tsantos84 commentedNov 3, 2018
Github had bad moments exactly when I've tried to call you to help me with rebase. I think its better to create a new branch and cherry pick only the necessary commits. |
xabbuh commentedNov 3, 2018
@tsantos84 I have rebased your PR. Can you double-check that I didn't mess up anything? |
tsantos84 commentedNov 3, 2018
All commits are there. Many thanks for help me in this PR. |
xabbuh commentedNov 5, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
It could be worth to add an entry to the component's changelog file. |
nicolas-grekas commentedDec 1, 2018
@tsantos84 could you please add a note in the changelog file of the component as suggested by@xabbuh? |
tsantos84 commentedDec 2, 2018
Sure. Which version should I reference? |
tsantos84 commentedDec 3, 2018
chalasr commentedDec 12, 2018
@tsantos84 4.3.0 is the target here. |
tsantos84 commentedJan 18, 2019
Done,@dunglas. Sorry for the very long time since your request for these changes. |
fabpot commentedFeb 21, 2019
Thank you@tsantos84. |
…ault value (tsantos84)This PR was squashed before being merged into the 4.3-dev branch (closes#27570).Discussion----------[PropertyInfo] Added support for extract type from default value| Q | A| ------------- | ---| Branch? | master || Bug fix? | no| New feature? | yes || BC breaks? | no || Deprecations? | no || Tests pass? | yes || Fixed tickets | - || License | MIT || Doc PR | - |Added support for extract type from property's default value.```phpclass Dummy{ private $age = 30;}$types = $propertyInfo->getTypes('Dummy', 'age');/* Example Result -------------- array(1) { [0] => class Symfony\Component\PropertyInfo\Type (6) { private $builtinType => string(3) "int" private $nullable => bool(false) private $class => 'Dummy' private $collection => bool(false) private $collectionKeyType => NULL private $collectionValueType => NULL } }*/```Commits-------f6510cd [PropertyInfo] Added support for extract type from default value
Uh oh!
There was an error while loading.Please reload this page.
Added support for extract type from property's default value.