-
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
fix: Entity can't handle column named attributes #5781
fix: Entity can't handle column named attributes #5781
Conversation
Add _set*() method as a setter.
I like this solution better, but let's wrap up the Issue conversation first. I think it is quite possible that someone is using |
// If a "`_set` + $key" method exists, it is a setter. | ||
if (method_exists($this, '_' . $method)) { | ||
$this->{$method}($value); | ||
|
||
return $this; | ||
} | ||
|
||
// If a "`set` + $key" method exists, it is also a setter. | ||
// But setAttributes() is not a setter for this. | ||
if ($key !== 'attributes' && method_exists($this, $method)) { |
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.
// If a "`_set` + $key" method exists, it is a setter. | |
if (method_exists($this, '_' . $method)) { | |
$this->{$method}($value); | |
return $this; | |
} | |
// If a "`set` + $key" method exists, it is also a setter. | |
// But setAttributes() is not a setter for this. | |
if ($key !== 'attributes' && method_exists($this, $method)) { | |
// If a "`_set` + $key" method exists, it is a setter, or | |
// if a "`set` + $key" method exists, it is also a setter. | |
// But setAttributes() is not a setter for this. | |
if (method_exists($this, '_' . $method) || ($key !== 'attributes' && method_exists($this, $method))) { |
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.
Let's make code shorter,
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, I found a bug in my code.
Why do you like shorter code?
Maybe mark this one to revisit for version 5? |
Description
Fixes #5762
Supersede #5763
_set
+ key" for a attributeChecklist: