for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Chadicus\Spl\DataStructures;
/**
* This class behaves the same as ArrayObject disallowing modifications.
*/
final class ImmutableArrayObject extends \ArrayObject
{
* @see \ArrayObject::offsetSet
*
* @throws \LogicException
public function offsetSet($index, $newval)
throw new \LogicException('Attempting to write to an immutable array');
}
* @see \ArrayObject::offsetUnset
public function offsetUnset($index)
* @see \ArrayObject::append
public function append($value)
* @see \ArrayObject::exchangeArray
public function exchangeArray($array)
* Creates a new ImmutableArrayObject from the given mutable ArrayObject instance.
* @param \ArrayObject The mutable array object.
* @return ImmutableArrayObject
public static function createFromMutable(\ArrayObject $arrayObject)
return new static($arrayObject->getArrayCopy(), $arrayObject->getFlags(), $arrayObject->getIteratorClass());