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
Switch to threaded view of this topic Create a new topic Submit Reply
Re: get_object_vars ($this) and member visibility [message #169391] Thu, 09 September 2010 07:34 Go to next message
Helmut Chang is currently offline  Helmut Chang
Messages: 22
Registered: September 2010
Karma: 0
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 ---
Re: get_object_vars ($this) and member visibility [message #169398 is a reply to message #169391] Thu, 09 September 2010 13:06 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
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
==================
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Tue Nov 26 01:11:34 GMT 2024

Total time taken to generate the page: 0.02115 seconds