Include a file

@param string $filename
320808
public static function loadFile($filename)
    {
        if (class_exists(\PHPUnit\Util\Fileloader::class)) {
            // PHPUnit 6.x
            \PHPUnit\Util\Fileloader::checkAndLoad($filename);
        } else {
            // PHPUnit 7.x+
            \PHPUnit\Util\FileLoader::checkAndLoad($filename);
        }
    }
291504
public function setFileName($filename)
    {
        $this->load();
        $this->filename = $filename;
        $this->io = new Real($filename);
    }
869157
public function containsFile( $fileName )
	{
		if( !$this->numFiles )
			return FALSE;
		foreach( $this->files as $key => $information )
			if( $information['name'] == $fileName )
				return TRUE;
	}
151568
protected function addFile(File $file) {
        $files = $this->getFiles();
        $files[$file->getName()] = $file;
        $this->setFiles($files);
    }
5635
private void includeFile(File file)
        throws IOException
    {
        if (!file.exists())
            throw new FileNotFoundException(file.toString());
        
        if (file.isDirectory())
        {
            List list = new List(List.Unordered);       
            String[] ls = file.list();
            for (int i=0 ; i< ls.length ; i++)
                list.add(ls[i]);
            StringWriter sw = new StringWriter();
            list.write(sw);
            reader = new StringReader(sw.toString());
        }
        else
        {
            reader = new BufferedReader(new FileReader(file));
        }
    }
1109738
public function output(string $filename)
    {
        $basename  = pathinfo($filename, PATHINFO_BASENAME);
        $this->save($basename, true);
    }
525286
public function includeBlock($blockName)
    {
        $blockName = str_replace('/', DIRECTORY_SEPARATOR, $blockName);
        $blockContent = '';
        $blockFile = BASE_PATH . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'share' . DIRECTORY_SEPARATOR . 'layout' . DIRECTORY_SEPARATOR . $blockName . '.' . $this->config['templateExtension'];

        if (file_exists($blockFile)) {
            $templateTmp = file_get_contents($blockFile);
            preg_match_all("~\{\{\s*(.*?)\s*\}\}~", $templateTmp, $block);
            foreach ($block[1] as $k => $v) {
                if ($v === 'php') {
                    $templateTmp = str_replace('{{php}}', '<?php', $templateTmp);
                } elseif ($v === '/php') {
                    $templateTmp = str_replace('{{/php}}', '?>', $templateTmp);
                } else {
                    $blockTemplate = $this->includeBlock($v);
                    $templateTmp = str_replace('{{' . $v . '}}', $blockTemplate, $templateTmp);
                }
            }
            $blockContent = $templateTmp;
        } else {
            $blockContent = 'FILE NOT FOUND (' . $blockFile . ')';
        }
        return $blockContent;
    }
780005
public function save($fileName = null)
	{
		file_put_contents(empty($fileName) ? $this->fileName : $fileName, XML::toString($this->data), LOCK_EX);
	}
649596
public function setFileName($fileName)
	{
		$hasFilename = ($this->fileName !== null);
		
		if ($hasFilename) {
			$previousName = $this->fileName;
			$previousExtension = $this->getExtension();
		}
		
		parent::setFileName($fileName);
		
		if ($hasFilename) {
			
			$newExtension = $this->getExtension();

			if (strcasecmp($previousExtension, $newExtension) !== 0) {

				// restore name back to previous one. Because that's safer.
				parent::setFileName($previousName);

				throw new \RuntimeException('Extension change is not allowed');
			}
		}
	}
96841
public function add($url, $filename)
    {
        array_push(
            $this->data,
            array('url' => $url, 'length' => '-', 'filename' => $filename)
        );
        $this->write();
    }
154101
public function saveAsScript(string $filename): void
    {
        $config = clone $this;
        unset($config->i__loader);

        $export = str_replace('stdClass::__set_state', '(object)', var_export($config, true));
        $script = "<?php\nreturn $export;";

        $success = file_put_contents($filename, $script, str_contains($filename, ':') ? 0 : LOCK_EX);

        if ($success && function_exists('opcache_compile_file')) {
            // @codeCoverageIgnoreStart
            opcache_compile_file($filename);
            // @codeCoverageIgnoreEnd
        }
    }
474894
public function import($filename)
    {
        // TODO: Wrap this in a transaction!
        if (!file_exists($filename)) {
            throw new Exception("File not found: $filename");
        }

        $sql_queries = file_get_contents($filename);
        $sql_queries = $this->_removeRemarks($sql_queries);
        $sql_queries = StringUtils::smartSplit($sql_queries, ";", "'", "\\'");

        foreach ($sql_queries as $sql) {
            $sql = trim($sql); // Trim newlines so we don't have blank queries
            if (empty($sql))
                continue;
            $this->write($sql);
        }
    }
1135914
protected function setFilenameOption($filename): void
    {
        if (is_string($filename)) {
            $filename = new BasicFilename($filename);
        }

        if (!is_callable($filename)) {
            throw new TypeError("Filename should be a string or callable");
        }

        $this->filename = $filename;
    }
79717
public function handleDownload(string $fileName): void
	{
		$file = $this->getFileInfo($fileName);
		if ($file->isDir) {
			$archive = new TempFile;
			File::zip($this->getFullPath($file->name), (string) $archive);
			$response = new FileResponse($archive, $file->name . '.zip');
		} else {
			$response = new FileResponse($this->getFullPath($file->name));
		}
		$this->presenter->sendResponse($response);
	}
218496
final protected function fopen($filename = 'php://temp', $use_include_path = false)
	{

		$this->_fhandle = $filename;
		$this->use_include_path = $use_include_path;
		return $this;
	}
830469
def include(self, filename):
        
        if filename != STDIN and filename in [x[0] for x in self.filestack]:  # Already included?
            self.warning(' Recursive inclusion')

        self.filestack.append([filename, 1, self.lex, self.input_data])
        self.lex = lex.lex(object=self)
        result = self.put_current_line()  # First #line start with \n (EOL)

        try:
            if filename == STDIN:
                self.input_data = sys.stdin.read()
            else:
                self.input_data = api.utils.read_txt_file(filename)

            if len(self.input_data) and self.input_data[-1] != EOL:
                self.input_data += EOL
        except IOError:
            self.input_data = EOL

        self.lex.input(self.input_data)
        return result
124014
public static function autoload(string $className): void
    {
        $classPath = str_replace('\\', DS, $className);
        $path = $classPath . '.php';

        if ((@include $path) === false) {
            // if we fail to include a file, let's throw an exception so we can see where it happened - it'll speed up troubleshooting
            $includePath = get_include_path();
            throw new ApplicationException("Unable to load class {$className} in current include path={$includePath}");
        }
    }