Skip to content

Commit

Permalink
fix: breaking change for object that implements toRawArray()
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Nov 28, 2023
1 parent 02e5a33 commit 9745bac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion system/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,18 @@ protected function timeToString(array $properties): array
*/
protected function objectToRawArray($object, bool $onlyChanged = true, bool $recursive = false): array
{
if ($object instanceof Entity) {
/**
* @deprecated 4.4.4 Checking `toRawArray()` method is deprecated.
*/
if (method_exists($object, 'toRawArray')) {
if (! $object instanceof Entity) {
@trigger_error(
'In Model, to use your own class that implemented the "toRawArray()" method is deprecated.'
. ' It will be changed so that "toRawArray()" is only executed if the object is an CodeIgniter\'s "Entity".',
E_USER_DEPRECATED
);
}

$properties = $object->toRawArray($onlyChanged, $recursive);
} else {
$mirror = new ReflectionClass($object);
Expand Down

0 comments on commit 9745bac

Please sign in to comment.