/** * Gets parent class. * * @return ReflectionClass A `ReflectionClass` object or null if the class has no parent. */ public function getParentClass() { $parent = parent::getParentClass(); if (!$parent) { return null; } return new ReflectionClass($parent->getName()); }
/** * Test if the `getParentClass` method returns null if the class has no parent. */ public function testGetParentClassReturnNull() { $className = self::FIXTURE_NS . '\\ClassWithoutParent'; $object = new ReflectionObject(new $className()); $this->assertNull($object->getParentClass()); }