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
Namespace
PhpParserCode
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;
}