/** * Gets a list of methods. * * @param int $filter The optional filter, for filtering desired method types. It's configured * using the `ReflectionMethod` constants. * * @return ReflectionMethod[] An array of `ReflectionMethod` objects. */ public function getMethods($filter = null) { $methods = array(); foreach (parent::getMethods($filter) as $method) { /* @var \ReflectionMethod $method */ $methods[] = new ReflectionMethod($method->class, $method->name); } return $methods; }
/** * Test if the `getMethods` method returns a list of methods within a class. */ public function testGetMethods() { $className = self::FIXTURE_NS . '\\ClassWithMethods'; $object = new ReflectionObject(new $className()); $methods = $object->getMethods(InternalReflectionMethod::IS_PUBLIC); $this->assertInstanceOf('com\\mohiva\\common\\lang\\ReflectionMethod', $methods[0]); $this->assertInstanceOf('com\\mohiva\\common\\lang\\ReflectionMethod', $methods[1]); $this->assertEquals('foo', $methods[0]->name); $this->assertEquals('bar', $methods[1]->name); }