You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
name: Bug report
about: The documentation in section "Handling Business Logic" may lead to the impression that under all circumstances the magic methods __get and __set make sure that the PascalCase getXXX and setXXX methods are called. This is not true.
Describe the bug
The documentation says
For each one, the class expects the snake_case column name to be converted into PascalCase, and prefixed with either set or get. These methods will then be automatically called whenever you set or retrieve the class property using the direct syntax (i.e. $user->email).
Unfortunately this is not true. The PHP manual says:
__set() is run when writing data to inaccessible properties. __get() is utilized for reading data from inaccessible properties.
So, whenever you do an assignment to the properties within class methods the magic setters and getters are not called. When the properties are protected also methods of derived classes will not make use of __get or __set.
This also means that the supplied example setCreatedAt is useless because this method is not called internally when modifying the created_at property.
CodeIgniter 4 version
CodeIgniter 4.0.0 Alpha 2 release
Affected module(s)
Entity
The text was updated successfully, but these errors were encountered:
Thanks. Have added a note to clarify that situation.
As for the setCreatedAt method - it is still valid. When the entity is created and data dumped in from the Model, that method would be called, and would convert the date to a Time instance that can be used by the developer.
name: Bug report
about: The documentation in section "Handling Business Logic" may lead to the impression that under all circumstances the magic methods __get and __set make sure that the PascalCase getXXX and setXXX methods are called. This is not true.
Describe the bug
The documentation says
Unfortunately this is not true. The PHP manual says:
So, whenever you do an assignment to the properties within class methods the magic setters and getters are not called. When the properties are protected also methods of derived classes will not make use of __get or __set.
This also means that the supplied example setCreatedAt is useless because this method is not called internally when modifying the created_at property.
CodeIgniter 4 version
CodeIgniter 4.0.0 Alpha 2 release
Affected module(s)
Entity
The text was updated successfully, but these errors were encountered: