Process the lines from a file.

@param  SplFileObject $file

@return void
9884
protected function processLines(SplFileObject $file)
    {
        $filename = $file->getPathname();

        $lines = [];
        $duplicates = [];
        foreach ($file as $line) {
            $trimLine = trim($line);
            $lineNo = ($file->key() + 1);

            if (isset($lines[$trimLine])) {
                $foundLineNo = $lines[$trimLine];
                if (!in_array($foundLineNo, $duplicates)) {
                    $duplicates[] = $foundLineNo;
                }

               $duplicates[] = $lineNo;
            } else if (strlen($trimLine) > 3) {
                // Non duplicate first line
                $lines[$trimLine] = $lineNo;
            }
        }

        $totalDuplicates = count($duplicates);
        if ($totalDuplicates > 0) {
            sort($duplicates);
            $duplicatesStr = '';
            foreach (array_chunk($duplicates, 10) as $chunk) {
                $duplicatesStr .= implode(', ', $chunk) . PHP_EOL;
            }

            $this->stats[$filename] = [
                'file' => $filename,
                'duplicate' => $totalDuplicates,
                'line_no' => $duplicatesStr,
            ];
        }
    }
913995
public static function highlight($file)
    {
        $highlightFileFunc = new \ReflectionFunction('highlight_file');
        if (!$highlightFileFunc->isDisabled()) {
            highlight_file($file);
        } else {
            echo '<pre>' . htmlspecialchars(file_get_contents($file)) . '</pre>';
        }
    }
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;
        }
    }
38580
public function init($file)
	{
		try {
			
			$this->load($file);

		} catch (Exceptions\FileNotExists $e) {

			$this->create($file);
		}
	}
1055469
public static function removeFile(string $file): void
    {
        if (\is_file($file)) {
            if (!@\unlink($file)) {
                throw new \RuntimeException(\sprintf('Unable to delete file "%s"%s', $file, self::getErrorInfo()));
            }
        }
        
        \clearstatcache(true, $file);
    }
387726
protected function fileToClass(SplFileInfo $file)
    {
        preg_match('/.*namespace\s([^\;]+)?/i', $file->getContents(), $match);

        if (isset($match[1])) {
            $class = $match[1].'\\'.$file->getBasename('.php');
            if (class_exists($class)) {
                return $class;
            }
        }
    }
332490
public function read($file)
    {
        $this->filePath = $file;
        $this->config = parse_ini_file($this->filePath);
    }
730243
private function extractLines($file, $start, $end)
    {
        $fileObject = new \SplFileObject($file);
        $fileObject->seek($start - 1);

        $whitespaceLength = null;
        $content          = '';
        $iterator         = $end - $start;

        while ($line = $fileObject->current()) {
            if ($whitespaceLength === null && preg_match('/^\s*/', $line, $matches)) {
                $whitespaceLength = strlen($matches[0]);
            }

            $line = substr($line, $whitespaceLength);
            $content .= $line ?: PHP_EOL;
            $fileObject->next();
            $iterator--;

            if ($iterator < 0) {
                break;
            }
        }

        return trim($content);
    }
470931
protected function load(SplFileInfo $file)
    {
        $path = $file->getPathName();

        if (!isset($this->cache['contents'][$path])) {
            $data    = $this->decoder->decode($file->getContents(), static::getFormat($file));
            $context = ['file' => $file, 'data' => $data];

            if (is_array($data)) {
                foreach ($this->handlers as $property => $handler) {
                    if ($handler->isSupported($data)) {
                        $value = isset($data[$property]) ? $data[$property] : null;
                        $data[$property] = $handler->handle($value, $context);
                    }
                }
            }

            $this->cache['contents'][$path] = $data;
        }

        return $this->cache['contents'][$path];
    }
821867
public function removeLoaderByFile($file)
    {
        foreach ($this->loaders as $i => $loader) {
            /** @var LoaderInterface $loader */
            if ($loader->supports($file)) {
                unset($this->loaders[$i]);
            }
        }
    }
542182
protected function initialize(array $splFileInfoObjects = [])
    {
        if (!empty($splFileInfoObjects)) {
            foreach ($splFileInfoObjects as $object) {
                array_push($this->fileObjects, $this->createSplFileInfoObject($object));
            }
        }
    }
895626
public function set_file($file) {
        if (!file_exists($file) || (!is_readable($file))) {
            throw new progressive_parser_exception('invalid_file_to_parse');
        }
        $this->file = $file;
        $this->contents = null;
    }
448708
protected function touchFile($file)
    {
        passthru('touch '.$file, $error);
        if ($error !== 0) {
            $this->output->writeln('<error>Error creating file '.$file.'</error>');
        } else {
            $this->output->writeln('<info>File '.$file.' created successfully</info>');
        }
    }
770203
public function resolve($file)
    {
        $info = null;

        $this->rewind();
        foreach (clone $this as $path) {
            $info = new SplFileInfo(rtrim($path, '/') . '/' . ltrim($file, '/'));

            if ($info->isDir() || $info->isFile() || $info->isLink()) {
                break;
            }
        }

        return ($info)? $info->getPathname() : null;
    }
402189
public function addResource(string $file): void
    {
        $contents = file_get_contents($file);
        
        if ($contents === false) {
            throw new \RuntimeException("Error reading file at $file.");
        }
        
        $this->processData(json_decode($contents, true));
    }
657761
protected function filterFile($file)
    {
        if (is_string($file)) {
            $this->file = $file;
        } elseif (is_resource($file)) {
            $this->stream = new Stream($file);
        } elseif ($file instanceof StreamInterface) {
            $this->stream = $file;
        } else {
            throw new \InvalidArgumentException('The file resource is not readable.');
        }
    }
126702
private function lintFile(\SplFileInfo $file)
    {
        if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
            $this->output->write('lint file ' . $file . ' ... ');
        }

        $report = FileReport::create($file);
        $this->reports[] = $report;
        $status = $this->validator->validateFile($report);

        if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
            if (false === $status) {
                $this->output->writeln('<error>errors</error>');
            } else {
                $this->output->writeln('<info>passed.</info>');
            }
        } else {
            if (false === $status) {
                $this->output->write('<error>F</error>');
            } else {
                $this->output->write('.');
            }
        }

        return $status;
    }