Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you hint an array's items type? [duplicate]

This question is linked to this one :

Is it possible to hint the type of the items inside a returned array ?

e.g. :

/**  *  MyFunction does a lot of things  *  * @param TClass1 $var1  * @param TClass2 $var2  * @return array[TClass3] //<- I'm trying to express this  */  function MyFunction( $var1, $var2 ){    ... 

I am using NetBeans as an IDE, which takes (like many other PHP IDEs) advantage of the doc blocs above functions to determine the type of returned values.

If I could explain what type is expected inside an array, I could hope for the IDE to be able to offer correct completion for the following case :

  $myTab = MyFunction( $foo, $bar );   foreach( $myTab as $itm ){     $itm->myFi| //offer the completion for a TClass3 object   } 
like image 689
LeGEC Avatar asked May 26 '11 13:05

LeGEC


People also ask

How do you find duplicates in Java?

One of the most common ways to find duplicates is by using the brute force method, which compares each element of the array to every other element. This solution has the time complexity of O(n^2) and only exists for academic purposes.

How do I find duplicates in Swift?

The easiest way to find duplicate elements is if the phone number is just a 6-digit number and has type Int, you could sort the array of phone numbers and than filter that to find duplicates. And so on. @Mazyod - from the answer: "you could SORT the array of phone numbers and than FILTER that to find duplicates."


1 Answers

Use

@return TClass3[] 

or

@return TClass3[]|TClass3 
like image 171
OZ_ Avatar answered Oct 02 '22 01:10

OZ_