php-parser/internal/php5
i582 61523ab396 internal: fixed parsing of expression new
1. Now, for the expression 'new A' the correct
values EndLine, EndPos, and not -1 will be set;
2. Also, for expressions from php5 '$a = &new Foo',
the condition for parsing is fixed when it is necessary
to set the Args values and the initialization of the
NewTkn field is added, in the case when this condition
is false.

## Problem description

The reason why the positions after parsing became
incorrect is that the check that is responsible for
separating expressions like 'new A' and 'new A (args)'
relied on comparison with nil, however, when the parser
was updated, 'ctor_arguments' began to return not nil,
but &ArgumentList{}, so the condition was always true,
and in this case, when calculating the position, the
second argument of the 'NewTokenNodePosition' function
was nil, which is why -1 was returned there.

For the second, the reasons are similar. In addition,
there was a mistake in the number that needs to be
checked. In the expression:

'variable' '=' '&' T_NEW class_name_reference ctor_arguments'

it is necessary to check not 3, but 6 elements for nil.
2021-02-04 07:12:56 +03:00
..
node.go refactoring: move internal nodes 2020-12-28 21:31:24 +02:00
parser_test.go internal: fixed parsing of expression new 2021-02-04 07:12:56 +03:00
parser.go refactoring: update api 2020-12-29 21:23:22 +02:00
php5_bench_test.go refactoring: update api 2020-12-29 21:23:22 +02:00
php5.go internal: fixed parsing of expression new 2021-02-04 07:12:56 +03:00
php5.y internal: fixed parsing of expression new 2021-02-04 07:12:56 +03:00
test.php [refactoring] parameters: new node structure 2020-07-05 22:47:46 +03:00