Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-29 Thread justin
On Tue, Jan 29, 2013 at 9:18 AM, David Mintz wrote: > On Tue, Jan 29, 2013 at 9:43 AM, Anthony Ferrara wrote: > >> The constructor's return value is always ignored internally. So the only >> time the constructor's return is ever used is in a child-class. >> >> if (parent::__construct()) { >>

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-29 Thread David Mintz
On Tue, Jan 29, 2013 at 9:43 AM, Anthony Ferrara wrote: > The constructor's return value is always ignored internally. So the only > time the constructor's return is ever used is in a child-class. > > if (parent::__construct()) { > // blah > } > > You lost me there. If it's always ignored... a

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-29 Thread Anthony Ferrara
The constructor's return value is always ignored internally. So the only time the constructor's return is ever used is in a child-class. if (parent::__construct()) { // blah } But I'd argue that if you need to do that, inheritance isn't what you need, but another form of composition... Antho

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-29 Thread David Mintz
This might be little more than a matter of style, but I would add that I don't think Person's __construct() should return a boolean. By definition it returns an instance of the Person class, so you need not explicitly return anything. -- David Mintz http://davidmintz.org/ Fight for social equal

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-26 Thread CED
And I would say more secure. :) On 1/25/2013 6:18 PM, Jeff Slutz wrote: > Yes, as Brian said, go with protected. If you need to change the > value of the attribute from outside of the class then provide a public > setter method to set a new value. This approach makes the control of > the objects

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-25 Thread Jeff Slutz
Yes, as Brian said, go with protected. If you need to change the value of the attribute from outside of the class then provide a public setter method to set a new value. This approach makes the control of the objects a lot easier to manage. Best, Jeff -- Jeff Slutz JSLEUTH LLC 3242 44th ST APT

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-25 Thread Brian O'Connor
You can also use 'protected' to only allow sub-classes to access the variable. On Fri, Jan 25, 2013 at 7:52 PM, Leam Hall wrote: > And that would be to make the variables public. > > > On 01/25/2013 07:34 PM, Leam Hall wrote: > >> Will do. Right now I'm trying to figure out how to override a va

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-25 Thread Leam Hall
And that would be to make the variables public. On 01/25/2013 07:34 PM, Leam Hall wrote: Will do. Right now I'm trying to figure out how to override a variable set in the parent class. ___ New York PHP User Group Community Talk Mailing List http://li

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-25 Thread Leam Hall
Will do. Right now I'm trying to figure out how to override a variable set in the parent class. On 01/25/2013 07:06 PM, Darryle Steplight wrote: Take a look at PHP traits, its a PHP 5.4 feature and PHP's solution to multi-inheritance. On Fri, Jan 25, 2013 at 6:57 PM, Leam Hall wrote: Err...u

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-25 Thread Darryle Steplight
Take a look at PHP traits, its a PHP 5.4 feature and PHP's solution to multi-inheritance. On Fri, Jan 25, 2013 at 6:57 PM, Leam Hall wrote: > Err...until I remember to put parent::__construct() in B. :) > > Leam > > > On 01/25/2013 06:51 PM, Leam Hall wrote: >> >> Interesting. The parent isn't

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-25 Thread Leam Hall
Err...until I remember to put parent::__construct() in B. :) Leam On 01/25/2013 06:51 PM, Leam Hall wrote: Interesting. The parent isn't multi-generational, far as I can see. That is, if C extends B which extends A, parent::__construct() in C does not have access to stuff constructed in A. I

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-25 Thread Leam Hall
Interesting. The parent isn't multi-generational, far as I can see. That is, if C extends B which extends A, parent::__construct() in C does not have access to stuff constructed in A. I can make it work by making C extend A, but need to google a way to inherit further up the chain. Thanks!

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-25 Thread Joey Derrico
As Jeff said you have to call it explicitly class Trooper extends Person { public function _construct($parms) { parent::_construct(); //Whatever else is here } } Joey Derrico On Fri, Jan 25, 2013 at 5:57 PM, Rob Marscher wrote: > Here's where the info is for that in the php docs: > http://php.n

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-25 Thread Rob Marscher
Here's where the info is for that in the php docs: http://php.net/manual/en/language.oop5.decon.php On Jan 25, 2013, at 5:51 PM, Jeff Slutz wrote: > I think you're looking for parent::__construct(); > > The child's __construct() will replace the parent's. So if you want to run > the parent's

Re: [nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-25 Thread Jeff Slutz
I think you're looking for parent::__construct(); The child's __construct() will replace the parent's. So if you want to run the parent's you have to call it explicitly. JS -- Jeff Slutz JSLEUTH LLC 3242 44th ST APT 3F Astoria, NY 11103 c. 970.443.9390 j...@jeffslutz.com On Fri, Jan 25, 2013

[nyphp-talk] OOP Newbie Building arrays in extended classes

2013-01-25 Thread Leam Hall
Okay, OOP newbie time again. In line 11 I declare an array. Per IRC conversations a day or so ago, line 49 has to go into the __construct function. However, the hope is that line 83 would add to what was done in line 49. It seems not to. I think because the extends doesn't actually call the __