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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jaba at inbox dot lv
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 20:01:28 2024 UTC