Phalcon\Build\Generator_File_PhalconC::getSortedSourceFilesToAppend PHP Method

getSortedSourceFilesToAppend() protected method

Excludes unrelated files and the ones, which were already included by an other procedure.
protected getSortedSourceFilesToAppend ( string $path ) : array | boolean
$path string
return array | boolean
    protected function getSortedSourceFilesToAppend($path)
    {
        $basePathLen = strlen($this->sourceDir . '/');
        $flags = \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS;
        $iterator = new \FilesystemIterator($path, $flags);
        $dirs = array();
        $files = array();
        foreach ($iterator as $item) {
            /** @var \SplFileInfo $item */
            $itemPath = Util::normalize($item->getPathname());
            if ($item->isDir()) {
                if (basename($itemPath) == 'kernel') {
                    // These files must have been added already - before usual files
                    continue;
                }
                $dirs[] = $itemPath;
            } else {
                if (substr($itemPath, -2) != '.c') {
                    continue;
                }
                if (isset($this->skipFiles[$itemPath])) {
                    continue;
                }
                $files[] = $itemPath;
            }
        }
        // Compose result, by adding files and sub files to the list
        sort($files);
        $result = $files;
        foreach ($dirs as $dir) {
            $subFiles = $this->getSortedSourceFilesToAppend($dir);
            $result = array_merge($result, $subFiles);
        }
        return $result;
    }