-
-
Notifications
You must be signed in to change notification settings - Fork 416
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
[make:entity] managing keyword prefixes (is, has) for boolean properties getters #1493
[make:entity] managing keyword prefixes (is, has) for boolean properties getters #1493
Conversation
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.
This change makes sense to me. It's consistent with the autodetection of the type (boolean) when asking for the type.
I'd suggest doing the same for setters, but only for the "is" prefix: isInternational property => setInternational. (but hasColor => setHasColor)
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.
This looks pretty good @ClemRiviere! - 1 minor comment. Also if you're up for doing the same for addSetter()
as @nicolas-grekas suggested, that would be even more awesome!
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.
Thanks @ClemRiviere!
This change does not make sense to me as it makes those setter incompatible with the property-access component (and so with the form component that relies on it) |
A link wasn't added automatically (maybe becaues it was a discussion, not an issue), but this is now causing property access issues as discussed in symfony/symfony#54885 (reply in thread). |
@stof I understand, I think we have two potential solutions for this :
I would personally go for the first solution, @jrushlow or @nicolas-grekas do you guys have any advices on this topic ? |
… setters (octoseth) This PR was merged into the 1.x-dev branch. Discussion ---------- [make-entity]Keep the 'is' prefixes for booleans properties setters When generating a new entity, if we name a boolean property with the prefix "is", this prefix is removed to construct the setter. example: ``` bool $isInternational; public function isInternational(): ?bool { return $this->isInternational; } public function setInternational(bool $isInternational): static { $this->isInternational = $isInternational; return $this; } ``` This is breaking when we want to access the property via a form : > [NoSuchPropertyException] > HTTP 500 Internal Server Error > The method "isInternational" in class "App\Entity\Conference" requires 0 arguments, but should accept only 1.. Make the property public, add a setter, or set the "mapped" field option in the form type to be false. This PR revert this change introduce in [PR 1493](#1493) to keep the 'is' prefix on the setter. example : ``` public function setIsInternational(bool $isInternational): static { $this->isInternational = $isInternational; return $this; } ``` Commits ------- 9fa9221 Keep the 'is' prefix on a boolean property when making the setter
make:entity
Related to #1492