naitsirch opened a new issue #3524:
URL: https://github.com/apache/netbeans/issues/3524


   ### Description
   
   Netbeans already supports the array notation in form of `Type[]` (e.g. 
`@return DateTime[]`) in return and param doc comments and respects it for 
autocomplete. But PHP does not support this as a return type declaration (until 
now). It only supports `array` as return type.
   
   So it is more naturally to document this as `array<Type>` (e.g. `@return 
array<DateTime>`. This notation is also supported by 
[PHPStan](https://phpstan.org/writing-php-code/phpdoc-types#general-arrays) and 
[Psalm](https://psalm.dev/docs/annotating_code/type_syntax/array_types/#generic-arrays).
 It is more flexible as it allows to declarate the type of the array key, too:
   ```
   array<int, Type>
   ```
   
   Sometimes you do not have a native array, but an object which is iterable 
and you want to declare those types, too. PHP supports the type `iterable`. So 
this notations should be supported, too:
   ```
   iterable<Type>
   iterable<int, Type>
   ```
   
   It would be great if Netbeans would add support for this notations.
   
   ### Use case/motivation
   
   Here's an example:
   
   ```php
   <?php
   class Example {
       /**
        * @return array<DateTime>
        */
       function dateTimes(): array {
           return [new DateTime('yesterday'), new DateTime('today')];
       }
   }
   
   $example = new Example();
   foreach ($example->dateTimes() as $instanceOfDateTime) {
       $instanceOfDateTime-> // shows autocomplete list, with methods of class 
"DateTime"
   }
   ```
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow the Apache Software Foundation's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct.html)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

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

Reply via email to