Re: Simplest way of enforcing an array of instances of a specific class but treating the whole thing as an array.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24 February 2011 12:43, Richard Quadling <rquadling@xxxxxxxxx> wrote:
> Hi.
>
> Brain being a little slow today.
>
> My objective is to enforce a parameter to a method to be an array of a
> specific class (or null).
>
> The specific class is LatLng.
>
> I want to be able to pass an array of LatLngs to a method.
>
> I know I can hint this as ...
>
> function(array $LatLngs) {...}
>
> and then in the array processing loop, use ...
>
> if ($element instanceof LatLng) {...}
>
> But I have a LOT of different types that can exist in arrays and I
> want to enforce the commonality of the type.
>
>
> I think I need a class of LatLngs and this has to implement an
> Traversable and ArrayAccess interfaces.
>
> But I'm not sure.
>
> Anyone got any clues / reading?
>
> Thanks.
>
> Richard.
>
> --
> Richard Quadling
> Twitter : EE : Zend
> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
>

And it seems that ArrayObject is my start point.

Richard.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux