apache / apache/netbeans

Hack {$variable} is not accepted as valid construction

Open
#7,249 1 comment 0 reactions 0 assignees View on GitHub
kind:bug needs:triage PHP
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 21

### What happened

I use PHP's variable hack `{$variable}` in case when I need to use - but I found that this hack is not accepted as valid construction, at least in some cases.

I wanted to use this construction

`$this -> result[$key] = {$this -> used_function}($this -> checked_string, $expression);`

to produce code like (that is part of very simple class for massive validation based on regular expressions)

`$this -> result[$name] = any_function($this -> checked_string, $expression);`

but Netbeans sees code with hack `{$variable}` as invalid - and marks it by red colour. But it is a very strange, because in else case (writen below) it was accepted as valid.

`CalendarCheck::{$this -> calendar_check_method}($index_of_years)`

It is a very problematic, if one feature is accepted in some cases - and not in else cases. It would be very good if this could be corrected.

### Language / Project Type / NetBeans Component

PHP

### How to reproduce

How to reproduce this issue is described in section "What happened".

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Windows 11, 64bit (originally Windows 10, 64 bit)

### JDK

BellSoft LibericaJDK-21 (originally Oracle JRE 8)

### Apache NetBeans packaging

Apache NetBeans provided installer

### Anything else

How it looks in case if hack is not accepted
![HackIsNotAccepted](https://github.com/apache/netbeans/assets/18380572/8abbac64-74d0-4b18-afb1-86107bc45487)
How it looks in case if hack is accepted
![HackIsAccepted](https://github.com/apache/netbeans/assets/18380572/d9717ba6-b3b1-42c2-bf6d-bb21858f1274)

It seems like it is a (known) bug of PHP, not issue of NetBeans.

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two PHP snippets from the issue in the NetBeans PHP editor and compare which dynamic constructions receive an error marker. Trace the PHP parsing or validation entry point responsible for the inconsistent diagnostics. Done means the reported {$this->used_function} call is accepted consistently with CalendarCheck::{$this->calendar_check_method} and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.