PhpBench\Benchmark\Remote\ReflectionHierarchy::hasStaticMethod PHP Метод

hasStaticMethod() публичный Метод

Return true if the class hierarchy contains the named static method.
public hasStaticMethod ( string $name ) : boolean
$name string
Результат boolean
    public function hasStaticMethod($name)
    {
        foreach ($this->reflectionClasses as $reflectionClass) {
            if (isset($reflectionClass->methods[$name])) {
                $method = $reflectionClass->methods[$name];
                if ($method->isStatic) {
                    return true;
                }
                break;
            }
        }
        return false;
    }

Usage Example

Пример #1
0
 private function validateMethodExists($context, ReflectionHierarchy $benchmarkReflection, $method, $isStatic = false)
 {
     if (false === $benchmarkReflection->hasMethod($method)) {
         throw new \InvalidArgumentException(sprintf('Unknown %s method "%s" in benchmark class "%s"', $context, $method, $benchmarkReflection->getTop()->class));
     }
     if ($isStatic !== $benchmarkReflection->hasStaticMethod($method)) {
         throw new \InvalidArgumentException(sprintf('%s method "%s" must %s static in benchmark class "%s"', $context, $method, $isStatic ? 'be' : 'not be', $benchmarkReflection->getTop()->class));
     }
 }