src/Autoloader.php
public static function findSourceFiles(string $path)
    {
        $result = array();
        $reader = dir($path);

        while ($file = $reader->read())
        {
            if ($file === '.' || $file === '..')
                continue;

            $file = $path . '/' . $file;
            if (substr($file, -4) === ".php")
            {
                $result[] = $file;
            }
            elseif (is_dir($file))
            {
                $sub = self::findSourceFiles($file);
                foreach ($sub as $f)
                    $result[] = $f;
            }
        }

        return $result;
    }
public static function findSourceFiles(string $path)
    {
        $result = array();
        $reader = dir($path);

        while ($file = $reader->read())
        {
            if ($file === '.' || $file === '..')
                continue;

            $file = $path . '/' . $file;
            if (substr($file, -4) === ".php")
            {
                $result[] = $file;
            }
            elseif (is_dir($file))
            {
                $sub = self::findSourceFiles($file);
                foreach ($sub as $f)
                    $result[] = $f;
            }
        }

        return $result;
    }
Find all .php source files in the specified path or any subdirectory,
and return them in an array.

@return array The list of .php files.