Thanks for your answer guys, they answered my questions. Hopefully any introduction in the language of a __getStatic() and __setStatic() won't make things even more confusing.
Thanks also for the effort you put in developing PHP, I really appreciate it.
Cheers,
I. Stan
----- Original Message ----
From: Gregory Beaver greg@chiaraquartet.net
To: Ionut Gabriel Stan ionut.stan@yahoo.com
Cc: internals@lists.php.net
Sent: Wednesday, September 17, 2008 7:25:31 AM
Subject: [PHP-DEV] Re: Namespaced function vs static method in global class
Ionut Gabriel Stan wrote:
<snip><snip>echo Test::foo(); // outputs namespace function
echo '<br>';
echo ::Test::foo(); // outputs namespace function
My questions are:
- How should I call the static method foo in the global class Test (except for call_user_func)
- How should I call the static method baz of class Bar in namespace Test with call_user_func
- Is there no possibility to change your minds and replace the double colon with something else, likes a simple colon? I find it very confusing to figure out what is what and the way I should call it.
Hi Ionut,
Stas did a good job of answering how to call the static method using
call_user_func. The answer to #1 under the current implementation is
"you can't" which is why I posted a patch to allow differentiating
between the two earlier this week.
However, I have since discovered a much better solution, and have a
working patch, but am checking details offlist before I propose it, as
it involves a slight but important change to namespace syntax. Stay
tuned for further details. As for your 3rd question, I guarantee this
will not happen, as it is technically impossible to do. For instance:
switch ($something) {
case oops:
is:this:part:of:oops();
break;
}
The above code could resolve to either "case oops:" followed by
"is:this:part:of:oops()" or as "case oops:is:this:part:of:oops()" and
there is no way for a computer to tell the difference without
introducing required whitespace. Since PHP != Python, that won't happen :).
Greg