Adicionar arquivo do phar
@param $phar
@param \SplFileInfo $file
@param bool $strip
429747
private function addFile(\Phar $phar, \SplFileInfo $file, $strip = true)
    {
        $this->info('add file: ' . str_replace(base_path(), '', $file->getRealPath()));

        $path    = str_replace(base_path(), '', $file->getRealPath());
        $content = file_get_contents($file);

        // Tratar espacos?
        if ($strip)
            $content = $this->stripWhitespace($content);

        // Eh arquivo de licenca?
        if ('LICENSE' === basename($file))
            $content = "\n" . $content . "\n";

        // Tratar parametros
        foreach ($this->params as $pk => $pv)
        {
            $pk = sprintf('@%s@', $pk);
            $content = str_replace($pk, $pv, $content);
        }

        $phar->addFromString($path, $content);
    }
241297
public function addFile($filename, $root = JPATH_ROOT, $strip = 0)
	{
		return $this->add(file_get_contents($filename), $root, $strip);
	}
197779
public function filter(SplFileInfo $file)
    {
        try {
            $class = $this->getClassName($file->getPathname());
        } catch (Exception $e){
            return false;
        }

        $usedtraits = class_uses($class, $this->useautoload);

        foreach ($this->instances as $instance) {
            if (in_array($instance, $usedtraits)) {
                return true;
            }
        }

        return false;
    }
416152
public function queryRequired($path = null, $strip = true)
    {
        return $this->arrRequired($this->queryData(), $path, $strip);
    }
1070507
public function visitFile(\SplFileInfo $file, MessageCatalogue $catalogue)
    {
        if ($file->getExtension() !== 'js') {
            return;
        }

        $process = new Process('node ' . $this->translationDumperPath . ' ' . escapeshellarg($file));
        $process->run();

        $result = json_decode($process->getOutput());

        if ($result && $result->translationsFound) {
            foreach ($result->translationsFound as $translation) {
                $message = new Message($translation->key, $translation->domain);
                $message->addSource(new FileSource($file->getPathname()));
                $catalogue->add($message);
            }
        }
    }
698507
private function _openSHPFile($toWrite = false)
    {
        $this->SHPFile = $this->_openFile($toWrite, '.shp', 'Shape');
        if (! $this->SHPFile) {
            return false;
        }

        return true;
    }
427813
public function detachFile($page, $file)
    {
        $filesIds = $page->files->pluck('id')->toArray();
        $pivotData = [];
        $position = 1;
        foreach ($filesIds as $fileId) {
            if ($fileId != $file->id) {
                $pivotData[$fileId] = ['position' => $position++];
            }
        }
        $page->files()->sync($pivotData);
        $this->forgetCache();
    }
31161
private function addBinFile($phar)
    {
        $content = file_get_contents(__DIR__ . '/../../bin/ctb');
        $content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content);
        $phar->addFromString('bin/ctb', $content);
    }
234254
public function checkDynamic(\Phalcon\Http\Request\File $file = null, $directory, $permission = 0777)
    {
        if (is_dir($directory) === false && file_exists($directory) === false) {
            mkdir(rtrim($directory,'/') . DIRECTORY_SEPARATOR, $permission, true);
        }

        return true;
    }
1061306
protected function addDbup(\Phar $phar)
    {
        $content = file_get_contents(__DIR__ . '/../../../dbup');
        $content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content);

        $phar->addFromString('dbup', $content);
    }
1306358
protected function hasExtension(SplFileInfo $file): bool
    {
        if ($this->extension === null) {
            return true;
        }

        return strtolower($file->getExtension()) === strtolower($this->extension);
    }
226916
public function add_files(\Phar $phar)
    {
        $finder = new Finder();
        $finder->files()
            ->ignoreVCS(true)
            ->name('*.php')
            ->name('logo.txt')
            ->name('about.txt')
            ->exclude('Tests')
            ->exclude('tests')
            ->exclude('docs')
            ->exclude('/storage')
            ->exclude('/config')
            ->in(base_path());

        foreach ($finder as $file)
            $this->addFile($phar, $file, true);
    }
13148
public static function check_phar() {
		// Not checking or can't check, we're done!
		if (! \BLOBCOMMON_PHAR_UPDATES ||
			(false === ($remote = static::get_release_info('Phar URI', static::PHAR_TEMPLATE)))
		) {
			return;
		}

		$current = \get_option('blob-common_installed', false);

		// Everything is current, let's get out of here!
		if (
			! $remote['date_created'] ||
			! $remote['url'] ||
			($remote['date_created'] === $current)
		) {
			return;
		}

		// Generate a unique name for the temporary download.
		$dir = \dirname(\BLOBCOMMON_PHAR_PATH) . '/';
		$file = 'blob-common.phar.new.' . \microtime(true);
		$file = \wp_unique_filename($dir, $file);

		// Download it.
		$response = \wp_remote_get($remote['url']);
		if (200 !== \wp_remote_retrieve_response_code($response)) {
			return;
		}

		// Save it.
		if (@\file_put_contents("{$dir}{$file}", \wp_remote_retrieve_body($response))) {
			@\chmod("{$dir}{$file}", \BLOBCOMMON_CHMOD_FILE);
			// Check the hash.
			if (@\md5_file("{$dir}{$file}") === $remote['checksum']) {
				// Move the file somewhere more permanent. We won't
				// actually load it until the next go around.
				@\rename("{$dir}{$file}", "{$dir}blob-common.phar.new");

				// Update the option so we don't redownload it.
				\update_option('blob-common_installed', $remote['date_created']);
			}
			// It failed; delete it.
			else {
				@\unlink("{$dir}{$file}");
			}
		}
	}
1063573
public static function write($pFile, $pContent, $pAppend = false)
    {
        if (! is_writable($pFile)) {
            self::create($pFile);
        }

        if ($pAppend) {
            return (file_put_contents($pFile, $pContent, FILE_APPEND | LOCK_EX));
        }

        return (file_put_contents($pFile, $pContent, LOCK_EX));
    }
929873
private function addLicense($phar)
    {
        if (is_readable($this->path . '/LICENSE')) {
            $this->addFile($phar, new \SplFileInfo($this->path . '/LICENSE'), false);
        }
    }
635893
public function addFile($file, $fileInfo)
    {
        if (!($fileInfo instanceof \SplFileInfo)) {
            $fileInfo = new \SplFileInfo($fileInfo);
        }

        $this->files[$file] = $fileInfo;

        try {
            $mTime = $fileInfo->getMTime();
        } catch (\Exception $e) {
            $mTime = 0;
        }

        if ($mTime > $this->maxMTime) {
            $this->maxMTime = $mTime;
        }

        return $this;
    }
1310459
protected function makePhar()
    {
        $phar = new Phar($this->filePhar, 0, $this->alias);
        $phar->setSignatureAlgorithm(\Phar::SHA1);
        $phar->startBuffering();

        // Adicionar arquivos
        $this->addFiles($phar);

        // Adicionar arquivo bin
        $this->addBinFile($phar);

        // Adicionar Stup
        $this->addStub($phar);

        // Adicionar licenca
        $this->addLicence($phar);

        // Adicionar arquivo de update
        //$this->addUpdateFile($phar);

        // Finalizar phar.
        $phar->stopBuffering();
        unset($phar);
    }