Using an object as a backing array for %s is deprecated, as it allows violating class constraints and invariants

Description

It is not allowed anymore to create an ArrayObject based on an object. This leads to many unexpected behaviors, that are not supported anymore by PHP.

Example

<?php

$object = new stdClass;
$object->a = 1;

new ArrayObject($object);

?>

Literal Examples

  • Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants

Solutions

  • Cast the object to array before using it with ArrayObject.

  • Do not use ArrayObject.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.