glayzzle / php-parser

:herb: NodeJS PHP Parser - extract AST or tokens
https://php-parser.glayzzle.com/
BSD 3-Clause "New" or "Revised" License
534 stars 71 forks source link

Wrong start loc when using nullsafeoperator `?->` #1128

Open abdul-alhasany opened 1 year ago

abdul-alhasany commented 1 year ago

Hi The parser seems to provide wrong start loc when using nullsafeoperator.

Example:

<?php
$test = $object?->property;

The example will give this loc:

start: {
   line: 2,
   column: 15, // should be 8
   offset: 21, // should be 14
},
end: {
   line: 2,
   column: 26,
   offset: 32
}

only start.column and start.offset provide the wrong position, the rest of the details are correct.

When removing the operator ? the position details are correct.