Phalcon\Build\Generator_File_PhalconC::appendSource PHP Méthode

appendSource() private méthode

Appends the source to phalcon.c, removing some directives, external symbol declarations and excessive comments
private appendSource ( $fileHandler, $path )
    private function appendSource($fileHandler, $path)
    {
        if (!file_exists($path)) {
            return;
        }
        $openComment = false;
        foreach (file($path) as $line) {
            // Skip comments
            $trimLine = trim($line);
            if ($trimLine == '/*' || $trimLine == '/**') {
                $openComment = true;
                continue;
            }
            if ($openComment) {
                if ($trimLine == '*/' || $trimLine == '**/') {
                    $openComment = false;
                }
                continue;
            }
            // Skip unneeded lines
            if (strncmp($line, '#include "', 10) == 0 || strncmp($line, '#include <', 10) == 0 || strncmp($line, 'ZEPHIR_DOC_METHOD', 18) == 0 || strncmp($line, '#line ', 6) == 0) {
                continue;
            }
            // Clean externs, except for PHP API functions
            if (strncmp($line, 'extern ', 7) == 0) {
                if (substr($line, 7, 8) == 'ZEND_API' || substr($line, 7, 6) == 'PHPAPI') {
                    fwrite($fileHandler, $line);
                } else {
                    fwrite($fileHandler, substr($line, 7));
                }
                continue;
            }
            // Ordinary line - put it as is
            fwrite($fileHandler, $line);
        }
        fwrite($fileHandler, PHP_EOL . PHP_EOL);
    }