Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 11:29 PM, Casey <[EMAIL PROTECTED]> wrote: > I don't think constructors return the object: im starting to think this as well. what for example happens when there is not __construct() method ? class Test { private $blah = ''; } here $blah is part of a new instance, before __con

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Casey
On Jan 30, 2008 4:53 PM, Jochem Maas <[EMAIL PROTECTED]> wrote: > Richard Lynch schreef: > > I believe the constructor returns the object created, with no chance > > in userland code of altering that fact, over-riding the return value, > > or any other jiggery-pokery to that effect. > > > > New cau

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jochem Maas
Richard Lynch schreef: I believe the constructor returns the object created, with no chance in userland code of altering that fact, over-riding the return value, or any other jiggery-pokery to that effect. New causes the constructor to be called in the first place, and that's about it. The assi

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Chris
Richard Lynch wrote: On Wed, January 30, 2008 6:19 pm, Chris wrote: I dunno about the OOP instances getting GC'ed, but PHP *definitely* reclaims memory from arrays and strings as they go out of scope, usually. Does anyone else find that funny? :) It definitely does it ... usually ;) Ah well

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Richard Lynch
On Wed, January 30, 2008 6:19 pm, Chris wrote: > >> I dunno about the OOP instances getting GC'ed, but PHP *definitely* >> reclaims memory from arrays and strings as they go out of scope, >> usually. > > Does anyone else find that funny? :) > > It definitely does it ... usually ;) Ah well. It d

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Richard Lynch
I believe the constructor returns the object created, with no chance in userland code of altering that fact, over-riding the return value, or any other jiggery-pokery to that effect. New causes the constructor to be called in the first place, and that's about it. The assignment to a variable is d

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Chris
I dunno about the OOP instances getting GC'ed, but PHP *definitely* reclaims memory from arrays and strings as they go out of scope, usually. Does anyone else find that funny? :) It definitely does it ... usually ;) -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Richard Lynch
On Wed, January 30, 2008 9:53 am, Stut wrote: > The "forcing it out of scope" was the crux of my point. However, if > Jochem is right then it's kinda pointless with the current > implementation of the GC, but may become relevant in the new GC. I dunno about the OOP instances getting GC'ed, but PHP

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
> > Indeed. Now, the place where you sleep... is it guarded? well it is, but.. i probly misunderstood some implication in the directions of my virtual fortress and therefore, probly not as well a i suspect ;) -nathan

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut
Nathan Nobbe wrote: On Jan 30, 2008 11:58 AM, Stut <[EMAIL PROTECTED] > wrote: Ok, I'm going to have to assume you really are as stupid as you seem. If I need to provide an example to demonstrate what I meant I will, but I feel I made it quite clear that my

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut
Jim Lucas wrote: Stut wrote: Nathan Nobbe wrote: On Jan 30, 2008 11:31 AM, Stut <[EMAIL PROTECTED] > wrote: "I would *just* use a static method" *just* *just* *just* *just* *just* *just* *just* *just* *just* No instance. None. Grrr. here is a mod of

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 11:58 AM, Stut <[EMAIL PROTECTED]> wrote: > Ok, I'm going to have to assume you really are as stupid as you seem. If > I need to provide an example to demonstrate what I meant I will, but I > feel I made it quite clear that my comment regarding what *I* would do > did not in any wa

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jim Lucas
Stut wrote: Nathan Nobbe wrote: On Jan 30, 2008 11:31 AM, Stut <[EMAIL PROTECTED] > wrote: "I would *just* use a static method" *just* *just* *just* *just* *just* *just* *just* *just* *just* No instance. None. Grrr. here is a mod of the code you poste

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut
Nathan Nobbe wrote: On Jan 30, 2008 11:31 AM, Stut <[EMAIL PROTECTED] > wrote: "I would *just* use a static method" *just* *just* *just* *just* *just* *just* *just* *just* *just* No instance. None. Grrr. here is a mod of the code you posted w/ a var_du

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 11:31 AM, Stut <[EMAIL PROTECTED]> wrote: > > "I would *just* use a static method" > > *just* *just* *just* *just* *just* *just* *just* *just* *just* > > No instance. None. Grrr. here is a mod of the code you posted w/ a var_dump() of the local variable $o; _doSomething(); }

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut
Jim Lucas wrote: Stut wrote: Nathan Nobbe wrote: On Jan 30, 2008 10:53 AM, Stut <[EMAIL PROTECTED] > wrote: Nathan Nobbe wrote: I never said I wasn't creating an instance in the example I posted. then what exactly did you mean by this? Actually no, I m

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut
Nathan Nobbe wrote: On Jan 30, 2008 11:21 AM, Stut <[EMAIL PROTECTED] > wrote: Calling a static method does not create an instance of the class. there you go again; calling a static method does create an instance of the class if you call new inside of it :P

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jim Lucas
Stut wrote: Nathan Nobbe wrote: On Jan 30, 2008 10:53 AM, Stut <[EMAIL PROTECTED] > wrote: Nathan Nobbe wrote: I never said I wasn't creating an instance in the example I posted. then what exactly did you mean by this? Actually no, I mean I would *just*

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 11:21 AM, Stut <[EMAIL PROTECTED]> wrote: > Calling a static method > does not create an instance of the class. there you go again; calling a static method does create an instance of the class if you call new inside of it :P -nathan

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jim Lucas
Stut wrote: Nathan Nobbe wrote: On Jan 30, 2008 10:53 AM, Stut <[EMAIL PROTECTED] > wrote: Nathan Nobbe wrote: I never said I wasn't creating an instance in the example I posted. then what exactly did you mean by this? Actually no, I mean I would *just*

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut
Nathan Nobbe wrote: On Jan 30, 2008 10:53 AM, Stut <[EMAIL PROTECTED] > wrote: Nathan Nobbe wrote: I never said I wasn't creating an instance in the example I posted. then what exactly did you mean by this? Actually no, I mean I would *just* use a static

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 10:53 AM, Stut <[EMAIL PROTECTED]> wrote: > Nathan Nobbe wrote: > I never said I wasn't creating > an instance in the example I posted. > then what exactly did you mean by this? Actually no, I mean I would *just* use a static method. If there is no reason to instantiate an object

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut
Nathan Nobbe wrote: On Jan 30, 2008 10:46 AM, Stut <[EMAIL PROTECTED] > wrote: Nathan Nobbe wrote: Actually no, I mean I would *just* use a static method. If there is no reason to instantiate an object, why would you? you realize you a

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 10:46 AM, Stut <[EMAIL PROTECTED]> wrote: > Nathan Nobbe wrote: > > Actually no, I mean I would *just* use a static method. If there is no > reason to instantiate an object, why would you? you realize you are instantiating an class in the code you posted, right

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut
Nathan Nobbe wrote: It's fairly likely that I'd actually just use a static method here, both your and my code use static methods. it sounds to me like you are using the term 'static method' to mean a static method that has a variable with a reference to an instance of the class that it is

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Nathan Nobbe
On Jan 30, 2008 5:56 AM, Stut <[EMAIL PROTECTED]> wrote: > Nathan Nobbe wrote: > You posted a singleton pattern. no, what i posted was a simple factory pattern. if you invoke it twice there will be 2 instances of Test in memory, eg. not singleton. $a = Test::getInstance(); $b = Test::getInstance

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jochem Maas
Anup Shukla schreef: Nathan Nobbe wrote: Actually, I don't think so. I believe constructors return void, while the 'new' keyword returns a copy of the object. im pretty sure constructors return an object instance: php > class Test { function __construct() {} } php > var_dump(new Test()); obje

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Anup Shukla
Nathan Nobbe wrote: Actually, I don't think so. I believe constructors return void, while the 'new' keyword returns a copy of the object. im pretty sure constructors return an object instance: php > class Test { function __construct() {} } php > var_dump(new Test()); object(Test)#1 (0) { }

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jochem Maas
Stut schreef: Jochem Maas wrote: Stut schreef: Nathan Nobbe wrote: On Jan 29, 2008 7:27 PM, Stut <[EMAIL PROTECTED]> wrote: Personally I'd use a static method in this instance. thats what i recommended. If you need to create an instance of the class you can do so in the static method and

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut
Jochem Maas wrote: Stut schreef: Nathan Nobbe wrote: On Jan 29, 2008 7:27 PM, Stut <[EMAIL PROTECTED]> wrote: Personally I'd use a static method in this instance. thats what i recommended. If you need to create an instance of the class you can do so in the static method and that way it wi

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Jochem Maas
Stut schreef: Nathan Nobbe wrote: On Jan 29, 2008 7:27 PM, Stut <[EMAIL PROTECTED]> wrote: Personally I'd use a static method in this instance. thats what i recommended. If you need to create an instance of the class you can do so in the static method and that way it will get destroyed whe

Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Stut
Nathan Nobbe wrote: On Jan 29, 2008 7:27 PM, Stut <[EMAIL PROTECTED]> wrote: Personally I'd use a static method in this instance. thats what i recommended. If you need to create an instance of the class you can do so in the static method and that way it will get destroyed when the function i

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Nathan Nobbe
On Jan 29, 2008 7:27 PM, Stut <[EMAIL PROTECTED]> wrote: > Personally I'd use a static method in this instance. thats what i recommended. If you need to create > an instance of the class you can do so in the static method and that way it > will get destroyed when the function is done. Otherwise t

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Stut
On 29 Jan 2008, at 20:08, "Nathan Nobbe" <[EMAIL PROTECTED]> wrote: On Jan 29, 2008 3:02 PM, Stut <[EMAIL PROTECTED]> wrote: Why? What exactly do you think you're saving by not putting the instance in a variable? I can't think of one good reason to do this. its an esthetic thing; and besides th

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Nathan Nobbe
On Jan 29, 2008 3:26 PM, Jochem Maas <[EMAIL PROTECTED]> wrote: > Nathan Nobbe schreef: > > On Jan 29, 2008 3:02 PM, Stut <[EMAIL PROTECTED]> wrote: > > > >> Why? What exactly do you think you're saving by not putting the > >> instance in a variable? I can't think of one good reason to do this. >

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Jochem Maas
Nathan Nobbe schreef: On Jan 29, 2008 3:02 PM, Stut <[EMAIL PROTECTED]> wrote: Why? What exactly do you think you're saving by not putting the instance in a variable? I can't think of one good reason to do this. its an esthetic thing; and besides the simple factory method is an easy workarou

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Nathan Nobbe
On Jan 29, 2008 3:02 PM, Stut <[EMAIL PROTECTED]> wrote: > Why? What exactly do you think you're saving by not putting the > instance in a variable? I can't think of one good reason to do this. > its an esthetic thing; and besides the simple factory method is an easy workaround to achieve it. as

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Stut
On 29 Jan 2008, at 19:43, Christoph Boget <[EMAIL PROTECTED]> wrote: On Jan 29, 2008 2:37 PM, Paul Scott <[EMAIL PROTECTED]> wrote: Looks like a repurpose of one of my posts: http://fsiu.uwc.ac.za/index.php?module=blog&action=viewsingle&postid=gen9Srv59Nme5_7092_1182404204 actually, this is

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Jochem Maas
Christoph Boget schreef: Constructors return the object, correct? If so, how can I do this: class Bob { private $blah; _construct( $blah ) { $this->blah = $blah; } public getBlah() { return $this->blah; } } echo Bob( 'Hello!' )->getBlah(); When I try that, I get the message

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Christoph Boget
> On Jan 29, 2008 2:37 PM, Paul Scott <[EMAIL PROTECTED]> wrote: > > Looks like a repurpose of one of my posts: > > http://fsiu.uwc.ac.za/index.php?module=blog&action=viewsingle&postid=gen9Srv59Nme5_7092_1182404204 > actually, this is slightly different; here we are talking about being > able to im

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Nathan Nobbe
On Jan 29, 2008 2:37 PM, Paul Scott <[EMAIL PROTECTED]> wrote: > Looks like a repurpose of one of my posts: > > > http://fsiu.uwc.ac.za/index.php?module=blog&action=viewsingle&postid=gen9Srv59Nme5_7092_1182404204 actually, this is slightly different; here we are talking about being able to immed

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Nathan Nobbe
On Jan 29, 2008 2:27 PM, Andrew Ballard <[EMAIL PROTECTED]> wrote: > On Jan 29, 2008 1:53 PM, Christoph Boget <[EMAIL PROTECTED]> > wrote: > > Constructors return the object, correct? > > Actually, I don't think so. I believe constructors return void, while > the 'new' keyword returns a copy of th

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Paul Scott
On Tue, 2008-01-29 at 14:17 -0500, Eric Butera wrote: > http://www.travisswicegood.com/index.php/2007/10/26/fluent_api_here_i_come > Looks like a repurpose of one of my posts: http://fsiu.uwc.ac.za/index.php?module=blog&action=viewsingle&postid=gen9Srv59Nme5_7092_1182404204 --Paul All Email

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Andrew Ballard
On Jan 29, 2008 1:53 PM, Christoph Boget <[EMAIL PROTECTED]> wrote: > Constructors return the object, correct? Actually, I don't think so. I believe constructors return void, while the 'new' keyword returns a copy of the object. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubs

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Eric Butera
On Jan 29, 2008 1:53 PM, Christoph Boget <[EMAIL PROTECTED]> wrote: > Constructors return the object, correct? If so, how can I do this: > > class Bob { > private $blah; > _construct( $blah ) { > $this->blah = $blah; > } > public getBlah() { > return $this->blah; > } > } > > echo

Re: [PHP] How can I do this -- method chaining

2008-01-29 Thread Richard Heyes
Christoph Boget wrote: Constructors return the object, correct? If so, how can I do this: class Bob { private $blah; _construct( $blah ) { $this->blah = $blah; } public getBlah() { return $this->blah; } } echo Bob( 'Hello!' )->getBlah(); When I try that, I get the message "U

[PHP] How can I do this -- method chaining

2008-01-29 Thread Christoph Boget
Constructors return the object, correct? If so, how can I do this: class Bob { private $blah; _construct( $blah ) { $this->blah = $blah; } public getBlah() { return $this->blah; } } echo Bob( 'Hello!' )->getBlah(); When I try that, I get the message "Undefined function Bob".