Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP] @return static is broken #7192

Closed
mvorisek opened this issue Mar 26, 2024 · 4 comments · Fixed by #7431
Closed

[PHP] @return static is broken #7192

mvorisek opened this issue Mar 26, 2024 · 4 comments · Fixed by #7431
Assignees
Labels
kind:bug Bug report or fix PHP [ci] enable extra PHP tests (php/php.editor)
Milestone

Comments

@mvorisek
Copy link

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 mvorisek added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Mar 26, 2024
@troizet troizet added the PHP [ci] enable extra PHP tests (php/php.editor) label Mar 26, 2024
@junichi11
Copy link
Member

Please write a minimal example to reproduce it soon.

@mvorisek
Copy link
Author

mvorisek commented Apr 10, 2024

@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
Copy link
Author

mvorisek commented May 2, 2024

@junichi11 were you able to reproduce it?

@junichi11
Copy link
Member

@mvorisek Reproducible. Thanks!

@junichi11 junichi11 removed the needs:triage Requires attention from one of the committers label May 31, 2024
@junichi11 junichi11 added this to the NB23 milestone May 31, 2024
@junichi11 junichi11 self-assigned this May 31, 2024
junichi11 added a commit to junichi11/netbeans that referenced this issue Jun 3, 2024
- apache#7192
- Set a caller type when a method type is a trait and the caller type is not the same as the method type
- Add unit tests
@junichi11 junichi11 linked a pull request Jun 3, 2024 that will close this issue
junichi11 added a commit to junichi11/netbeans that referenced this issue Jun 3, 2024
- apache#7192
- Set a caller type when a method type is a trait and the caller type is not the same as the method type
- Add unit tests
junichi11 added a commit that referenced this issue Jun 4, 2024
Fix the Code Completion for `static` return type #7192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix PHP [ci] enable extra PHP tests (php/php.editor)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants