The ArrayObject class is only rarely used at the moment due to a lack
for almost all array_* functions beside the sort functions.

Currently implemented by ArrayObject:
https://www.php.net/manual/en/class.arrayobject.php

Missing methods that would be most useful:
array_​chunk
array_​column
array_​diff_​assoc
array_​diff_​key
array_​diff_​uassoc
array_​diff_​ukey
array_​diff
array_​filter
array_​flip
array_​intersect_​assoc
array_​intersect_​key
array_​intersect_​uassoc
array_​intersect_​ukey
array_​intersect
array_​key_​first
array_​key_​last
array_​keys
array_​map
array_​merge
array_​pop
array_​push
array_​rand
array_​reduce
array_​replace_​recursive
array_​replace
array_​reverse
array_​search
array_​shift
array_​slice
array_​splice
array_​unique
array_​unshift
array_​values
shuffle


Furthermore, the already existing sort functions return VOID, which
isn't best for an object. Instead, returning the ArrayObject itself to
support a fluid interface would be much better, i.e.:

$ao = new \ArrayObject([null, 'a' => 2, 'b' => 1]);
$ao->filter()->sort()->flip();

This change wouldn't break any existing code already using the ArrayObject.


It should be possible to extend from ArrayObject too and have access to
the internal array. Therefore, a new method would be required:

protected getArrayRef() : array

The method is similar to the existing getArrayCopy() method but returns
a reference to the internal array instead of a copy. Thus, classes
extending ArrayObject will be able to implement additional methods
efficiently without the need to create copies of the internal array first.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to