note 80310 deleted from language.oop5.overloading by cmb
| From: | cmb@php.net | Date: | Sun, 18 Aug 2019 08:28:14 +0000 |
| Subject: | note 80310 deleted from language.oop5.overloading by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211903@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
It should be noted that __call will trigger only for method calls on an instantiated object, and
cannot be used to 'overload' static methods. For example:
<?php
class TestClass {
function __call($method, $args) {
echo "Method {$method} called with args: " . print_r($args, TRUE);
}
}
// this will succeed
$obj = new TestClass();
$obj->method_doesnt_exist();
// this will not
TestClass::method_doesnt_exist();
?>
It would be useful if the PHP devs would include this in a future release, but in the meantime, just
be aware of that pitfall.