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] Update List Information from ReflectionExtractor#16911

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

Closed
zanbaldwin wants to merge2 commits intosymfony:2.8fromzanbaldwin:feature/property-info-reflection-list
Closed

[PropertyInfo] Update List Information from ReflectionExtractor#16911

zanbaldwin wants to merge2 commits intosymfony:2.8fromzanbaldwin:feature/property-info-reflection-list

Conversation

@zanbaldwin
Copy link
Member

QA
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#16889
LicenseMIT
Doc PRsymfony/symfony-docs#5974

Unless a property with the same casing exists, lowercase the first letter of a property name extracted from a method. From what I understand, we don't actually need to supportsnake_case at all in the PropertyInfo component.

I cannot think of any use-case where PropertyAccess would be used to get/set a property valuebefore using PropertyInfo to find out information about the property and the values it supports.

Since PropertyInfo supports the discovery of property names, which can then be used as identifiers in PropertyAccess, there should be no need to support a naming strategy to map property identifiers from one naming convention to another.


Running$reflectionExtractor->getProperties($class) with the following classes:

class X{public$a;public$b;publicfunctiongetA() {}}// Result: array('a', 'b');
class Y{public$A;public$b;publicfunctionsetA() {}}// Result: array('A', 'b');
class Y{public$username;protected$emailAddress;public$password;publicfunctiongetEmailAddress() {}publicfunctionisActive() {}}// Result: array('username', 'emailAddress', 'password', 'active');

@zanbaldwinzanbaldwin changed the titleFeature/property info reflection list[PropertyInfo] Update List Information from ReflectionExtractorDec 8, 2015
Copy link
Member

Choose a reason for hiding this comment

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

You should use this regex instead:

// if more than two uppercase characters don't lcfirstreturn preg_match('/[A-Z]{2,}$/', $name) ? $name : lcfirst($name);

(First proposed by@soyuka inhttps://github.com/dunglas/DunglasApiBundle/pull/260/files)

It allows to handle properly methods likegetIBAN().

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Should that be/^[A-Z]{2,}/ to still lowercase the first letter of methods likegetCarsIOwn()?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not really:

> /[A-Z]{2,}$/.test('SIRET')true //don't lowercase first char> /[A-Z]{2,}$/.test('Siret')false //do lowercase> /[A-Z]{2,}$/.test('SIret')false //same> /[A-Z]{2,}/.test('SIret')true //with your regex it'd become SIret, but it should be sIret

Regex tests that the full property name is uppercased. If it's not, I think we should lower the first character.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

So are we lowercasing the first letter unless it doesn't contain any lowercase letters at all? Example...

InputResult
Aa
Aaaa
AAaaAa
AAAAAA

I don't think it's a good solution, unless I misunderstood what you meant.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I thought that it was:

Lowercase the first letter unless the string is an uppercased word (eg not only the first letter is uppercased).

For the above proposal, I was refering to getters/setters, for example:

InputResultWrong
getSomeVarsomeVar
getSIRETSIRETsIRET
getIBANIBANiBAN
getAnotherVariableWithUppercaseanotherVariableWithUppercase

That said, I might have misunderstood the goal of your PR.

@dunglas
Copy link
Member

Status: need work

Zander Baldwin added2 commitsDecember 9, 2015 10:50
Unless a property with the same casing exists, lowercase the first letter of a name extracted from a method.Fixes#16889.
@dunglas
Copy link
Member

Status: Reviewed

@dunglas
Copy link
Member

👍

@dunglas
Copy link
Member

Thanks for fixing this bug @zanderbaldwin.

dunglas added a commit that referenced this pull requestDec 14, 2015
…actor (zanderbaldwin)This PR was squashed before being merged into the 2.8 branch (closes#16911).Discussion----------[PropertyInfo] Update List Information from ReflectionExtractor| Q             | A| ------------- | ---| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#16889| License       | MIT| Doc PR        |symfony/symfony-docs#5974Unless a property with the same casing exists, lowercase the first letter of a property name extracted from a method. From what I understand, we don't actually need to support `snake_case` at all in the PropertyInfo component.I cannot think of any use-case where PropertyAccess would be used to get/set a property value *before* using PropertyInfo to find out information about the property and the values it supports.Since PropertyInfo supports the discovery of property names, which can then be used as identifiers in PropertyAccess, there should be no need to support a naming strategy to map property identifiers from one naming convention to another.---Running `$reflectionExtractor->getProperties($class)` with the following classes:```phpclass X{    public $a;    public $b;    public function getA() {}}// Result: array('a', 'b');``````phpclass Y{    public $A;    public $b;    public function setA() {}}// Result: array('A', 'b');``````phpclass Y{    public $username;    protected $emailAddress;    public $password;    public function getEmailAddress() {}    public function isActive() {}}// Result: array('username', 'emailAddress', 'password', 'active');```Commits-------b2da76c [PropertyInfo] Update List Information from ReflectionExtractor
This was referencedDec 26, 2015
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@zanbaldwin@dunglas@soyuka@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp