Bug #65466 [NEW]: forward_static_call doesn't trigger __callStatic for non-existing methods

From: Date: Sat, 17 Aug 2013 14:13:13 +0000
Subject: Bug #65466 [NEW]: forward_static_call doesn't trigger __callStatic for non-existing methods
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-180949@lists.php.net to get a copy of this message
From:             daniel dot ruthardt at zoesolutions dot eu
Operating system: Linux
PHP version:      5.4.18
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:forward_static_call doesn't trigger __callStatic for non-existing methods

Description:
------------
---
From manual page: http://www.php.net/function.forward-static-call
---

The manual page makes you think that this function can be used to force a
static method 
call, it however doesn't. Essentially, this functions just does the same
thing as does 
the :: operator, which heavily depends on the current context - as
unfortunately does 
forward_static_call.

One might expect, that using a function which says in its name and
description, that it 
will call static methods, that calling non-existing static methods will end
up in 
__callStatic and not in __call.

Test script:
---------------
<?php

class A {

	public function __call($name, $arguments) {
		echo("i don't want to be in here :-(");
	}

	public static function __callStatic($name, $arguments) {
		echo('i want to be in here, but how?');
	}

	public function instanceMethod() {
		// objective: call a non-existing static method,
		// so that eventually __callStatic is called and
		// can take care of things
		forward_static_call(['A', 'test']);
	}

}

(new A())->instanceMethod();

?>

Expected result:
----------------
i want to be in here, but how?

Actual result:
--------------
i don't want to be in here :-(

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



Thread (2 messages)

« previous php.bugs (#180949) next »