我希望能够在父类中声明一个具有未知数量参数的抽象函数:
abstract function doStuff(...);
然后使用一组提示参数定义一个实现:
/**
* @param int $userID
* @param int $serviceproviderID
*/
static function doStuff($userID, $serviceproviderID) {}
到目前为止,我得到的最佳方法是,
abstract function doStuff();
/**
* @param int $userID
* @param int $serviceproviderID
*/
static function doStuff() {
$args = func_get_args();
...
}
但每次调用函数时,由于提示,我都会收到一堆“缺少参数”的警告。有没有更好的办法?
编辑:问题是错的,请不要浪费你的时间回答。以下是我正在寻找的东西,似乎没有任何警告。
abstract class Parent {
abstract function doStuff();
}
/**
* @param type $arg1
* @param type $arg2
*/
class Child extends Parent {
function doStuff($arg1, $arg2) {
...
}
}