Neos\Flow\Reflection\ReflectionService::getAllSubClassNamesForClass PHP Method

getAllSubClassNamesForClass() public method

If no class inheriting the given class was found, an empty array is returned.
public getAllSubClassNamesForClass ( string $className ) : array
$className string Name of the parent class
return array An array of names of those classes being a direct or indirect subclass of the specified class
    public function getAllSubClassNamesForClass($className)
    {
        if (!$this->initialized) {
            $this->initialize();
        }
        $className = $this->cleanClassName($className);
        if (class_exists($className) === false) {
            throw new \InvalidArgumentException('"' . $className . '" does not exist or is not the name of a class.', 1257168042);
        }
        $this->loadOrReflectClassIfNecessary($className);
        return isset($this->classReflectionData[$className][self::DATA_CLASS_SUBCLASSES]) ? array_keys($this->classReflectionData[$className][self::DATA_CLASS_SUBCLASSES]) : [];
    }

Usage Example

 /**
  * Get all class names inside this namespace and return them as array.
  *
  * @param string $namespace
  * @return array Array of all class names inside a given namespace.
  */
 protected function getClassNamesInNamespace($namespace)
 {
     $affectedViewHelperClassNames = array();
     $allViewHelperClassNames = $this->reflectionService->getAllSubClassNamesForClass(\Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper::class);
     foreach ($allViewHelperClassNames as $viewHelperClassName) {
         if ($this->reflectionService->isClassAbstract($viewHelperClassName)) {
             continue;
         }
         if (strncmp($namespace, $viewHelperClassName, strlen($namespace)) === 0) {
             $affectedViewHelperClassNames[] = $viewHelperClassName;
         }
     }
     sort($affectedViewHelperClassNames);
     return $affectedViewHelperClassNames;
 }
All Usage Examples Of Neos\Flow\Reflection\ReflectionService::getAllSubClassNamesForClass
ReflectionService