Read lines from the bottom of giver file

@param   string  $file  the file path
@param   integer $count the count of wanted lines

@return  array            an array of read lines or false of fiel error
540282
public static function getLinesFromBottom( $file , $count = 1 )
	{
		$fl    = @fopen( $file , "r" );
		$lines = array();
		$bytes = 0;

		if ( $fl === false )
		{
			return false;
		}

		$count = max( 1 , (int)$count );

		for ( $x_pos = 0 , $ln = 0 , $line = '' , $still = true ; $still ; $x_pos-- )
		{

			if ( fseek( $fl , $x_pos , SEEK_END ) === -1 )
			{
				$still = false;
				$char  = "\n";
			}
			else
			{
				$char = fgetc( $fl );
			}

			if ( $char === "\n" )
			{

				$deal = utf8_encode( $line );
				$line = '';

				if ( $deal !== '' )
				{
					$lines[] = $deal;
					$count--;
					if ( $count === 0 )
					{
						$still = false;
					}
				}

				// continue directly without keeping the \n
				continue;
			}
			$line = $char . $line;
			$bytes++;
		}

		fclose( $fl );

		return $lines;
	}
144596
protected function processLines(SplFileObject $file)
    {
        $extension = $file->getExtension();

        $totalLines = 0;
        $totalBlankLines = 0;
        $totalComments = 0;
        $isMultilines = false;
        while ($file->valid()) {
            $currentLine = $file->fgets();
            $trimLine = trim($currentLine);

            // Ignoring the last new line
            if ($file->eof() && empty($trimLine)) {
                break;
            }

            $totalLines ++;
            if (empty($trimLine)) {
                $totalBlankLines ++;
            }

            // Detecting comments
            if (strpos($trimLine, '//') === 0
                || strpos($trimLine, '#') === 0) {
                $totalComments ++;
            }

            // Detecting multilines comments
            if (strpos($trimLine, '/*') === 0) {
                $isMultilines = true;
            }
            if ($isMultilines) {
                $totalComments ++;
            }
            if (strpos($trimLine, '*/') === 0) {
                $isMultilines = false;
            }
        }

        if (!isset($this->extensions[$extension])) {
            return;
        }

        $this->setStats($extension, [
            'language' => $this->extensions[$extension],
            'files' => 1,
            'blank' => $totalBlankLines,
            'comment' => $totalComments,
            'code' => $totalLines - ($totalBlankLines + $totalComments),
        ]);
    }
564625
protected function getListLanguage($count = false)
    {
        $list = $this->language->getList();

        $allowed = $this->getAllowedFiltersLanguage();
        $this->filterList($list, $allowed, $this->query_filter);
        $this->sortList($list, $allowed, $this->query_filter, array('code' => 'asc'));

        if ($count) {
            return count($list);
        }

        $this->limitList($list, $this->data_limit);
        $this->prepareListLanguage($list);
        return $list;
    }
94976
private function readMoWords($fp, $offset, $count, $pack)
    {
        fseek($fp, $offset);

        return unpack($pack . $count, fread($fp, $count * 4));
    }
1022720
public function readintarray($unpack, $pos, $count)
    {
        return unpack($unpack . $count, $this->read($pos, 4 * $count));
    }
571235
public static function line_count(string $file, bool $trim=true) {
		// We definitely need a file.
		if (! $file || ! @\is_file($file)) {
			return 0;
		}

		$lines = 0;

		// Unfortunately we still need to read the file line by line,
		// but at least we're only loading one line into memory at a
		// time. For large files, this makes a big difference.
		if ($handle = @\fopen($file, 'r')) {
			while (false !== ($line = @\fgets($handle))) {
				if ($trim) {
					if (\trim($line)) {
						++$lines;
					}
				}
				else {
					++$lines;
				}
			}

			@\fclose($handle);
		}

		return $lines;
	}
330444
public function getLastCommand($count = 1) {
    $retval = array();
    for($i = 0; $i < $count; $i++) {
      $retval[] = array_pop($this->command_history);
    }
    return $retval;
  }
414130
public static function read($file)
    {
        if (!is_readable($file) || !is_file($file)) {
            return;
        }

        $data = file_get_contents($file);

        if ($data === false) {
            return;
        }

        return $data;
    }
455039
public function getFilesFromZip($file)
    {
        try {
            $files = $this->zip->set($file)->getList();
        } catch (Exception $e) {
            return array();
        }

        return count($files) < 2 ? array() : $files;
    }
1348150
public function getCellsList($offset, $count)
    {
        //check whether workshett name is set or not
        if ($this->worksheetName == '')
            throw new Exception('Worksheet name not specified');
        $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
            '/worksheets/' . $this->worksheetName . '/cells?offset=' .
            $offset . '&count=' . $count;
        $signedURI = Utils::sign($strURI);
        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
        $json = json_decode($responseStream);
        $listCells = array();
        foreach ($json->Cells->CellList as $cell) {
            $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() .
                '/worksheets/' . $this->worksheetName . '/cells' . $cell->link->Href;
            $signedURI = Utils::sign($strURI);
            $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
            $json = json_decode($responseStream);
            array_push($listCells, $json->Cell);
        }
        return $listCells;

    }
1115477
private function _loadData($type, $count)
    {
        $data = $this->ShapeFile->readSHP($count);
        if ($data === false) {
            return false;
        }
        $this->read += strlen($data);

        return Util::loadData($type, $data);
    }
1175681
public static function read($file)
    {
        if (!is_readable($file)) {
            return;
        }
        $data = @file_get_contents($file);
        if ($data === false) {
            return;
        }
        $value = @unserialize($data);
        if ($value === false) {
            return;
        }

        return $value;
    }
917411
public function stream_read($count)
    {
        $ret = substr($this->_data, $this->_pos, $count);
        $this->_pos += strlen($ret);
        return $ret;
    }
1319097
public function stream_read($count)
    {
        $ret = mb_substr($this->data, $this->position, $count);
        $this->position += mb_strlen($ret);

        return $ret;
    }
173888
public function getLastLines(int $numberOfLines = self::DEFAULT_NUMBER_OF_LINES): array
    {
        $lines = [];
        if (null === $this->file) {
            return $lines;
        }

        $this->file->seek($this->lineCount);
        $currentKey = $this->file->key();
        while ($currentKey >= 0) {
            $line = $this->getDefaultParser()->parse($this->file->current());
            if ($line) {
                $lines[] = $line;
            }

            if (--$currentKey >= 0) {
                $this->file->seek($currentKey);
            }

            if (\count($lines) >= $numberOfLines) {
                break;
            }
        }

        return $lines;
    }
724756
public function stream_read($count)
    {
        $ret = substr($this->data, $this->position, $count);
        $this->position += strlen($ret);
        return $ret;
    }
1105728
protected function getFileContents($file)
    {
        // If the file is not readable
        if (!is_readable($file)) {
            throw new RuntimeException(
                sprintf(RuntimeException::INVALID_FILE_STR, $file),
                RuntimeException::INVALID_FILE
            );
        }

        return file_get_contents($file);
    }