Calling %s() on an object is deprecated¶
Description¶
prev()
, current()
, next()
and reset()
where php native functions used to navigate in arrays. They also applied to objects, although this is an accidental feature. Nowadays, using object with these functions is deprecated.
Example¶
<?php
$object = (object) ['a' => 1];
echo current($object);
?>
Literal Examples¶
Calling prev() on an object is deprecated
Calling next() on an object is deprecated
Calling reset() on an object is deprecated
Calling current() on an object is deprecated
Solutions¶
Cast the object to an array, and store it in a variable before using the mentioned functions.
Changed Behavior¶
This error may appear following an evolution in behavior, in previous versions. See passingObjectIsDeprecated.
Changed Behavior¶
This error may appear following an evolution in behavior, in previous versions. See passingObjectIsDeprecated.