If your class structure allows, you can split the class into several different classes that are part of the inheritance chain:
class foo1 {
public static function a() {}
}
class foo extends foo1 {
public static function b() {}
}
__ callStatic(), . ( PHP 5.3, , __call 5.0.) Smarty 3 IIRC.
class foo {
private static $parts = array('A', 'B');
public static __callStatic($name, $arguments) {
foreach (self::$parts as $part) {
if (method_exists($part, $name)) {
return call_user_func_array(array($part, $name), $arguments);
}
}
throw new Exception();
}
}
class A {
public static function a() {}
}
class B {
public static function b() {}
}
PHP 5.4 , :
class foo {
use A, B;
}
trait A {
public static function a() {}
}
trait B {
public static function b() {}
}