php.net |  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
Votes:21
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
Description:
------------
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:
---------------
<?php
	class Db {
		
		...
		
		function __call($method,$args) {
			echo 'Method: '.$method.'<br />';
			var_dump($args);
		}
		
		...
	}
	
	# this works fine
	$Db = new Db();
	$Db->test();
	
	# this makes a PHP error
	Db::test();
?>

Expected result:
----------------
Method: test
Array()

Method: test
Array()



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

Patches

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