netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

[PHP] `@return static` is broken

Open mvorisek opened this issue 1 year ago • 3 comments

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.

image

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

mvorisek avatar Mar 26 '24 00:03 mvorisek

Please write a minimal example to reproduce it soon.

junichi11 avatar Apr 09 '24 05:04 junichi11

@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:

image

And my observation is when use MyHookTrait; is commented out/removed, the above repro is working then:

image

mvorisek avatar Apr 10 '24 09:04 mvorisek

@junichi11 were you able to reproduce it?

mvorisek avatar May 02 '24 13:05 mvorisek

@mvorisek Reproducible. Thanks!

junichi11 avatar May 31 '24 05:05 junichi11