Zephir\ClassDefinition::getMethod PHP Method

getMethod() public method

Returns a method by its name
public getMethod ( $methodName, boolean | true $checkExtends = true ) : boolean | ClassMethod
$checkExtends boolean | true
return boolean | ClassMethod
    public function getMethod($methodName, $checkExtends = true)
    {
        $methodNameLower = strtolower($methodName);
        foreach ($this->methods as $name => $method) {
            if ($methodNameLower == $name) {
                return $method;
            }
        }
        if (!$checkExtends) {
            return false;
        }
        $extendsClassDefinition = $this->getExtendsClassDefinition();
        if ($extendsClassDefinition instanceof ClassDefinition) {
            if ($extendsClassDefinition->hasMethod($methodName)) {
                return $extendsClassDefinition->getMethod($methodName);
            }
        }
        return false;
    }

Usage Example

Exemplo n.º 1
0
 public function getOptimizedMethod()
 {
     $optimizedName = $this->getName() . '_zephir_internal_call';
     $optimizedMethod = $this->classDefinition->getMethod($optimizedName, false);
     if (!$optimizedMethod || !$this->optimizable) {
         return $this;
     }
     return $optimizedMethod;
 }
All Usage Examples Of Zephir\ClassDefinition::getMethod