|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-06-22 10:04 UTC] andre-desch at t-online dot de
Description:
------------
If You define both the magic function for static and dynamic calls for a class and
then call a static function from a derivate's method, not the static but the
dynamic magic function is called.
Test script:
---------------
<?php
class MyBaseClass {
public static function __callStatic($what, $args)
{
return 'static call';
}
public function __call($what, $args)
{
return 'dynamic call';
}
}
class MyDerivedClass extends MyBaseClass {
function someAction()
{
//here I call a base class' static function
//it returns "dynamic call" instead of "static call"
return MyBaseClass::Foo();
}
}
$bar = new MyDerivedClass();
echo $bar->someAction();
?>
Expected result:
----------------
static call
Actual result:
--------------
dynamic call
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 20:00:01 2025 UTC |
It is a static call if You use an empty proxy class like below. The only difference in scope is, that MyProxyClass is not directly in the hierachy tree above the calling method's class. Please explain why this is intended. class MyProxyClass extends MyBaseClass { //empty } class MyDerivedClass extends MyBaseClass { function someAction() { return MyProxyClass::Foo(); } }