Edit report at https://bugs.php.net/bug.php?id=51176&edit=1
ID: 51176
Comment by: steve at twitpic dot com
Reported by: majkl578 at gmail dot com
Summary: Static calling in non-static method behaves like
$this->
Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: Irrelevant
PHP Version: 5.3.2RC3
Assigned To: felipe
Block user comment: N
Private report: N
New Comment:
This is ridiculous- this bug is not bogus, it's completely legitimate,
unexpected
behavior, and totally non documented. As a reasonable programmer, one expects a
static call to behave the same inside of a class as well as outside of a class.
How can we bring the "desired" behavior up for vote? I think that it's insane
to
not fix it.
Previous Comments:
------------------------------------------------------------------------
[2011-05-31 02:06:16] david71rj at gmail dot com
Sorry by realive this topic, but I really think that it is a bug.
If I want call "bar" with context, the correct mean is $this->bar(). Else, the
"static" sounds for me like "call without context". I'm wrong?
Please, read this topic to understand what I'm saying:
http://stackoverflow.com/questions/6181603/php-is-handling-incorrectly-my-static-
call
------------------------------------------------------------------------
[2010-11-03 12:03:17] majkl578 at gmail dot com
You cannot call foo::start(), because the method is non-static and therefore it
does not make sense.
Also, self, static and class name are used to call methods statically, not in a
object context.
For calling method bar in object context, I think '$this->' should be used
instead.
Obviously parent should not behave this way and respect context, but I think it
should be the only exception (as shown in #52713).
------------------------------------------------------------------------
[2010-11-03 02:45:23] [email protected]
Hello, I've reverted the wrong changes introduced by trying to fix the issue
reported, but actually there is no bug at all. self::bar(), static::bar() and
foo::bar() are being called in an object context, hence the __call() is called.
I.e.
$foo->start(); // invoke the __call method
foo::start(); // invoke the __callStatic method
Thanks.
------------------------------------------------------------------------
[2010-11-03 02:35:28] [email protected]
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=305043
Log: - Reverted fix for bug #51176
------------------------------------------------------------------------
[2010-03-04 14:27:55] [email protected]
Hello!
This isn't my decision, but the release manager.
Thanks.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=51176
--
Edit this bug report at https://bugs.php.net/bug.php?id=51176&edit=1