-
-
Notifications
You must be signed in to change notification settings - Fork 328
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
Add support for snake_care properties in fixtures. #323
Conversation
A good codingstyle would have the setters also in snake_case, not in camelCase. |
Having a PSR2 compatible code style with snake case properties. And several MLOC, I would rather not change. Already implemented this as extension in the company, just trying to give something back by making Alice more codestyle agnostic. |
Do I understand you right that you have snake_case properties and camelCase setters? |
correct. |
I think I'm good for this, since it doesn't break BC - @Seldaek any comments? |
Seems safe enough as long as people use camelCased method names, but strictly speaking it does break BC as if you have setfoo_bar it'll now call setfoobar. I doubt it'll really be an issue in practice though. |
Remaining BC if a setsnake_case setter exists. When for a property a setter exists Alice will use that setter to populate the value. Now properties that use snake case are also transformed into their corresponding setters. For example: Nelmio\Alice\support\models\User: user{1..10}: family_name: <lastName()> will use the setter setFamilyName if available and otherwise fill the property without setter.
@tshelburne I agree, added it in. |
@hboomsma I've made a PR with a few changes. Once merged I will merge and squash this PR. If you have a property
If it is a normal property, e.g.
It also avoids to introduce a BC @Seldaek mentioned. |
Thanks very much for the work @hboomsma :) |
When for a property a setter exists Alice will use that setter to populate the value. Now properties that use snake case are also transformed into their corresponding setters. For example:
Will use the setter setFamilyName if available and otherwise fill the property without setter.