gossi\codegen\utils\ReflectionUtils::getOverrideableMethods PHP Method

getOverrideableMethods() public static method

public static getOverrideableMethods ( ReflectionClass $class, boolean $publicOnly = false )
$class ReflectionClass
$publicOnly boolean
    public static function getOverrideableMethods(\ReflectionClass $class, $publicOnly = false)
    {
        $filter = \ReflectionMethod::IS_PUBLIC;
        if (!$publicOnly) {
            $filter |= \ReflectionMethod::IS_PROTECTED;
        }
        return array_filter($class->getMethods($filter), function ($method) {
            return !$method->isFinal() && !$method->isStatic();
        });
    }

Usage Example

 public function testGetOverridableMethods()
 {
     $ref = new \ReflectionClass('gossi\\codegen\\tests\\fixture\\OverridableReflectionTest');
     $methods = ReflectionUtils::getOverrideableMethods($ref);
     $this->assertEquals(4, count($methods));
     $methods = array_map(function ($v) {
         return $v->name;
     }, $methods);
     sort($methods);
     $this->assertEquals(array('a', 'd', 'e', 'h'), $methods);
 }