PHP array functions for the ArrayObject

Greetings to all members of the forum,

arrays are an important part of the PHP language and there are a lot of useful (some more, some less) functions to use them with. The ArrayObject is a good step to bringing the array type closer to object oriented programming, but besides sorting almost none of the many array functions are supported by ArrayObject.

Therefore (and because I wanted to try TDD) I have extended the native ArrayObject to support most of the array functions in what I hope is a sensible manner.

The project can be found on GitHub and Packagist (if you want to include it in your own project).

And maybe, some day, it will make it into the PHP core …



This is a good idea, it would be nice if PHP Natively supported all the functions in the ArrayObject class. What would also be useful is if you could declare that $foo = [1,2]; created an ArrayObject instance rather than a scalar array but I don’t think that’s going to happen :frowning:

It would already be a great help if arrays worked with the ArrayAccess type hint.

1 Like