apache / apache/netbeans

Javascript Hint when PHP code embedded in construction of JS object

Open
#4,805 3 comments 0 reactions 0 assignees View on GitHub
kind:bug
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 15

### What happened

```html

var formBox = new FormBox;
formBox.display({
form : document.getElementById('thisForm')
, buttons : [
{icon : 'search.png', label : 'View', name : 'View', submitAction : true}
<?php if ($_SESSION['JobID']==1) {?>
, {icon : 'delete.png', label : 'Delete', name : 'Delete', submitAction : true}
<?php }?>
]
, deleteConfirm : 1
});

```

Above code gives a hint error "Expected an operand but found ," on the line following the first PHP statement, and lines following that up to the end of the JS statement.
Seems like a valid method of building an object in JS dependent on PHP decision.

### How to reproduce

Paste above code in a PHP file in Netbeans editor.

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

No / Don't know

### Operating System

Windows 10 64bit

### JDK

SE 16

### Apache NetBeans packaging

Apache NetBeans provided installer

### Anything else

_No response_

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

No

### Code of Conduct

Yes

Contributor guide

Open the contributing guide

Research direction

Reproduce the reported hint by pasting the supplied example into a PHP file in the NetBeans editor. Trace how the JavaScript and PHP sections are parsed around the conditional object entry, then verify that valid embedded PHP no longer produces the "Expected an operand but found ," diagnostic.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, 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.