-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: add new setter/getter for Entity #7230
Conversation
4ca42db
to
e977ae9
Compare
I'm not sure what this is needed for? |
For method name collision. #5762 (comment) |
I meant the colons in the value, but now I see those are an artifact of the test fixture, not part of the code! My mistake. |
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.
Looks good, pending docs.
e977ae9
to
8006f5f
Compare
Added docs. |
8006f5f
to
6f52f1e
Compare
@mostafakhudair @najdanovicivan @iRedds @the-gt99 @lonnieezell |
I think this adds a lot of unnecessary complexity to have multiple ways of defining setters. So far the only problem we have is when we need to override setAttributes method. Since now we have setAttributes as deprecated and we're going forward with injectRawData() method. I'd rather use https://www.php.net/manual/en/reflectionmethod.getdeclaringclass.php to check if setAttributes is not from CodeIgniter\Entity or CodeIgniter\Entity\Entity class. So if method is not from base CI4 classes it can be handled as regular setter for $this->attributes['attributes']. The only problem with this one is BC in Entity classes which override the setAttributes method. |
@najdanovicivan Thank you for your opinion. The main reason of this PR is to avoid setter/getter method name conflicts, |
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.
Docs look good.
As far as I remember, PSR does not recommend using the underscore character as a prefix for method names. |
We don't remove If there are columns |
Needs #7208Description
Add special getter/setter to Entity to avoid method name conflicts.
_set
+ key" for a attribute_get
+ key" for a attributeChecklist: