loadMigrationClasses($includedFiles, $namespace); $versions = []; foreach ($classes as $class) { $versions[] = $class->getName(); } return $versions; } /** * Look up all declared classes and find those classes contained * in the given `$files` array. * * @param string[] $files The set of files that were `required` * @param string|null $namespace If not null only classes in this namespace will be returned * * @return ReflectionClass[] the classes in `$files` */ protected function loadMigrationClasses(array $files, ?string $namespace = null): array { $classes = []; foreach (get_declared_classes() as $class) { $reflectionClass = new ReflectionClass($class); if (! in_array($reflectionClass->getFileName(), $files, true)) { continue; } if ($namespace !== null && ! $this->isReflectionClassInNamespace($reflectionClass, $namespace)) { continue; } $classes[] = $reflectionClass; } return $classes; } /** * @param ReflectionClass $reflectionClass */ private function isReflectionClassInNamespace(ReflectionClass $reflectionClass, string $namespace): bool { return strncmp($reflectionClass->getName(), $namespace . '\\', strlen($namespace) + 1) === 0; } }