BetterReflection\Reflection\ReflectionClass::removeMethod PHP Method

removeMethod() public method

Returns true if method was successfully removed. Returns false if method was not found, or could not be removed.
public removeMethod ( string $methodName ) : boolean
$methodName string
return boolean
    public function removeMethod($methodName)
    {
        $lowerName = strtolower($methodName);
        foreach ($this->node->stmts as $key => $stmt) {
            if ($stmt instanceof ClassMethod && $lowerName === strtolower($stmt->name)) {
                unset($this->node->stmts[$key], $this->cachedMethods);
                return true;
            }
        }
        return false;
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function removeMethod($methodName)
 {
     return $this->reflectionClass->removeMethod($methodName);
 }