apache / apache/netbeans

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

Open
#7,411 5 comments 1 reaction 0 assignees View on GitHub
kind:feature needs:triage PHP
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 21

### What happened

`/** @var Collection $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

```
$b*/

$b->
```

Use this code in a file and press `+` 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

Contributor guide

Open the contributing guide

Research direction

Start with the supplied PHP reproduction in the issue and inspect how NetBeans handles @var typehints during completion after $b->. Compare it with the working $a-> case; done means the generic Collection form still provides the same Collection or ArrayAccess suggestions without discarding the rest of the annotation.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.