Re: [PHP] Method chaining off constructors

2008-06-06 Thread Robert Cummings
On Fri, 2008-06-06 at 11:35 -0400, Christoph Boget wrote: > > The 'new' keyword has to apply to the object created in the constructor (and > > not the return value of any of the follow-up calls.) To establish this > > precedence, chaining wasn't allowed on constructors. > > If precedence was th

Re: [PHP] Method chaining off constructors

2008-06-06 Thread Christoph Boget
> The 'new' keyword has to apply to the object created in the constructor (and > not the return value of any of the follow-up calls.) To establish this > precedence, chaining wasn't allowed on constructors. If precedence was the issue, why doesn't this work, either: (new bob())->one()->two()

Re: [PHP] Method chaining off constructors

2008-06-06 Thread Adam Richardson
The 'new' keyword has to apply to the object created in the constructor (and not the return value of any of the follow-up calls.) To establish this precedence, chaining wasn't allowed on constructors. On Fri, Jun 6, 2008 at 11:04 AM, Eric Butera <[EMAIL PROTECTED]> wrote: > On Fri, Jun 6, 2008

Re: [PHP] Method chaining off constructors

2008-06-06 Thread Eric Butera
On Fri, Jun 6, 2008 at 11:00 AM, Christoph Boget <[EMAIL PROTECTED]> wrote: >> > Why? I thought constructors returned the object? >> It's been a while since I've played with objects in PHP, but couldn't >> you just add the line: >> return $this; >> ...to the end of your __construct() function? Sor

RE: [PHP] Method chaining off constructors

2008-06-06 Thread Christoph Boget
> > Why? I thought constructors returned the object? > It's been a while since I've played with objects in PHP, but couldn't > you just add the line: > return $this; > ...to the end of your __construct() function? Sorry if this is obtuse of > me to say, I just thought maybe the answer was that sim

RE: [PHP] Method chaining off constructors

2008-06-06 Thread Boyd, Todd M.
> -Original Message- > From: Christoph Boget [mailto:[EMAIL PROTECTED] > Sent: Friday, June 06, 2008 9:45 AM > To: PHP General > Subject: [PHP] Method chaining off constructors > > Is there a reason why you can't do method chaining off of constructors? > &

[PHP] Method chaining off constructors

2008-06-06 Thread Christoph Boget
Is there a reason why you can't do method chaining off of constructors? Consider the following class: class bob { public function __construct() { echo 'Constructor()'; } public function one() { echo '->one()'; return $this; } public function two

Re: [PHP] method chaining

2002-11-11 Thread Terry McBride
'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, November 11, 2002 1:33 PM Subject: RE: [PHP] method chaining > Apologies for the previous truncated version of this -- dunno what happened there!! > > > -Original Message- > > From: Terry McBride

Re: [PHP] method chaining

2002-11-11 Thread Terry McBride
- Original Message - From: "Ford, Mike [LSS]" <[EMAIL PROTECTED]> To: "'Terry McBride'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, November 11, 2002 1:33 PM Subject: RE: [PHP] method chaining > Apologies for the previous tru

RE: [PHP] method chaining

2002-11-11 Thread Ford, Mike [LSS]
Apologies for the previous truncated version of this -- dunno what happened there!! > -Original Message- > From: Terry McBride [mailto:terry@;boxitllc.com] > Sent: 11 November 2002 15:53 > > I have a question about php and OO. I want to chain methods > together having > them performed o

RE: [PHP] method chaining

2002-11-11 Thread Ford, Mike [LSS]
> -Original Message- > From: Terry McBride [mailto:terry@;boxitllc.com] > Sent: 11 November 2002 15:53 > > I have a question about php and OO. I want to chain methods > together having > them performed on the results of the following method. > Meaning something > like $foo->get("bar")-

Re: [PHP] method chaining

2002-11-11 Thread Terry McBride
--- From: "Ernest E Vogelsinger" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, November 11, 2002 12:02 PM Subject: Re: [PHP] method chaining > At 17:57 11.11.2002, Terry McBride spoke out and said: > [snip] >

Re: [PHP] method chaining

2002-11-11 Thread Terry McBride
me error. Terry - Original Message - From: "Johan Ohlin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, November 11, 2002 11:45 AM Subject: Re: [PHP] method chaining > If I have understood correctly what you want to do then this will do fine... > > $

Re: [PHP] method chaining

2002-11-11 Thread Terry McBride
s a reference in order to grab it properly!? I wish I knew why these decisions went the way the did. Terry - Original Message - From: "Maxim Maletsky" <[EMAIL PROTECTED]> To: "Terry McBride" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monda

Re: [PHP] method chaining

2002-11-11 Thread Johan Ohlin
If I have understood correctly what you want to do then this will do fine... $foo->${$foo->get("bar")}->getBaz(); / Johan - Original Message - From: "Terry McBride" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, November 11, 20

Re: [PHP] method chaining

2002-11-11 Thread Maxim Maletsky
work around: $obj = $foo->get("bar"); $obj->getBaz(); it is a better way as you don't have to re-repeat the function code and re-pass the oblect. -- Maxim Maletsky [EMAIL PROTECTED] "Terry McBride" <[EMAIL PROTECTED]> wrote... : > Hello, > > I have a question about php and OO. I want to ch

Re: [PHP] method chaining

2002-11-11 Thread Ernest E Vogelsinger
At 16:53 11.11.2002, Terry McBride spoke out and said: [snip] >Hello, > >I have a question about php and OO. I want to chain methods together having >them performed on the results of the following method. Meaning something >like $foo->get("bar")->getBaz().

[PHP] method chaining

2002-11-11 Thread Terry McBride
Hello, I have a question about php and OO. I want to chain methods together having them performed on the results of the following method. Meaning something like $foo->get("bar")->getBaz(). I get the following error from the script bellow. Parse error: parse error, unexpected T_OBJECT_OPERATOR,