You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "WebSmithery (via GitHub)" <gi...@apache.org> on 2024/09/25 16:10:01 UTC

[I] Parsed variables in function names incorrectly flagged as syntax errors [netbeans]

WebSmithery opened a new issue, #7795:
URL: https://github.com/apache/netbeans/issues/7795

   ### 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 <code>('string_literal' . $stringVariable)</code> or by using double quotes so that PHP parses the variable <code>"string_literal$stringVariable"</code>, and this can be done at the actual function call <code>"string_literal$stringVariable()"</code>
   
   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](https://github.com/user-attachments/assets/74793d11-4b64-4e49-9250-a4704a573d71)
   
   ### 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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists