use ReflectionClass;
public function __construct()
{
$reflectClass = new ReflectionClass($this);
//必须重写的方法
$requiredOverwriteMethods = [
'isCurrentLimit',
'genCacheKey',
'really',
];
foreach ($requiredOverwriteMethods as $method) {
if ($reflectClass->getMethod($method)->getDeclaringClass()->getName() !== $reflectClass->getName()) {
throw new \Exception('继承:'.__CLASS__.'的子类必须重写方法:'.$method);
}
}
unset($method);
}
评论