parser-reflection icon indicating copy to clipboard operation
parser-reflection copied to clipboard

Unary minus value expr isn't resolved correctly in NodeExpressionResolver

Open MaximilianKresse opened this issue 4 years ago • 1 comments

Given code:

class Test
{
    const A = -5;

    protected $a = -5;

    public function test($a = -5)
    {}
}

All of these value cannot be parsed correctly in the current version (v3.0.1).

The values of all elements are parsed as "NULL".

The problem can be found in the NodeExpressionResolver. Negativ values are parsed as UnaryMinus with an expression inside. But at the moment there is no "resolveExprUnaryMinus" method and so these nodes are completely ignored.

The same counts for an unary plus. But in most cases you would never write an unary plus before positive numbers (at least I never did it or have seen it).

MaximilianKresse avatar Feb 25 '21 14:02 MaximilianKresse

The inspection completed: 2 updated code elements

scrutinizer-notifier avatar Feb 25 '21 14:02 scrutinizer-notifier

The inspection completed: No new issues

scrutinizer-notifier avatar Jun 21 '23 10:06 scrutinizer-notifier