写文件
@param string $filename
@param string $fileContent
@param int    $flags
762478
static function writeFile( $filename,  $fileContent,  $flags=null){
        mkdir(dirname($filename), 0777, true);
        file_put_contents($filename,$fileContent,$flags);
    }
310186
private static function putResourceContent($name, $filenamePath, $base, $filePath)
    {
        $data = file_get_contents($filenamePath);
        if (!empty($name)) {
            file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data);
        }else {
            file_put_contents($base . $filePath, $data);
        }
    }
298834
public function filePutContents($path, $content, $flags = 0)
    {
        if (! $this->isFile($path) && !$this->createFile($path))
            return false;
        if (($flags & FILE_APPEND) == FILE_APPEND)
            $this->at($path)->content .= $content;
        else
            $this->at($path)->content = $content;
        return true;
    }
185127
function writeFileFromFile($filename, $localFilename, $multicall = false)
    {
        if (!file_exists($localFilename)) {
            throw new InvalidArgumentException('localFilename = ' . print_r($localFilename, true));
        }

        $contents = file_get_contents($localFilename);
        return $this->writeFile($filename, $contents, $multicall);
    }
1147782
protected function processTagContent(?string $tagContent = null): void
    {
        $currentNamespace = NamespaceHelper::findCurrentNamespaceName($this->file, $this->stackPos);

        if (((int) $this->file->findPrevious([T_NAMESPACE], $this->stackPos) > 0) && $currentNamespace &&
            $tagContent !== $currentNamespace) {
            $isFixing = $this->file->addFixableError(
                static::MESSAGE_CODE_TAG_WRONG_PACKAGE,
                $this->stackPos,
                static::CODE_TAG_WRONG_PACKAGE,
                [
                    $currentNamespace
                ]
            );

            if ($isFixing) {
                $this->fixWrongPackage($currentNamespace);
            }
        }
    }
817313
public static function SaveFile($FileName, $FileContents, $Flags = VANILLA_FILE_PUT_FLAGS) {
   
      // Check that the folder exists and is writable
      $DirName = dirname($FileName);
      $FileBaseName = basename($FileName);
      if (!is_dir($DirName))
         throw new Exception(sprintf('Requested save operation [%1$s] could not be completed because target folder [%2$s] does not exist.',$FileBaseName,$DirName));
         
      if (!IsWritable($DirName))
         throw new Exception(sprintf('Requested save operation [%1$s] could not be completed because target folder [%2$s] is not writable.',$FileBaseName,$DirName));
         
      if (file_put_contents($FileName, $FileContents, $Flags) === FALSE)
         throw new Exception(sprintf('Requested save operation [%1$s] could not be completed!',$FileBaseName));

      return TRUE;
   }
1223235
protected function createFile($fileName, $fileContent)
    {
        $this->inCurrentDir(function($mst) use ($fileName, $fileContent) {
            $mst->_mkdir(dirname($fileName));

            $success = file_put_contents($fileName, $fileContent);

            if (false === $success) {
                throw new ExpectationException("Could not write to file $fileName");
            }
        });
    }
796811
public static function file_put_contents(string $filename, $data, int $flags = 0, $context = null){
		$dir = dirname($filename);
		if(!is_dir($dir)){
			if(!mkdir($dir, 0777, true)){
				throw new Exception("Could not create directory $dir");
			}
		}

		file_put_contents($filename, $data, $flags, $context);
	}
1307377
static function saveIncludedFiles($filename, $fromFile) {
        if (file_exists($filename)) {
            $all_included_files = json_decode(file_get_contents($filename), JSON_OBJECT_AS_ARRAY);
        } else {
            $all_included_files = array();
        }
        foreach (get_included_files() as $includedFile) {
            if (!isset($all_included_files[$includedFile])) {
                $all_included_files[$includedFile] = array();
            }
            if (!in_array($fromFile, $all_included_files[$includedFile])) {
                array_push($all_included_files[$includedFile], $fromFile);
            }
        }
        file_put_contents($filename, json_encode($all_included_files));
    }
230623
protected function processTagContent(?string $tagContent = null): void
    {
        if (!$this->isValidContent($tagContent)) {
            $this->getFile()->{'add' . ($this->asError() ? 'Error' : 'Warning')}(...$this->getReportData($tagContent));
        }
    }
84623
protected function sendHeaders(string $filename)
    {
        if (strlen($filename) != strcspn($filename, '\\/')) {
            throw new Exception('The filename cannot contain the "/" and "\\" characters.');
        }

        $flag = FILTER_FLAG_STRIP_LOW;
        if (strlen($filename) !== mb_strlen($filename)) {
            $flag |= FILTER_FLAG_STRIP_HIGH;
        }

        $filenameFallback = str_replace('%', '', filter_var($filename, FILTER_SANITIZE_STRING, $flag));

        $disposition = sprintf('attachment; filename="%s"', str_replace('"', '\\"', $filenameFallback));
        if ($filename !== $filenameFallback) {
            $disposition .= sprintf("; filename*=utf-8''%s", rawurlencode($filename));
        }

        header('Content-Type: text/csv');
        header('Content-Transfer-Encoding: binary');
        header('Content-Description: File Transfer');
        header('Content-Disposition: '.$disposition);
    }
386718
protected function writeFile(string $filename, string $content): void
    {
        try {
            $f = \fopen($filename, 'w');
            \fwrite($f, $content, \mb_strlen($content));
            \fclose($f);
        } catch (\Throwable $e) {
            throw new WriterException($e->getMessage(), $e->getCode(), $e);
        }
    }
142680
public static function file_force_contents($dir, $contents, $flags = 0){
        $dir = explode('/', $dir);
        $file = array_pop($dir);
        $dir = implode('/', $dir);
        clearstatcache(true, $dir);
        if(!file_exists($dir)){mkdir($dir, 0705, true);}
        return file_put_contents($dir . '/' . $file, $contents, $flags);
    }
1274478
public static function process($fileOrContent, array $options = [])
	{
		$minifier = new static;

		if (strlen($fileOrContent) <= PHP_MAXPATHLEN && is_file($fileOrContent))
		{
			$minifier->addFile($fileOrContent, $options);
		}
		else
		{
			$minifier->addContent($fileOrContent, $options);
		}

		return $minifier->minify();
	}
617427
public function write(string $filename, string $contents): int
    {
        return (int)file_put_contents($filename, $contents);
    }
448939
public function open($filename, $flags = null) {
        $result = parent::open($filename, $flags);

        if ($result === true)
            return parent::ER_OK;

        if (!is_int($result)) {
            Logger::log('ZipArchive::open() returned an invalid result: '.$result.' ('.gettype($result).')', L_ERROR);
            return parent::ER_INTERNAL;
        }
        if (!isset(static::$errors[$result]))
            Logger::log('ZipArchive::open() returned an unknown error: '.$result, L_WARN);

        return $result;
    }
1101741
public static function write($path, $content = null, $flags = null)
    {
        $path = Normalize::diskFullPath($path);

        $pathArray = explode(DIRECTORY_SEPARATOR, $path);
        array_pop($pathArray);
        $pathName = implode(DIRECTORY_SEPARATOR, $pathArray);

        if (!Directory::exist($pathName)) {
            Directory::create($pathName);
        }
        return @file_put_contents($path, $content, $flags);
    }