Skip to content

Commit 9745bac

Browse files
committed
fix: breaking change for object that implements toRawArray()
1 parent 02e5a33 commit 9745bac

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

system/BaseModel.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,18 @@ protected function timeToString(array $properties): array
17351735
*/
17361736
protected function objectToRawArray($object, bool $onlyChanged = true, bool $recursive = false): array
17371737
{
1738-
if ($object instanceof Entity) {
1738+
/**
1739+
* @deprecated 4.4.4 Checking `toRawArray()` method is deprecated.
1740+
*/
1741+
if (method_exists($object, 'toRawArray')) {
1742+
if (! $object instanceof Entity) {
1743+
@trigger_error(
1744+
'In Model, to use your own class that implemented the "toRawArray()" method is deprecated.'
1745+
. ' It will be changed so that "toRawArray()" is only executed if the object is an CodeIgniter\'s "Entity".',
1746+
E_USER_DEPRECATED
1747+
);
1748+
}
1749+
17391750
$properties = $object->toRawArray($onlyChanged, $recursive);
17401751
} else {
17411752
$mirror = new ReflectionClass($object);

0 commit comments

Comments
 (0)