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