#51176 [NEW]: Static calling in non-static method behaves like $this->

From: Date: Mon, 01 Mar 2010 16:53:03 +0000
Subject: #51176 [NEW]: Static calling in non-static method behaves like $this->
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-148137@lists.php.net to get a copy of this message
From:             majkl578 at gmail dot com
Operating system: Irrelevant
PHP version:      5.3.2RC3
PHP Bug Type:     Scripting Engine problem
Bug description:  Static calling in non-static method behaves like $this->

Description:
------------
When calling non-existing static method from non-static method, __call()
is called instead of __callStatic().
self/static/className behaves incorrectly - like $this-> in that context.

Verified on 5.3.2RC3, 5.3.1 and 5.3.0.

Reproduce code:
---------------
class Foo
{
	public function start()
	{
		self::bar();
		static::bar();
		Foo::bar();
	}
	
	public function __call($n, $a)
	{
		echo 'instance';
	}
	
	public static function __callStatic($n, $a)
	{
		echo 'static';
	}
}

$foo = new Foo();
$foo->start();

Expected result:
----------------
static
static
static

Actual result:
--------------
instance
instance
instance

-- 
Edit bug report at http://bugs.php.net/?id=51176&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51176&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51176&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51176&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51176&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51176&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51176&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51176&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51176&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51176&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51176&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51176&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51176&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51176&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51176&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51176&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51176&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51176&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51176&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51176&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51176&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51176&r=mysqlcfg



Thread (12 messages)

« previous php.bugs (#148137) next »