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

   ### Apache NetBeans version
   
   Apache NetBeans 16
   
   ### What happened
   
   PHP anonymous classes seem to cause unexpected notices.
   
   It's OK.
   
   ```php
   class Bird
   {
       public function speak(string $dialogue): string
       {
           return "Chitter: '{$dialogue}'";
       }
   }
   
   class Main
   {
       private function createBird(): Bird
       {
           return new Bird();
       }
   
       public function output()
       {
           echo $this->createBird()->speak("Hello"), PHP_EOL;
       }
   }
   ```
   
   It causes an unexpected notice.
   
   ```php
   interface Human
   {
       public function speak(string $dialogue);
   }
   
   class Main
   {
       private function createHuman(): Human
       {
           return new class implements Human {
               public function speak(string $dialogue): string
               {
                   return "Say: '{$dialogue}'";
               }
           };
       }
   
       public function output()
       {
           echo $this->createHuman()->speak("Hello"), PHP_EOL;
       }
   }
   ```
   
   It also causes unexpected notices at not only createHuman() but also 
createBird().
   
   ```php
   class Bird
   {
       public function speak(string $dialogue): string
       {
           return "Chitter: '{$dialogue}'";
       }
   }
   
   interface Human
   {
       public function speak(string $dialogue): string;
   }
   
   class Main
   {
       private function createBird(): Bird
       {
           return new Bird();
       }
   
       private function createHuman(): Human
       {
           return new class implements Human {
               public function speak(string $dialogue): string
               {
                   return "Say: '{$dialogue}'";
               }
           };
       }
   
       public function output()
       {
           echo $this->createBird()->speak("Good morning"), PHP_EOL;
           echo $this->createHuman()->speak("Hello"), PHP_EOL;
       }
   }
   ```
   
   ### How to reproduce
   
   1. Create new PHP file
   2. Paste source code in the issue
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   macOS Monterey (12.6)
   
   ### JDK
   
   openjdk version "15.0.1"
   
   ### Apache NetBeans packaging
   
   Apache NetBeans provided installer
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request?
   
   Yes
   
   ### Code of Conduct
   
   Yes


-- 
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