the-liquid-metal opened a new issue, #6026: URL: https://github.com/apache/netbeans/issues/6026
### Apache NetBeans version Apache NetBeans 18 ### What happened The only place where all trait members can be accessed/invoked is the implementing class. Recent RFCs related to trait invalidates previously allowed behavior. Reference: - [Accessing static members on traits](https://wiki.php.net/rfc/deprecations_php_8_1#accessing_static_members_on_traits) - [Constants in Traits](https://wiki.php.net/rfc/constants_in_traits) ### How to reproduce ```php <?php declare(strict_types=1); trait MyTrait { public const CONST_1 = "foo"; protected const CONST_2 = "bar"; private const CONST_3 = "baz"; public static string $propA = "foo"; protected static string $propB = "bar"; private static string $propC = "baz"; public string $propX = "foo"; protected string $propY = "bar"; private string $propZ = "baz"; public static function funcA(string $par1): string { return $par1."foo"; } protected static function funcB(string $par1): string { return $par1."bar"; } private static function funcC(string $par1): string { return $par1."baz"; } public function funcX(string $par1): string { return $par1."foo"; } protected function funcY(string $par1): string { return $par1."bar"; } private function funcZ(string $par1): string { return $par1."baz"; } } class MyClass { use MyTrait; public function callAll() { // these statements are OK echo static::CONST_1; echo static::CONST_2; echo static::CONST_3; echo self::CONST_1; echo self::CONST_2; echo self::CONST_3; echo $this::CONST_1; echo $this::CONST_2; echo $this::CONST_3; echo static::$propA; echo static::$propB; echo static::$propC; echo self::$propA; echo self::$propB; echo self::$propC; echo $this::$propA; echo $this::$propB; echo $this::$propC; echo $this->propX; echo $this->propY; echo $this->propZ; echo static::funcA("foo"); echo static::funcB("bar"); echo static::funcC("baz"); echo self::funcA("foo"); echo self::funcB("bar"); echo self::funcC("baz"); echo $this::funcA("foo"); echo $this::funcB("bar"); echo $this::funcC("baz"); echo $this->funcX("foo"); echo $this->funcY("bar"); echo $this->funcZ("baz"); $func1A = static::funcA(...); $func1B = static::funcB(...); $func1C = static::funcC(...); $func2A = self::funcA(...); $func2B = self::funcB(...); $func2C = self::funcC(...); $func3A = $this::funcA(...); $func3B = $this::funcB(...); $func3C = $this::funcC(...); $func4X = $this->funcX(...); $func4Y = $this->funcY(...); $func4Z = $this->funcZ(...); var_dump($func1A, $func1B, $func1C, $func2A, $func2B, $func2C); var_dump($func3A, $func3B, $func3C, $func4X, $func4Y, $func4Z); } } $a = new MyClass; $a->callAll(); // these statements are error $t = new MyTrait; echo MyTrait::CONST_1; echo MyTrait::CONST_2; echo MyTrait::CONST_3; echo MyTrait::$propA; echo MyTrait::$propB; echo MyTrait::$propC; echo MyTrait->propX; echo MyTrait->propY; echo MyTrait->propZ; echo MyTrait::funcA("foo"); echo MyTrait::funcB("bar"); echo MyTrait::funcC("baz"); echo $t->funcX("foo"); echo $t->funcY("bar"); echo $t->funcZ("baz"); $func1A = MyTrait::funcA(...); $func1B = MyTrait::funcB(...); $func1C = MyTrait::funcC(...); $func4X = $t->funcX(...); $func4Y = $t->funcY(...); $func4Z = $t->funcZ(...); var_dump($func1A, $func1B, $func1C, $func2A, $func2B, $func2C); var_dump($func3A, $func3B, $func3C, $func4X, $func4Y, $func4Z); ``` ### 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
