PhpBench\Benchmark\Remote\ReflectionHierarchy::hasMethod PHP Method

hasMethod() public method

Return true if the class hierarchy contains the named method.
public hasMethod ( string $name ) : boolean
$name string
return boolean
    public function hasMethod($name)
    {
        foreach ($this->reflectionClasses as $reflectionClass) {
            if (isset($reflectionClass->methods[$name])) {
                return true;
            }
        }
        return false;
    }

Usage Example

Beispiel #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 be static in benchmark class "%s"', $context, $method, $benchmarkReflection->getTop()->class));
     }
 }