The file containing the diff output

Required.

@param  PhingFile $file File containing the diff output
@return void
@throws BuildException if $file not exists
421992
public function setPatchFile(PhingFile $file)
    {
        if (!$file->exists()) {
            throw new BuildException('patchfile ' . $file . " doesn't exist", $this->getLocation());
        }
        $this->cmd->createArgument()->setValue('-i');
        $this->cmd->createArgument()->setFile($file);
        $this->havePatchFile = true;
    }
887253
public function main()
    {
        if (!$this->propertyName) {
            throw new BuildException("You must specify the propertyName attribute", $this->getLocation());
        }

        // Currently only files are supported
        if ($this->file === null) {
            throw new BuildException("You must specify a path to resolve", $this->getLocation());
        }

        $fs = FileSystem::getFileSystem();

        // if dir attribute was specified then we should
        // use that as basedir to which file was relative.
        // -- unless the file specified is an absolute path
        if ($this->dir !== null && !$fs->isAbsolute(new PhingFile($this->file))) {
            $this->file = new PhingFile($this->dir->getPath(), $this->file);
        }

        $resolved = $this->project->resolveFile($this->file);

        $this->log("Resolved " . $this->file . " to " . $resolved->getAbsolutePath(), $this->logLevel);
        $this->project->setProperty($this->propertyName, $resolved->getAbsolutePath());
    }
1329048
public function buildFinished(BuildEvent $event)
    {
        parent::buildFinished($event);

        $project = $event->getProject();
        $properties = $project->getProperties();

        $filename = $properties['phing.log.mail.properties.file'];

        // overlay specified properties file (if any), which overrides project
        // settings
        $fileProperties = new Properties();
        $file = new PhingFile($filename);

        try {
            $fileProperties->load($file);
        } catch (IOException $ioe) {
            // ignore because properties file is not required
        }

        foreach ($fileProperties as $key => $value) {
            $properties['key'] = $project->replaceProperties($value);
        }

        $success = $event->getException() === null;
        $prefix = $success ? 'success' : 'failure';

        try {
            $notify = StringHelper::booleanValue($this->getValue($properties, $prefix . '.notify', 'on'));
            if (!$notify) {
                return;
            }

            if (is_string(Phing::getDefinedProperty('phing.log.mail.subject'))) {
                $defaultSubject = Phing::getDefinedProperty('phing.log.mail.subject');
            } else {
                $defaultSubject = ($success) ? 'Build Success' : 'Build Failure';
            }
            $hdrs = [];
            $hdrs['From'] = $this->getValue($properties, 'from', $this->from);
            $hdrs['Reply-To'] = $this->getValue($properties, 'replyto', '');
            $hdrs['Cc'] = $this->getValue($properties, $prefix . '.cc', '');
            $hdrs['Bcc'] = $this->getValue($properties, $prefix . '.bcc', '');
            $hdrs['Body'] = $this->getValue($properties, $prefix . '.body', '');
            $hdrs['Subject'] = $this->getValue($properties, $prefix . '.subject', $defaultSubject);
            $tolist = $this->getValue($properties, $prefix . '.to', $this->tolist);
        } catch (BadMethodCallException $e) {
            $project->log($e->getMessage(), Project::MSG_WARN);
        }

        if (empty($tolist)) {
            return;
        }

        $mail = Mail::factory('mail');
        $mail->send($tolist, $hdrs, $this->mailMessage);
    }
397954
public function setFile($f)
    {
        if (is_string($f)) {
            $f = new PhingFile($f);
        }
        $this->file = $f;
    }
512953
private function processFileFromFilesystem($file, $hash)
    {
        $hashFromCache = $this->cache->read($file);

        if ($hashFromCache) {
            if ($hash != $hashFromCache) {
                $this->cache->write($file, $hash);
                $this->updatedFiles[] = $file;
            }
        } else {
            $this->cache->write($file, $hash);
            $this->newFiles[] = $file;
        }
    }
280039
protected function addResourceFile(string $file): void
    {
        if (!is_file($file)) {
            throw new \InvalidArgumentException("$file is not a file");
        }
        
        $contents = file_get_contents($file);
        
        if ($contents === false) {
            throw new \RuntimeException("Error reading file at $file.");
        }
        
        $this->addResourceString($contents);
    }
620899
protected function outputDeflated(File $file) {
    $crc = $file->isSmooth() ? hash_init('crc32b') : FALSE;
    $rawSize = $deflatedSize = 0;

    $fh = $file->getFilehandle();
    // Use tmpfile because php://temp and php://memory seem buggy (read: unusable) when using a stream filter.
    // ... or my memory is corrupt.
    $deflateHandle = tmpfile();
    $filterArgs = array('level' => $file->getDeflationLevel());
    $deflationFilter = stream_filter_append($deflateHandle, 'zlib.deflate', STREAM_FILTER_READ, $filterArgs);

    // No output till file has been written :(
    while (TRUE) {
      $raw = fread($fh, $this->blockSize);
      fwrite($deflateHandle, $raw);
      $rawLen = $raw === FALSE ? 0 : strlen($raw);
      if (!$rawLen) break;
      $rawSize += $rawLen;
      $crc && hash_update($crc, $raw);
    }

    rewind($deflateHandle);
    while (TRUE) {
      $deflated = fread($deflateHandle, $this->blockSize);
      $deflatedLen = $deflated === FALSE ? 0 : strlen($deflated);
      if (!$deflatedLen) break;
      $deflatedSize += $deflatedLen;
      $this->output($deflated);
    }

    stream_filter_remove($deflationFilter);
    fclose($deflateHandle);
    $fh && fclose($fh);

    if ($crc) $file->setRawCrc(hash_final($crc, TRUE));

    $file->setSize($rawSize);
    $file->setDeflatedSize($deflatedSize);
  }
676819
protected function importFile(PhingFile $file)
    {
        $ctx = $this->project->getReference(ProjectConfigurator::PARSING_CONTEXT_REFERENCE);
        $cfg = $ctx->getConfigurator();
        // Import xml file into current project scope
        // Since this is delayed until after the importing file has been
        // processed, the properties and targets of this new file may not take
        // effect if they have alreday been defined in the outer scope.
        $this->log(
            "Importing file {$file->getAbsolutePath()} from "
            . $this->getLocation()->getFileName(),
            Project::MSG_VERBOSE
        );
        ProjectConfigurator::configureProject($this->project, $file);
    }
88696
protected function outputRaw(File $file) {
    $fh = $file->getFilehandle();
    $crc = $file->isSmooth() ? hash_init('crc32b') : FALSE;
    $size = 0;
    while (TRUE) {
      $data = fread($fh, $this->blockSize);
      $chunkLength = $data === FALSE ? 0 : strlen($data);
      if ($chunkLength == 0) break;
      $size += $chunkLength;
      $crc && hash_update($crc, $data);
      $this->output($data);
    }

    $file->setSize($size);
    $file->setDeflatedSize($size);

    if ($crc) $file->setRawCrc(hash_final($crc, TRUE));
    fclose($fh);
  }
233642
protected function loadFile(PhingFile $file)
    {
        $fileParser = $this->fileParserFactory->createParser($file->getFileExtension());
        $props = new Properties(null, $fileParser);
        $this->log("Loading " . $file->getAbsolutePath(), $this->logOutput ? Project::MSG_INFO : Project::MSG_VERBOSE);
        try { // try to load file
            if ($file->exists()) {
                $props->load($file);
                $this->addProperties($props);
            } else {
                $this->log(
                    "Unable to find property file: " . $file->getAbsolutePath() . "... skipped",
                    $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN
                );
            }
        } catch (IOException $ioe) {
            throw new BuildException("Could not load properties from file.", $ioe);
        }
    }
1234381
public function main()
    {
        if (isset($this->schema) && !file_exists($this->schema->getPath())) {
            throw new BuildException("Schema file not found: " . $this->schema->getPath());
        }
        if (!isset($this->file) and count($this->filesets) == 0) {
            throw new BuildException("Missing either a nested fileset or attribute 'file' set");
        }

        set_error_handler([$this, 'errorHandler']);
        if ($this->file instanceof PhingFile) {
            $this->lint($this->file->getPath());
        } else { // process filesets
            $project = $this->getProject();
            foreach ($this->filesets as $fs) {
                $ds = $fs->getDirectoryScanner($project);
                $files = $ds->getIncludedFiles();
                $dir = $fs->getDir($this->project)->getPath();
                foreach ($files as $file) {
                    $this->lint($dir . DIRECTORY_SEPARATOR . $file);
                }
            }
        }
        restore_error_handler();
    }
143830
protected function handlePHPUnitConfiguration(PhingFile $configuration)
    {
        if (!$configuration->exists()) {
            throw new BuildException("Unable to find PHPUnit configuration file '" . (string) $configuration . "'");
        }

        if (class_exists('PHPUnit_Util_Configuration')) {
            $config = PHPUnit_Util_Configuration::getInstance($configuration->getAbsolutePath());
        } else {
            $config = \PHPUnit\Util\Configuration::getInstance($configuration->getAbsolutePath());
        }

        if (empty($config)) {
            return;
        }

        $phpunit = $config->getPHPUnitConfiguration();

        if (empty($phpunit)) {
            return;
        }

        $config->handlePHPConfiguration();

        if (isset($phpunit['bootstrap'])) {
            $this->setBootstrap($phpunit['bootstrap']);
        }

        if (isset($phpunit['stopOnFailure'])) {
            $this->setHaltonfailure($phpunit['stopOnFailure']);
        }

        if (isset($phpunit['stopOnError'])) {
            $this->setHaltonerror($phpunit['stopOnError']);
        }

        if (isset($phpunit['stopOnSkipped'])) {
            $this->setHaltonskipped($phpunit['stopOnSkipped']);
        }

        if (isset($phpunit['stopOnIncomplete'])) {
            $this->setHaltonincomplete($phpunit['stopOnIncomplete']);
        }

        if (isset($phpunit['processIsolation'])) {
            $this->setProcessIsolation($phpunit['processIsolation']);
        }

        foreach ($config->getListenerConfiguration() as $listener) {
            if (!class_exists($listener['class'], false)
                && $listener['file'] !== ''
            ) {
                include_once $listener['file'];
            }

            if (class_exists($listener['class'])) {
                if (count($listener['arguments']) == 0) {
                    $listener = new $listener['class'];
                } else {
                    $listenerClass = new ReflectionClass(
                        $listener['class']
                    );
                    $listener = $listenerClass->newInstanceArgs(
                        $listener['arguments']
                    );
                }

                if ($listener instanceof \PHPUnit\Framework\TestListener) {
                    $this->addListener($listener);
                }
            }
        }

        if (method_exists($config, 'getSeleniumBrowserConfiguration')) {
            $browsers = $config->getSeleniumBrowserConfiguration();

            if (!empty($browsers)
                && class_exists('PHPUnit_Extensions_SeleniumTestCase')
            ) {
                PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers;
            }
        }

        return $phpunit;
    }
30781
protected function lint($file)
    {
        $command = $this->interpreter == ''
            ? 'php'
            : $this->interpreter;

        if (strpos($command, 'hhvm') !== false) {
            $command .= ' --no-config -l';
        } else {
            if ($this->deprecatedAsError) {
                $command .= ' -d error_reporting=32767 ';
            }

            $command .= ' -n -l ';
        }

        if (!file_exists($file)) {
            throw new BuildException('File not found: ' . $file);
        }

        if (!is_readable($file)) {
            throw new BuildException('Permission denied: ' . $file);
        }

        if ($this->cache) {
            $lastmtime = $this->cache->get($file);

            if ($lastmtime >= filemtime($file)) {
                $this->log("Not linting '" . $file . "' due to cache", Project::MSG_DEBUG);

                return false;
            }
        }

        $messages = [];
        $errorCount = 0;

        exec($command . '"' . $file . '" 2>&1', $messages);

        for ($i = 0, $messagesCount = count($messages); $i < $messagesCount; $i++) {
            $message = $messages[$i];
            if (trim($message) == '') {
                continue;
            }

            if ((!preg_match('/^(.*)Deprecated:/', $message) || $this->deprecatedAsError) && !preg_match(
                '/^No syntax errors detected/',
                $message
            )
            ) {
                $this->log($message, Project::MSG_ERR);

                if (!isset($this->badFiles[$file])) {
                    $this->badFiles[$file] = [];
                }

                $this->badFiles[$file][] = $message;

                $this->hasErrors = true;
                $errorCount++;
            }
        }

        if (!$errorCount) {
            $this->log($file . ': No syntax errors detected', $this->logLevel);

            if ($this->cache) {
                $this->cache->put($file, filemtime($file));
            }
        }
    }
834233
protected function openPng($file)
    {
        if (file_exists($file) && filesize($file)) {
            $this->resource = @imagecreatefrompng($file);
        } else {
            $this->resource = false;
        }
    }
313618
protected function analyze($file)
    {
        if (file_exists($file)) {
            if (is_readable($file)) {
                // Construct shell command
                $cmd = $this->analyzerPath . " ";

                foreach ($this->enable as $enable) { // Enable warning levels
                    $cmd .= " --enable $enable ";
                }

                foreach ($this->disable as $disable) { // Disable warning levels
                    $cmd .= " --disable $disable ";
                }

                $cmd .= "$file 2>&1";

                // Execute command
                $result = shell_exec($cmd);
                $result = explode("\n", $result);

                for ($i = 2, $size = count($result); $i < ($size - 1); $i++) {
                    $this->counter++;
                    $this->log($result[$i], Project::MSG_WARN);
                }

                $total = count($result) - 3;

                if ($total > 0 && $this->haltonwarning) {
                    throw new BuildException('zendcodeanalyzer detected ' . $total . ' warning' . ($total > 1 ? 's' : '') . ' in ' . $file);
                }
            } else {
                throw new BuildException('Permission denied: ' . $file);
            }
        } else {
            throw new BuildException('File not found: ' . $file);
        }
    }
754384
public function write($file = "")
    {
        $envString = $this->generateEnvString($this->lines);
        file_put_contents($file ? $file : $this->filePath, $envString);
    }
381723
private function checkFileMigration(string $file, OutputInterface $output): int
    {
        $queries = Parser::extractSql(file_get_contents($file));
        if (!empty($queries)) {
            $output->writeln(sprintf('<comment>Migration %s contains</comment>', $file));
            $this->printQueries($queries, $output);
        } else {
            $output->writeln(sprintf('<comment>Migration %s is empty</comment>', $file));
        }
        return 0;
    }