You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "the-liquid-metal (via GitHub)" <gi...@apache.org> on 2023/06/05 09:26:56 UTC

[GitHub] [netbeans] the-liquid-metal opened a new issue, #6041: [PHP] Instantiation using an inaccessible constructor must produce error

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

   ### Apache NetBeans version
   
   Apache NetBeans 18
   
   ### What happened
   
   PHP allows constructor to be declared with private or protected visibility. This feature is useful for creating singleton (and may be other pattern).
   
   ### How to reproduce
   
   ```php
   <?php
   declare(strict_types=1);
   
   final class MyClass {
       private static $instance;
       public static function create() {
       	static::$instance ??= new static;
           return static::$instance;
       }
   
       private function __construct() {}
   }
   
   $ins1 = new MyClass;       // this statement must display error
   $ins2 = MyClass::create(); // OK
   $ins3 = MyClass::create(); // OK
   echo $ins2 === $ins3 ? "singleton" : "ordinary";
   ```
   
   ### 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: 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