Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged
fabpot merged 1 commit intosymfony:masterfromtsantos84:extract-property-type-from-default-value
Feb 21, 2019
Merged

[PropertyInfo] Added support for extract type from default value#27570

fabpot merged 1 commit intosymfony:masterfromtsantos84:extract-property-type-from-default-value
Feb 21, 2019

Conversation

@tsantos84
Copy link
Contributor

@tsantos84tsantos84 commentedJun 9, 2018
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR-

Added support for extract type from property's default value.

class 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    }  }*/

ro0NL, DavidBadura, yceruto, and teohhanhui reacted with thumbs up emoji
Copy link
Member

@fabpotfabpot left a 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(
Copy link
Member

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?

Copy link
ContributorAuthor

@tsantos84tsantos84Jun 27, 2018
edited
Loading

Choose a reason for hiding this comment

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

Sure. Actually, quite obvious.

Copy link
Member

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.

jvasseur reacted with thumbs up emoji
'double' => Type::BUILTIN_TYPE_FLOAT,
);

$type =gettype($defaultValues[$property]);
Copy link
Member

@dunglasdunglasJun 28, 2018
edited
Loading

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
Copy link
ContributorAuthor

tsantos84 commentedJul 3, 2018
edited
Loading

@dunglas, anymore work should be done here?

*/
publicfunctiontestExtractWithDefaultValue($property,$type)
{
$this->assertEquals($type,$this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\DefaultValue',$property,array()));
Copy link
Member

Choose a reason for hiding this comment

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

DefaultValue::class

Copy link
ContributorAuthor

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?

@tsantos84
Copy link
ContributorAuthor

Hi@dunglas, Anymore work to do here?

Copy link
Contributor

@srozesroze left a 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(
Copy link
Member

Choose a reason for hiding this comment

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

Could be aconst right?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sure.

@tsantos84
Copy link
ContributorAuthor

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
Copy link
Member

Failures look unrelated with your changes.

@tsantos84
Copy link
ContributorAuthor

Nice. Thank you.

@fabpot
Copy link
Member

@tsantos84 Can you rebase this PR to get rid of the merge commits (this is a requirement before I can merge)? Thank you.

@tsantos84
Copy link
ContributorAuthor

@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
Copy link
ContributorAuthor

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
Copy link
Member

@tsantos84 I have rebased your PR. Can you double-check that I didn't mess up anything?

tsantos84 and curtchan reacted with thumbs up emojitsantos84 reacted with hooray emoji

@tsantos84
Copy link
ContributorAuthor

All commits are there. Many thanks for help me in this PR.

@xabbuh
Copy link
Member

xabbuh commentedNov 5, 2018
edited
Loading

It could be worth to add an entry to the component's changelog file.

@nicolas-grekas
Copy link
Member

@tsantos84 could you please add a note in the changelog file of the component as suggested by@xabbuh?

@tsantos84
Copy link
ContributorAuthor

Sure. Which version should I reference?

@tsantos84
Copy link
ContributorAuthor

@nicolas-grekas?

@chalasr
Copy link
Member

@tsantos84 4.3.0 is the target here.

@tsantos84
Copy link
ContributorAuthor

Done,@dunglas. Sorry for the very long time since your request for these changes.

@fabpot
Copy link
Member

Thank you@tsantos84.

@fabpotfabpot merged commitf6510cd intosymfony:masterFeb 21, 2019
fabpot added a commit that referenced this pull requestFeb 21, 2019
…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
@tsantos84tsantos84 deleted the extract-property-type-from-default-value branchFebruary 21, 2019 14:15
@nicolas-grekasnicolas-grekas modified the milestones:next,4.3Apr 30, 2019
@fabpotfabpot mentioned this pull requestMay 9, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@dunglasdunglasdunglas approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@xabbuhxabbuhxabbuh approved these changes

@lyrixxlyrixxAwaiting requested review from lyrixx

+1 more reviewer

@srozesrozesroze approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

8 participants

@tsantos84@dunglas@fabpot@xabbuh@nicolas-grekas@chalasr@sroze@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp