PhpParser\Node\Stmt\ClassLike::getMethods PHP Method

getMethods() public method

Gets all methods defined directly in this class/interface/trait
public getMethods ( ) : ClassMethod[]
return ClassMethod[]
    public function getMethods()
    {
        $methods = array();
        foreach ($this->stmts as $stmt) {
            if ($stmt instanceof ClassMethod) {
                $methods[] = $stmt;
            }
        }
        return $methods;
    }

Usage Example

 /**
  * Get only the methods that this class implements (i.e. do not search
  * up parent classes etc.)
  *
  * @return ReflectionMethod[]
  */
 public function getImmediateMethods()
 {
     /* @var $methods \ReflectionMethod[] */
     $methods = array_map(function (ClassMethod $methodNode) {
         return ReflectionMethod::createFromNode($this->reflector, $methodNode, $this);
     }, $this->node->getMethods());
     $methodsByName = [];
     foreach ($methods as $method) {
         $methodsByName[$method->getName()] = $method;
     }
     return $methodsByName;
 }
All Usage Examples Of PhpParser\Node\Stmt\ClassLike::getMethods