apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.64k stars 844 forks source link

Parsed variables in function names incorrectly flagged as syntax errors #7795

Open WebSmithery opened 3 days ago

WebSmithery commented 3 days ago

Apache NetBeans version

Apache NetBeans 23

What happened

In PHP, function names can be constructed as strings at runtime.

Such a process can involve joining two strings together, one of which is a variable.

These strings could be joined using the concatenation operator ('string_literal' . $stringVariable) or by using double quotes so that PHP parses the variable "string_literal$stringVariable", and this can be done at the actual function call "string_literal$stringVariable"()

If the concatenation operator is used, NetBeans is perfectly happy, but if double quotes and variable parsing is used, NetBeans flags it as a syntax error:

NetBeans bug

Language / Project Type / NetBeans Component

PHP project

How to reproduce

Enter this code in a PHP file:

<?php
$type = 'int';
$isType = "is_$type"(7);
var_dump($isType);

NetBeans should accept this code without issue, yet it flags it as a syntax error.

It can be verified that there is no such syntax error by running the code. PHP runs the code without errors or warnings, outputting bool(true) (because 7 is an integer).

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 10 Pro, Version 22H2, OS build 19045.4046

JDK

Java Platform SE 22.0.2

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No