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

   ### Apache NetBeans version
   
   Apache NetBeans 18
   
   ### What happened
   
   Accessing undeclared/inaccessible class constant must produce error.
   
   ### How to reproduce
   
   ```php
   <?php
   declare(strict_types=1);
   
   class MyClass1 {
       public const PUBLIC_CONST = "foo";
       protected const PROTECTED_CONST = "bar";
       private const PRIVATE_CONST = "baz";
   
       public static function fnStatic() {
           echo static::PUBLIC_CONST;     // OK
           echo static::PROTECTED_CONST;  // OK
           echo static::PRIVATE_CONST;    // OK
           echo static::UNDEFINED_CONST;  // this statement must display error
   
           echo self::PUBLIC_CONST;     // OK
           echo self::PROTECTED_CONST;  // OK
           echo self::PRIVATE_CONST;    // OK
           echo self::UNDEFINED_CONST;  // this statement must display error
       }
   
       public function fnInstance() {
           echo static::PUBLIC_CONST;     // OK
           echo static::PROTECTED_CONST;  // OK
           echo static::PRIVATE_CONST;    // OK
           echo static::UNDEFINED_CONST;  // this statement must display error
   
           echo self::PUBLIC_CONST;     // OK
           echo self::PROTECTED_CONST;  // OK
           echo self::PRIVATE_CONST;    // OK
           echo self::UNDEFINED_CONST;  // this statement must display error
   
           echo $this::PUBLIC_CONST;     // OK
           echo $this::PROTECTED_CONST;  // OK
           echo $this::PRIVATE_CONST;    // OK
           echo $this::UNDEFINED_CONST;  // this statement must display error
       }
   }
   
   class MyClass2 extends MyClass1 {
       public static function fnStatic() {
           echo static::PUBLIC_CONST;     // OK
           echo static::PROTECTED_CONST;  // OK
           echo static::PRIVATE_CONST;    // this statement must display error
           echo static::UNDEFINED_CONST;  // this statement must display error
   
           echo self::PUBLIC_CONST;     // OK
           echo self::PROTECTED_CONST;  // OK
           echo self::PRIVATE_CONST;    // this statement must display error
           echo self::UNDEFINED_CONST;  // this statement must display error
       }
   
       public function fnInstance() {
           echo static::PUBLIC_CONST;     // OK
           echo static::PROTECTED_CONST;  // OK
           echo static::PRIVATE_CONST;    // this statement must display error
           echo static::UNDEFINED_CONST;  // this statement must display error
   
           echo self::PUBLIC_CONST;     // OK
           echo self::PROTECTED_CONST;  // OK
           echo self::PRIVATE_CONST;    // this statement must display error
           echo self::UNDEFINED_CONST;  // this statement must display error
   
           echo $this::PUBLIC_CONST;     // OK
           echo $this::PROTECTED_CONST;  // OK
           echo $this::PRIVATE_CONST;    // this statement must display error
           echo $this::UNDEFINED_CONST;  // this statement must display error
       }
   }
   
   echo MyClass1::PUBLIC_CONST;     // OK
   echo MyClass1::PROTECTED_CONST;  // this statement must display error
   echo MyClass1::PRIVATE_CONST;    // this statement must display error
   echo MyClass1::UNDEFINED_CONST;  // this statement must display error
   
   $ins1 = new MyClass1;
   echo $ins1::PUBLIC_CONST;     // OK
   echo $ins1::PROTECTED_CONST;  // this statement must display error
   echo $ins1::PRIVATE_CONST;    // this statement must display error
   echo $ins1::UNDEFINED_CONST;  // this statement must display error
   
   
   function myFunc(MyClass1 $ins) {
       echo $ins::PUBLIC_CONST;     // OK
       echo $ins::PROTECTED_CONST;  // this statement must display error
       echo $ins::PRIVATE_CONST;    // this statement must display error
       echo $ins::UNDEFINED_CONST;  // this statement must display error
   }
   
   
   $ins1::fnStatic();
   $ins1->fnInstance();
   myFunc($ins1);
   
   $ins2 = new MyClass2;
   $ins2::fnStatic();
   $ins2->fnInstance();
   ```
   
   ### 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