FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Re: get_object_vars ($this) and member visibility
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: get_object_vars ($this) and member visibility [message #169391] Thu, 09 September 2010 07:34 Go to previous message
Helmut Chang is currently offline  Helmut Chang
Messages: 22
Registered: September 2010
Karma:
Junior Member
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.

> 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 ---
[Message index]
 
Read Message
Read Message
Previous Topic: display data from mysql db in text box??
Next Topic: Re: Another heredoc question
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 05:50:18 GMT 2024

Total time taken to generate the page: 0.05130 seconds