-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyInfo] Property case depends on the second character's case #32656
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
Comments
This can be reproduced on 3.4. @xabbuh This issue concerns PropertyInfo, not PropertyAccess and it's caused by this condition here: Basically in this case the first letter is not lowercased because it passes the regex test. I'm not sure what the fix should be, but I tend to agree with the comments in the api-platform issue that we should probably define a list of rules based on which we perform the extraction and document it somewhere. You could update the condition to something like this:
but then it would break other cases such as:
|
Would it be enough to check if the property is in full caps maybe? |
…om public method name (antograssiot) This PR was merged into the 3.4 branch. Discussion ---------- [PropertyInfo] Respect property name case when guessing from public method name | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #32656 | License | MIT | Doc PR | Using camelCase, with an attribute `$aFooBar`, naming the getter/setter `getAFooBar()`/`setAFooBar()`, returns the property name as AFooBar instead of aFooBar. # Before Property name `'AFooBar'` # After Property name `'aFooBar'` as expected Commits ------- 843bb76 [PropertyInfo] Respect property name case when guessing from public method name
Symfony version(s) affected: 4.3.2
Description
Using camelCase, with an attribute
$aFooBar
, naming the getter/settergetAFooBar()
/setAFooBar()
returns the property name asAFooBar
instead ofaFooBar
.I'm not sure if this is a bug or intended behavior, but it seems weird that the second character's case dictates the first character case, as:
getAFooBar
returns the property name asAFooBar
(1&2 uppercase => 1&2 uppercase)getAfooBar
returns the property name asafooBar
(1 uppercase & 2 lowercase => 1&2 lowercase)Found it out the hard way through api-platform/core#2941
Generating the getter with
make:entity
from the attribute$aFooBar
generatesgetAFooBar()
which in turn gives the property nameAFooBar
.How to reproduce
Create an entity such as the one below and get its properties.
The text was updated successfully, but these errors were encountered: