Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FileProfilerStorage.php

function FileProfilerStorage::readLineFromFile

Reads a line in the file, backward.

This function automatically skips the empty lines and do not include the line return in result value.

Parameters

resource $file The file resource, with the pointer placed at the end of the line to read:

1 call to FileProfilerStorage::readLineFromFile()
FileProfilerStorage::find in vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php
Finds profiler tokens for the given criteria.

File

vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php, line 227

Class

FileProfilerStorage
Storage for profiler using files.

Namespace

Symfony\Component\HttpKernel\Profiler

Code

protected function readLineFromFile($file) : mixed {
    $line = '';
    $position = ftell($file);
    if (0 === $position) {
        return null;
    }
    while (true) {
        $chunkSize = min($position, 1024);
        $position -= $chunkSize;
        fseek($file, $position);
        if (0 === $chunkSize) {
            // bof reached
            break;
        }
        $buffer = fread($file, $chunkSize);
        if (false === ($upTo = strrpos($buffer, "\n"))) {
            $line = $buffer . $line;
            continue;
        }
        $position += $upTo;
        $line = substr($buffer, $upTo + 1) . $line;
        fseek($file, max(0, $position), \SEEK_SET);
        if ('' !== $line) {
            break;
        }
    }
    return '' === $line ? null : $line;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal