Re: [PHP] tired of referencing static variables/constants with 'self ::'

2006-05-10 Thread John Wells
On 5/9/06, D. Dante Lorenso <[EMAIL PROTECTED]> wrote: As an OOP programmer, I would expect the scope search to be as follows: 1. LOCAL: current method 2. THIS: current instance ($this) 3. SELF: current class & parent classes, in order of inheritance 4. GLOBAL: globals Ok, so this

Re: [PHP] tired of referencing static variables/constants with 'self ::'

2006-05-10 Thread Jochem Maas
D. Dante Lorenso wrote: ... I mean, I was forced to write 'self ::' like 11 times in that constructor. THAT is annoying. would it help to consider that the annoyance is a matter of subjection rather than fact? ;-) I realize I am probably just venting since it's unlikely I can get anything

Re: [PHP] tired of referencing static variables/constants with 'self ::'

2006-05-09 Thread D. Dante Lorenso
Richard Lynch wrote: On Tue, May 9, 2006 12:42 pm, D. Dante Lorenso wrote:#1. You might do: define('MY_CONSTANT', true); class A { const MY_CONSTANT = MY_CONSTANT; } Then you can sort of have the best of both worlds... Though in a hack sort of way. :-^ Hehe, nice. No thanks ;-) Keep yer s

Re: [PHP] tired of referencing static variables/constants with 'self ::'

2006-05-09 Thread D. Dante Lorenso
Richard Lynch wrote: On Tue, May 9, 2006 4:48 pm, D. Dante Lorenso wrote: If the search for my constant follows the search I've listed above, self would never be necessary unless you wanted to pinpoint "3" directly. Under this same line of thinking, though, '$this->' really shouldn't be be ne

Re: [PHP] tired of referencing static variables/constants with 'self ::'

2006-05-09 Thread D. Dante Lorenso
Jochem Maas wrote: D. Dante Lorenso wrote: $x = ($y == self :: MY_CONSTANT || $y == self :: MY_CONSTANT2); I hate the spaces around the '::' whynot self::MY_CONSTANT? Stupid PHP Eclipse code beautifier ;-) It's what I use to beautify and since it always does that, I've been forced to accept

Re: [PHP] tired of referencing static variables/constants with 'self ::'

2006-05-09 Thread Richard Lynch
On Tue, May 9, 2006 4:48 pm, D. Dante Lorenso wrote: > If > the search for my constant follows the search I've listed above, self > would never be necessary unless you wanted to pinpoint "3" directly. > Under this same line of thinking, though, '$this->' really shouldn't > be > be necessary either

Re: [PHP] tired of referencing static variables/constants with 'self ::'

2006-05-09 Thread Richard Lynch
On Tue, May 9, 2006 12:42 pm, D. Dante Lorenso wrote: > Does anyone know if it's possible to reference class constants or > static > variables without having to use 'self::' all the time? > > class A { > const MY_CONSTANT = true; > > public function test() { >echo self :: MY_CONSTAN

Re: [PHP] tired of referencing static variables/constants with 'self ::'

2006-05-09 Thread Jochem Maas
D. Dante Lorenso wrote: John Wells wrote: On 5/9/06, D. Dante Lorenso <[EMAIL PROTECTED]> wrote: Does anyone know if it's possible to reference class constants or static variables without having to use 'self::' all the time? No, ... Why? The reason is SCOPE. implicit scope sucks - it mea

Re: [PHP] tired of referencing static variables/constants with 'self ::'

2006-05-09 Thread D. Dante Lorenso
D. Dante Lorenso wrote: As an OOP programmer, I would expect the scope search to be as follows: 1. LOCAL: current method 2. THIS: current instance ($this) 3. SELF: current class & parent classes, in order of inheritance 4. GLOBAL: globals Actually, 2 and 3 are really the same but only v

Re: [PHP] tired of referencing static variables/constants with 'self ::'

2006-05-09 Thread D. Dante Lorenso
John Wells wrote: On 5/9/06, D. Dante Lorenso <[EMAIL PROTECTED]> wrote: Does anyone know if it's possible to reference class constants or static variables without having to use 'self::' all the time? No, ... Why? The reason is SCOPE. As wonderful as PHP is, it can't read your mind. So if you'

Re: [PHP] tired of referencing static variables/constants with 'self ::'

2006-05-09 Thread John Wells
On 5/9/06, D. Dante Lorenso <[EMAIL PROTECTED]> wrote: Does anyone know if it's possible to reference class constants or static variables without having to use 'self::' all the time? No, and the answer is actually in your example. Copy-and-paste all of your example code into one file, and just

[PHP] tired of referencing static variables/constants with 'self ::'

2006-05-09 Thread D. Dante Lorenso
Does anyone know if it's possible to reference class constants or static variables without having to use 'self::' all the time? class A { const MY_CONSTANT = true; public function test() { echo self :: MY_CONSTANT; // works echo MY_CONSTANT; // doesn't work } } I don't thi