BetterReflection\Reflection\ReflectionClass::getImmediateMethods PHP Method

getImmediateMethods() public method

Get only the methods that this class implements (i.e. do not search up parent classes etc.)
public getImmediateMethods ( ) : BetterReflection\Reflection\ReflectionMethod[]
return BetterReflection\Reflection\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;
    }

Usage Example

Example #1
0
 /**
  * getVisibleMethods returns only the methods that are visible according to `api.visibility`.
  *
  * @param \BetterReflection\Reflection\ReflectionClass $class
  *
  * @return \BetterReflection\Reflection\ReflectionMethod[]
  */
 public function getVisibleMethods(ReflectionClass $class)
 {
     try {
         $methods = $class->getMethods();
     } catch (IdentifierNotFound $e) {
         $methods = $class->getImmediateMethods();
     }
     return array_filter($methods, [$this, 'isMethodVisible']);
 }
All Usage Examples Of BetterReflection\Reflection\ReflectionClass::getImmediateMethods