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

Breadcrumb

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

function Error::toColumn

Converts a file offset into a column.

Parameters

string $code Source code that $pos indexes into:

int $pos 0-based position in $code:

Return value

int 1-based column (relative to start of line)

2 calls to Error::toColumn()
Error::getEndColumn in vendor/nikic/php-parser/lib/PhpParser/Error.php
Gets the end column (1-based) into the line where the error ended.
Error::getStartColumn in vendor/nikic/php-parser/lib/PhpParser/Error.php
Gets the start column (1-based) into the line where the error started.

File

vendor/nikic/php-parser/lib/PhpParser/Error.php, line 148

Class

Error

Namespace

PhpParser

Code

private function toColumn(string $code, int $pos) : int {
    if ($pos > strlen($code)) {
        throw new \RuntimeException('Invalid position information');
    }
    $lineStartPos = strrpos($code, "\n", $pos - strlen($code));
    if (false === $lineStartPos) {
        $lineStartPos = -1;
    }
    return $pos - $lineStartPos;
}

API Navigation

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