the-liquid-metal opened a new issue, #6032:
URL: https://github.com/apache/netbeans/issues/6032
### Apache NetBeans version
Apache NetBeans 18
### What happened
Classes must declare ```__callStatic``` magic method in order to handle
undeclared/inaccessible instance method.
### How to reproduce
```php
<?php
declare(strict_types=1);
class MyStrictClass1 {
public static function fnPublic() {}
protected static function fnProtected() {}
private static function fnPrivate() {}
public function fnStatic() {
static::fnPublic(); // OK
static::fnProtected(); // OK
static::fnPrivate(); // OK
static::fnUndefined(); // this statement must display error
self::fnPublic(); // OK
self::fnProtected(); // OK
self::fnPrivate(); // OK
self::fnUndefined(); // this statement must display error
}
public function fnInstance() {
static::fnPublic(); // OK
static::fnProtected(); // OK
static::fnPrivate(); // OK
static::fnUndefined(); // this statement must display error
self::fnPublic(); // OK
self::fnProtected(); // OK
self::fnPrivate(); // OK
self::fnUndefined(); // this statement must display error
$this::fnPublic(); // OK
$this::fnProtected(); // OK
$this::fnPrivate(); // OK
$this::fnUndefined(); // this statement must display error
}
}
class MyStrictClass2 extends MyStrictClass1 {
public function fnStatic() {
static::fnPublic(); // OK
static::fnProtected(); // OK
static::fnPrivate(); // this statement must display error
static::fnUndefined(); // this statement must display error
self::fnPublic(); // OK
self::fnProtected(); // OK
self::fnPrivate(); // this statement must display error
self::fnUndefined(); // this statement must display error
}
public function fnInstance() {
static::fnPublic(); // OK
static::fnProtected(); // OK
static::fnPrivate(); // this statement must display error
static::fnUndefined(); // this statement must display error
self::fnPublic(); // OK
self::fnProtected(); // OK
self::fnPrivate(); // this statement must display error
self::fnUndefined(); // this statement must display error
$this::fnPublic(); // OK
$this::fnProtected(); // OK
$this::fnPrivate(); // this statement must display error
$this::fnUndefined(); // this statement must display error
}
}
class MyClassWithMagicMethods1 {
public function fnPublic() {}
protected function fnProtected() {}
private function fnPrivate() {}
public function __callStatic($name, $args) {
$this->$name(...$args);
}
public function fnStatic() {
static::fnPublic(); // OK
static::fnProtected(); // OK
static::fnPrivate(); // OK
static::fnUndefined(); // OK
self::fnPublic(); // OK
self::fnProtected(); // OK
self::fnPrivate(); // OK
self::fnUndefined(); // OK
}
public function fnInstance() {
static::fnPublic(); // OK
static::fnProtected(); // OK
static::fnPrivate(); // OK
static::fnUndefined(); // OK
self::fnPublic(); // OK
self::fnProtected(); // OK
self::fnPrivate(); // OK
self::fnUndefined(); // OK
$this::fnPublic(); // OK
$this::fnProtected(); // OK
$this::fnPrivate(); // OK
$this::fnUndefined(); // OK
}
}
class MyClassWithMagicMethods2 extends MyClassWithMagicMethods1 {
public function fnStatic() {
static::fnPublic(); // OK
static::fnProtected(); // OK
static::fnPrivate(); // OK
static::fnUndefined(); // OK
self::fnPublic(); // OK
self::fnProtected(); // OK
self::fnPrivate(); // OK
self::fnUndefined(); // OK
}
public function fnInstance() {
static::fnPublic(); // OK
static::fnProtected(); // OK
static::fnPrivate(); // OK
static::fnUndefined(); // OK
self::fnPublic(); // OK
self::fnProtected(); // OK
self::fnPrivate(); // OK
self::fnUndefined(); // OK
$this::fnPublic(); // OK
$this::fnProtected(); // OK
$this::fnPrivate(); // OK
$this::fnUndefined(); // OK
}
}
MyStrictClass1::fnPublic(); // OK
MyStrictClass1::fnProtected(); // this statement must display error
MyStrictClass1::fnPrivate(); // this statement must display error
MyStrictClass1::fnUndefined(); // this statement must display error
$strict = new MyStrictClass1;
$strict::fnPublic(); // OK
$strict::fnProtected(); // this statement must display error
$strict::fnPrivate(); // this statement must display error
$strict::fnUndefined(); // this statement must display error
MyClassWithMagicMethods1::fnPublic(); // OK
MyClassWithMagicMethods1::fnProtected(); // this statement must display
error
MyClassWithMagicMethods1::fnPrivate(); // this statement must display
error
MyClassWithMagicMethods1::fnUndefined(); // this statement must display
error
$magic = new MyClassWithMagicMethods1;
$magic::fnPublic(); // OK
$magic::fnProtected(); // OK
$magic::fnPrivate(); // OK
$magic::fnUndefined(); // OK
function myFunc(MyStrictClass1 $strict, MyClassWithMagicMethods1 $magic) {
$strict::fnPublic(); // OK
$strict::fnProtected(); // this statement must display error
$strict::fnPrivate(); // this statement must display error
$strict::fnUndefined(); // this statement must display error
$magic::fnPublic(); // OK
$magic::fnProtected(); // OK
$magic::fnPrivate(); // OK
$magic::fnUndefined(); // OK
}
$strict->fnInstance();
$magic->fnInstance();
myFunc($strict, $magic);
(new MyStrictClass2)->fnInstance();
(new MyClassWithMagicMethods2)->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