-
Notifications
You must be signed in to change notification settings - Fork 2k
refactor: Rework Entity class
#9878
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
base: 4.7
Are you sure you want to change the base?
Conversation
neznaika0
left a comment
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.
An actual note? We can already have the 'attributes' field
michalsn
left a comment
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.
Some initial comments added.
If you fix a bug, it should be mentioned in the changelog as well.
I've lost the changes. I'll fix it |
6efe618 to
027a0f2
Compare
|
|
Additionally:
public function __construct(array $data = [])
{
// ...
$this->syncOriginal()->fill($data);
}
public function fill(array $data)
{
// ...
} |
michalsn
left a comment
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.
- The question remains refactor: Rework
Entityclass #9878 (review)
I think we could already with _setAttributes(). Since we dropped setAttributes(), I see no problem with removing this note.
I would return the array check and fix fill() -null is never needed there.
Users are allowed to create the Entity and fill it later. This change could break people's apps.
How? Does the default constructor have an empty array, and |
This is a BC break, which has no real benefit. |
|
Good. Let's leave it. But we're breaking in 4.7. In my opinion, using null is the wrong developer code. php8.5 has already been released, and we still support the old standards. Of course, this is a concern for the developers... |
We do allow BC breaks, but only when they provide clear value or affect minimally exposed internals. This change does neither and would introduce unnecessary risk for users. That said, I'm not stubborn... if other maintainers think that this is the right direction, then I won't be opposed. |
michalsn
left a comment
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.
Other than this, looks good to me. Thanks.
michalsn
left a comment
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.
Final round from me, cleanup only.
| /** | ||
| * This method allows you to refuse to contain an unnecessary DataCaster if you do not use casting. | ||
| */ |
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 method allows you to refuse to contain an unnecessary DataCaster if you do not use casting. | |
| */ | |
| /** | |
| * Returns a DataCaster instance when casts are defined. | |
| * If no casts are configured, no DataCaster is created and null is returned. | |
| */ |
|
|
||
| // Synchronize option with DataCaster initialization | ||
| $this->dataCaster(); | ||
|
|
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 is not needed as $_cast does not decide about DataCaster initialization.
Description
I keep track of entity changes. At the moment, I don't see any conflicts when using 'attributes' as the column name.
There was also a bug with the restore of
$_cast.Question: Do I need to get rid of the DataCaster object? For example, I completely disabled casting in the Entity and transform it into a Model. But the object is always being created.
I could, under the condition
$_cast = false, not create it or destroy it when calling$this->cast(false). We can simplify by callinggetDataCaster()"on the fly", although it's no better to create an object every time. Suggestions?It is also planned to update the DateCast to use the interface, since it does not always set DateTime, but also DateTimeImmutable.
PR should be taken after #9877 But we can discuss it now.Checklist: