[PHP] `@return static` is broken
Apache NetBeans version
Apache NetBeans 21
What happened
@return static PHPDoc typehinting is broken.
It used to work, but I have upgraded to Netbeans 21 and it does no longer work. Instead of typehinting all the static class methods, with complex inheritance, there is some issue.
Language / Project Type / NetBeans Component
PHP
How to reproduce
repro files: https://github.com/atk4/core/blob/18741e5c99/src/StaticAddToTrait.php#L37 https://github.com/atk4/ui/blob/5fc79edc29/src/AbstractView.php#L31 https://github.com/atk4/ui/blob/5fc79edc29/src/View.php https://github.com/atk4/ui/blob/5fc79edc29/src/Form.php
Did this work correctly in an earlier version?
Apache NetBeans 16 or earlier
Operating System
any
JDK
any
Apache NetBeans packaging
Apache NetBeans provided installer
Anything else
No response
Are you willing to submit a pull request?
No
Please write a minimal example to reproduce it soon.
@junichi11 here is minimal repro:
<?php
declare(strict_types=1);
namespace Atk4\Repro;
trait MyHookTrait {}
trait MyStaticAddToTrait
{
/**
* @return static
*/
public static function addTo()
{
return new static();
}
}
abstract class MyBase
{
use MyStaticAddToTrait;
}
class MyForm extends MyBase
{
use MyHookTrait;
public function foo(): void {}
}
MyForm::addTo()->
when you type f on the end, I expect public foo method to by autocompleted/hinted. Currently, only the following is however displayed:
And my observation is when use MyHookTrait; is commented out/removed, the above repro is working then:
@junichi11 were you able to reproduce it?
@mvorisek Reproducible. Thanks!