apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.6k stars 836 forks source link

Typehinting countables in PHP with /** @var Collection<int,bool> $collection */ #7411

Open Eugene-Melbourne opened 1 month ago

Eugene-Melbourne commented 1 month ago

Apache NetBeans version

Apache NetBeans 21

What happened

/** @var Collection<int,bool> $collection */ This form of typehint is new way for countables in PHP I understand it may be too difficult to look inside of these "<"">" and analyze it, but can you please make typehinting to ignore only the contents of it, instead of ignoring all the whole typehinting comment?

Language / Project Type / NetBeans Component

PHP project

How to reproduce

<?php
use ArrayAccess;
class Collection implements ArrayAccess
{}

/** @var Collection $a*/
/** @var Collection<int,int> $b*/

$b->

Use this code in a file and press <strl>+<space> after ->

you will see no suggestions related to Collection class, however, if you replace $b-> with $a-> you get a few suggestions related to ArrayAccess interface.

I believe the same suggestions should be provided in both cases "$b->" and "$a->".

I mean you can ignore everything within <...> but still use the rest from /** @var ... $b*/

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 10 version 10.0 running on amd64; UTF-8; en_AU (nb)

JDK

19.0.2; Java HotSpot(TM) 64-Bit Server VM 19.0.2+7-44

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

Eugene-Melbourne commented 1 month ago

I appreciate your expert opinion, but I'm confused by you changing the "kind" of this ticket from "bug" to "feature".

If I were to request a feature I would prefer the typehints from < and > to be parsed, but I'm not asking for it. It would be too much to ask. I'm asking for a little change, just to ignore these (< and >) to keep the code compatible with phpstan and still useful at some point for Netbeans IDE.

I'm afraid it will never be done if mark this bug as a feature.

junichi11 commented 1 month ago

That pattern has not been implemented yet. So, it's not a bug. NB does not recognize it as a vardoc tag if a type has <> now. We have to fix the lexer.