the-liquid-metal opened a new issue, #6021:
URL: https://github.com/apache/netbeans/issues/6021

   ### Apache NetBeans version
   
   Apache NetBeans 18
   
   ### What happened
   
   In general, Netbeans can detect various error on class constant declaration. 
There are several errors related to instantiation, which can confuse people. 
   
   ### How to reproduce
   
   ```php
   <?php
   class MyClass {
       public function __construct(public $par1 = "bar", public $par2 = "baz") 
{}
   }
   
   class Test1 {
       const CONST_F1 = ["foo", new MyClass];               // already correct 
error display
       const CONST_F2 = ["foo", new MyClass()];             // already correct 
error display
       const CONST_F3 = ["foo", new MyClass($myVar)];       // already correct 
error display
       const CONST_F4 = ["foo", new MyClass(par2: $myVar)]; // already correct 
error display
       const CONST_F5 = ["foo", new MyClass(...$myVar)];    // already correct 
error display
   
       const CONST_C1 = new MyClass;               // incorrect
       const CONST_C2 = new MyClass();             // incorrect
       const CONST_C3 = new MyClass($myVar);       // incorrect
       const CONST_C4 = new MyClass(par2: $myVar); // incorrect
       const CONST_C5 = new MyClass(...$myVar);    // incorrect
   }
   
   class Test2 {
       const CONST_C1 = new MyClass;               // already correct error 
display
       const CONST_C2 = new MyClass();             // incorrect
       const CONST_C3 = new MyClass($myVar);       // incorrect
       const CONST_C4 = new MyClass(par2: $myVar); // incorrect
       const CONST_C5 = new MyClass(...$myVar);    // incorrect
   }
   
   class Test3 {
       const CONST_C3 = new MyClass($myVar);       // already correct error 
display
   }
   
   class Test4 {
       const CONST_C4 = new MyClass(par2: $myVar); // already correct error 
display
   }
   
   class Test5 {
       const CONST_C5 = new MyClass(...$myVar);    // already correct error 
display
   }
   ```
   
   Based on the code, we can conclude that:
   - if instantiation occurs as array member, error is displayed correctly.
   - if previous statement has error, the subsequent statements which have 
instantiation error will not be displayed.
   
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   Windows 10
   
   ### JDK
   
   Java: 14.0.1; Java HotSpot(TM) 64-Bit Server VM 14.0.1+7 Runtime: Java(TM) 
SE Runtime Environment 14.0.1+7
   
   ### Apache NetBeans packaging
   
   Apache NetBeans binary zip
   
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

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

Reply via email to