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

Breadcrumb

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

function NodeDumper::dumpPosition

Dump node position, if possible.

Parameters

Node $node Node for which to dump position:

Return value

string|null Dump of position, or null if position information not available

1 call to NodeDumper::dumpPosition()
NodeDumper::dumpRecursive in vendor/nikic/php-parser/lib/PhpParser/NodeDumper.php

File

vendor/nikic/php-parser/lib/PhpParser/NodeDumper.php, line 270

Class

NodeDumper

Namespace

PhpParser

Code

protected function dumpPosition(Node $node) : ?string {
    if (!$node->hasAttribute('startLine') || !$node->hasAttribute('endLine')) {
        return null;
    }
    $start = $node->getStartLine();
    $end = $node->getEndLine();
    if ($node->hasAttribute('startFilePos') && $node->hasAttribute('endFilePos') && null !== $this->code) {
        $start .= ':' . $this->toColumn($this->code, $node->getStartFilePos());
        $end .= ':' . $this->toColumn($this->code, $node->getEndFilePos());
    }
    return "[{$start} - {$end}]";
}
RSS feed
Powered by Drupal