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 270235 - [PHP7.1] Null is missing in types of phpdoc if nullable types are used
Summary: [PHP7.1] Null is missing in types of phpdoc if nullable types are used
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: Dev
Hardware: All All
: P3 normal (vote)
Assignee: junichi11
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-29 01:38 UTC by junichi11
Modified: 2017-04-07 01:49 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description junichi11 2017-03-29 01:38:42 UTC
PhpDocumentGenerator does not add null.

/**[Enter]
function test(?int $int): ?string {
    return "something";
}


Current result:

/**
 * 
 * @param int $int
 * @return ?string
 */
function test(?int $int): ?string {
    return "something";
}


Proposed result1:

/**
 * 
 * @param ?int $int
 * @return ?string
 */
function test(?int $int): ?string {
    return "something";
}


Proposed result2:

/**
 * 
 * @param int|null $int
 * @return string|null
 */
function test(?int $int): ?string {
    return "something";
}

Which is proper?
Comment 1 Tomas Mysik 2017-03-29 09:35:51 UTC
I guess "Proposed result2" (<type>|null); see [1] but keep an eye also on [2].

Thanks!
[1] https://phpdoc.org/docs/latest/guides/types.html#multiple-types-combined
[2] https://github.com/phpDocumentor/phpDocumentor2/issues/1833
Comment 2 junichi11 2017-03-29 11:36:16 UTC
(In reply to Tomas Mysik from comment #1)
> I guess "Proposed result2" (<type>|null); see [1] but keep an eye also on
> [2].

I also think so. I'm going to fix it as <type>|null. Thank you for your comment and information!
Comment 3 Tomas Mysik 2017-03-29 11:52:26 UTC
Nothing to thank for, of course. Thanks for looking at this issue!
Comment 4 junichi11 2017-04-06 01:03:09 UTC
Fixed. The problem of interface return types also is fixed(i.e. in a case of no return statements but there is a return type declaration):
e.g.
class Foo {}
interface TestInterface {
    /**
    public function test(?int $int): ?Foo;
}

http://hg.netbeans.org/web-main/rev/1ac8128b1b40

Thanks.
Comment 5 Tomas Mysik 2017-04-06 04:46:14 UTC
Thank you, Junichi!
Comment 6 junichi11 2017-04-06 04:52:02 UTC
You are welcome :)
Comment 7 Quality Engineering 2017-04-07 01:49:52 UTC
Integrated into 'main-silver', will be available in build *201704070002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/1ac8128b1b40
User: Junichi Yamamoto <junichi11@netbeans.org>
Log: #270235 - [PHP7.1] Null is missing in types of phpdoc if nullable types are used