This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 267470 - PHPDoc inline type hint
Summary: PHPDoc inline type hint
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: PHPDoc (show other bugs)
Version: 8.1
Hardware: All All
: P3 normal with 3 votes (vote)
Assignee: junichi11
URL:
Keywords: PATCH_AVAILABLE
: 245913 269841 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-08-07 17:59 UTC by dnt
Modified: 2018-06-29 19:48 UTC (History)
4 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
proposed patch (129.23 KB, patch)
2017-07-09 04:49 UTC, junichi11
Details | Diff
screenshot (11.54 KB, image/png)
2017-07-09 04:50 UTC, junichi11
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dnt 2016-08-07 17:59:17 UTC
Please add support for PHPDoc inline type hints:

/** @var Type $obj */
$obj = ...;

Thus Netbeans would be compatible with other IDEs e.g. PhpStorm or Eclipse.
Comment 1 Tomas Mysik 2016-08-08 06:01:11 UTC
This already works, long time ago ;)

(In reply to dnt from comment #0)
> /** @var Type $obj */

This is incorrect! It is not a valid PHPDoc so you must use just "/*". SO, in your case it would be:

/* @var Type $obj */
$obj = ...;

Thanks for reporting.
Comment 2 dnt 2016-08-09 09:26:45 UTC
Thanks for the quick reply. What Netbeans supports is:

/* @var $obj Type */ (variable before type)

In https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md#3-definitions the type hint is written in the form I asked for:

/** @var Type $obj */

It would be really helpful if Netbeans would support this as well when working together with users of other IDEs.
Comment 3 Tomas Mysik 2016-08-09 09:53:31 UTC
(In reply to dnt from comment #2)
> In
> https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.
> md#3-definitions

I see. Is this already part of PHPDoc? I see "proposed" in the URL.

Thanks.
Comment 4 Cruiser 2017-05-09 12:45:37 UTC
It is not working in 8.2 either.. But hope it's part of the Netbeans 9
Comment 5 marcovtwout 2017-05-23 14:11:57 UTC
The PSR-5 is still in draft, but other editors already support this syntax. For example, PHPStorm automatically creates blocks like this:

/** @var Type $name */

Would be really helpful if Netbeans can support this too!
Comment 6 junichi11 2017-07-07 04:46:21 UTC
We have to note an order of a variable and types.

/*  @var $variable Type */
/** @var Type $variable Description */

Although I cannot promise anything, I'll try to implement it in the next version(NOT NB9.0).

Thanks.
Comment 7 junichi11 2017-07-09 04:49:01 UTC
Created attachment 164726 [details]
proposed patch

Support for the PHPDoc pattern.

Changes:

- Use /** @var VarType $variable */ as a template instead of /* @var $variable VarType */ (in code template and vardoc hint)
- Legacy vardoc code template abbreviation is changed to "vdocl"
- Currently, if vardoc has some whitespaces /* @var    $variable    VarType */, GotoDeclaration and MarkOccurrences don't work. So this is fixed in this patch.

I'll apply this patch after NetBeans 9.0 is released.

Thanks.
Comment 8 junichi11 2017-07-09 04:50:37 UTC
Created attachment 164727 [details]
screenshot
Comment 9 junichi11 2017-07-22 03:31:10 UTC
*** Bug 245913 has been marked as a duplicate of this bug. ***
Comment 10 junichi11 2017-07-22 10:24:56 UTC
*** Bug 269841 has been marked as a duplicate of this bug. ***