Re: get_object_vars ($this) and member visibility [message #169398 is a reply to message #169391] |
Thu, 09 September 2010 13:06 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 9/9/2010 3:34 AM, Helmut Chang wrote:
> Jerry Stuckle schrieb:
>
>>> I want to use collection objects, where I have methods but where I also
>>> can iterate over the elements in the collection and where I can access
>>> elements in the collection in an array-/[]-style. And where I can
>>> restrict the type of elements that are allowed in the collection.
>>>
>>
>> Which is completely different than mapping the properties to array
>> elements.
>
> Yes, it is. I wrote this also in my previous post :). I wrote "too
> simplified", because I wanted to show cases, where it might be useful to
> have an object, that behaves like an array. Your posting, I replied to,
> suggests IMHO, you think the whole ArrayAccess, Iterator, etc. intefaces
> are useless.
>
I said nothing of the kind. I was specifically addressing Gordon's
topic. If you want to discuss another topic, please start a new thread.
>> But unfortunately, PHP doesn't support either restricting the type in
>> the collection or overloading operators.
>
> I'm just trying to implement collection classes that restrict the type
> of their elements. It's not 100% perfect, as PHP itself gives you the
> retrictions, but:
>
> Because of this thread, I tested the ArrayAccess interface once again
> with PHP 5.3 and finally it "works as expected". Which means, if you
> implement it and pass an object in the offsetSet() method, it is a
> reference now. IIRC, until 5.3, it was a copy, which made this interface
> pretty useless.
>
> And the offsetSet() method of the interface gives you also the
> possibility to throw an exception, if the provided value is not of the
> correct type. But yes: unfortunately you cannot define this in the
> methods signature.
>
> Helmut
>
>
>
> --- news://freenews.netfront.net/ - complaints: news(at)netfront(dot)net ---
Which again is a completely different subject and has no relation to
Gordon's question.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|