|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #30310 Can't overload static methods with __call()
Submitted: 2004-10-02 19:47 UTC Modified: 2004-10-03 00:42 UTC
Avg. Score:4.8 ± 0.5
Reproduced:20 of 20 (100.0%)
Same Version:19 (95.0%)
Same OS:16 (80.0%)
From: jaba at inbox dot lv Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.* OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-10-02 19:47 UTC] jaba at inbox dot lv
I am trying to write a class which can be used statically e.g. Db::connect(); Db::query() etc. I also have a __call() method to be executed in case of calling an inexistent static method. But this does not work: PHP says that the method is undefined.

Reproduce code:
	class Db {
		function __call($method,$args) {
			echo 'Method: '.$method.'<br />';
	# this works fine
	$Db = new Db();
	# this makes a PHP error

Expected result:
Method: test

Method: test

Actual result:
Fatal error: Call to undefined method Db::test() in ...


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Fri Sep 21 02:01:26 2018 UTC