Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
WebSmithery opened this issue Sep 25, 2024 · 0 comments
Open
Labels
kind:bug Bug report or fix needs:triage Requires attention from one of the committers PHP [ci] enable extra PHP tests (php/php.editor)

Comments

@WebSmithery
Copy link

WebSmithery commented Sep 25, 2024

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

@WebSmithery WebSmithery added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Sep 25, 2024
@troizet troizet added the PHP [ci] enable extra PHP tests (php/php.editor) label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix needs:triage Requires attention from one of the committers PHP [ci] enable extra PHP tests (php/php.editor)
Projects
None yet
Development

No branches or pull requests

2 participants