I'm not against wrapping an array. My concern with the current approach is that it exposes all lot of not needed methods that replacements will have to implement. Simply implementing iterator would be better then deriving from arrayobject. At least when the actual class is being passed around rather then an interface such as iterator.

Sent from my HTC one X.

On 8 Aug, 2013 4:04 PM, "James HK" <jamesin.hongkong.1@gmail.com> wrote:
Hi,

ArrayAccessor is used in several classes[1] to conveniently access an
array through object methods. Of course one could make use of the
ArrayObject directly but one would need to implement the expectation
handling individually for when an expected element is not accessible.

Accessing an array "blindly" by the means of checking things manually
like if ( isset( array[$key]) && ... ) {} where ArrayAccessor or
ArrayObject allows to focus on the task of accessing a value
$this->has( $key ), $this->get( $key ) instead of checking its
validity and later try to gain access.

I'm not a fan of having something like array( 'beAKey' => 'beAValue' )
being transferred beyond an object that invokes the array. An array
that communicates to the outside of its own instantiation should be
encapsulate in an object that carries the array.

>> And when one does not need it, it is better to not have it, and stick with the simplest implementation possible.

If we don't want to use ArrayObject, I might have to create a similar
object handler, as I said before doing array( 'key' => 'value' ) by
"hand" creates all sorts of problems which starts with the validation,
raising exception, and retrieving of its value.

>> The get method of this class is throwing an InvalidArgumentException
Fair enough.

[1] Settings, MockObjectBuilder, Collector, ApiRequestParameterFormatter

Cheers

On 8/8/13, Jeroen De Dauw <jeroendedauw@gmail.com> wrote:
> Hey,
>
> I'm not sure what the use for the newly introduced ArrayAccessor class is.
> It seems to not be providing a lot of functionality on top of ArrayObject.
> And I found that one rarely actually needs the functionality ArrayObject
> provides. And when one does not need it, it is better to not have it, and
> stick with the simplest implementation possible.
>
> The get method of this class is throwing an InvalidArgumentException when a
> non-existing element is requested. This is wrong, as the provided argument
> is not invalid. An OutOfBoundsException would work.
>
> Cheers
>
> --
> Jeroen De Dauw
> http://www.bn2vs.com
> Don't panic. Don't be evil. ~=[,,_,,]:3
> --
>