[ 
https://issues.apache.org/jira/browse/NETBEANS-4509?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17176049#comment-17176049
 ] 

Czukowski commented on NETBEANS-4509:
-------------------------------------

Thanks for the info! My concern was about the traversable types, such as 
{{Doctrine\ORM\Internal\Hydration\IterableResult}}, it's become very common for 
such types to be method arguments or return types, where the autocompletion is 
lacking in NetBeans.

If it's too expensive to examine the class dependency tree, could it be made to 
trust the annotation comments in the first place, and only when there's none, 
then examine the type itself? This can be written in a number of ways though:
{code:php}
/**
 * @param SomeIterableType|Foo[] $result
 */
function processFoos(SomeIterableType $result): void{code}
or maybe just
{code:php}
/**
 * @param Foo[] $result
 */
function processFoos(SomeIterableType $result): void{code}
and something like this also works in PHPStan, although this syntax doesn't 
seem to be parsed correctly by NetBeans:
{code:php}
/**
 * @param SomeIterableType<int, Foo> $result
 */
function processFoos(SomeIterableType $result): void{code}

> PHP - code completion for function returning array
> --------------------------------------------------
>
>                 Key: NETBEANS-4509
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-4509
>             Project: NetBeans
>          Issue Type: Bug
>          Components: php - Editor
>    Affects Versions: 12.0
>            Reporter: Tomáš Procházka
>            Assignee: Tomáš Procházka
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 12.1
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> NetBeans support code completion for array items when their type is specified.
> Code completion does not work for methods which have return type {{array}} in 
> signature and specific type in {{@return}} annotation.
> In following code methods from {{\SplFileInfo}} are offered for variable 
> {{$file}}.
> {code:php}
> /**
>  * @param \SplFileInfo[] $files
>  */
> function walkFiles(array $files) {
>     foreach ($files as $file) {
>         $file-> // Offers methods from \SplFileInfo
>     }
> }
> {code}
> In following code is expected same behavior, but no methods are offered.
> {code:php}
> /**
>  * @return \SplFileInfo[]
>  */
> function getFiles(): array { }
> foreach (getFiles() as $file) {
>     $file-> // Does not offer methods from \SplFileInfo
> }
> {code}
> If return type is removed from {{getFiles()}} method, then methods are 
> offered for {{$file}}.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to