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

From: Date: Wed, 10 May 2006 13:51:29 +0000
Subject: Re: tired of referencing static variables/constants with 'self ::'
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-235878@lists.php.net to get a copy of this message
On 5/9/06, D. Dante Lorenso <dante@vocalspace.com> 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 is interesting Dante, you have me thinking... Perhaps this is all a result of PHP being a procedural language first, and an OOP language second? Indeed, even if our PHP applications are fully abstracted into objects, they still begin their lives in a procedural way... [thinking_aloud] I have little experience with pure OOP, short of a quick dive into Java, but I do recall that any J2EE web application that runs does so as an instance of a class (which is a child of some base "listener" class that handles web requests). So your initial "scope" sort of is at a "local object" level. So then it would make perfect sense as a programmer to want the ability to call an object constant or static property without having to say "hey, look for xxxx in the same place that I am right now". Because there's nowhere else you'd be, anyway. But with PHP, every script starts out procedurally, and hence at the "global" level. Then we instantiate a class, step into that object, and do our thing. But still, we _started_ outside, and our scope "ladder" does too. [/thinking_aloud] Yes? No? Maybe so? -John W

« previous php.general (#235878) next »