On Monday, November 12, 2018 10:06:08 AM CST Chuck Burgess wrote:
> So here we do indeed have a special IDE implementation to try to deal with
> the OP's kind of use case.
> 
> Again, I can't envision a more standardized way to solve this with tags
> themselves.
> 
> 
> I'll mention this again, with regard to this use case though:
> Stepping back a moment... that /* @var */ usage... seems like I've only
> ever seen that used to typehint the $item portion of the example, not the
> $stream portion... $stream should have been figured out earlier when it was
> first populated, either by its own /* @var */ doc or by the return type of
> whatever function/method actually populated it.
> 
> Would using the /* @var */ in this manner not solve this use case?
> CRB
> *about.me/ashnazg <http://about.me/ashnazg>*

I agree that, when putting a @var over a foreach, only the $item is really 
relevant to document.

My use case may be tangential/related, as I'm talking more about how to 
specify "iterable of X" in "the return type of whatever function/method 
actually populated it".

While it would be lovely to say that [] implies any "collection", I don't 
think PHP will let us do that.  Arrays and iterables are not interchangeable, 
as there's a few dozen functions that work on arrays but not iterables.

To wit:

/**
 * @return int[]
 */
function foo() : iterable {

}

int[] implies "Array of ints", which means calling array_* functions on it is 
a totally legit thing to do.  But what's returned is an iterable, which means 
there's no guarantee that it's an array; it could return any Traversable, or 
foo() could be a generator itself.  In those cases, the docblock is now 
materially wrong and misleading.

I'm not sure what the best solution here is, but I do think we need one.

(And that's before we get into the excitement of an iterable that returns non-
numeric keys, which is also completely valid, so we have to think about 
something like Go maps, yeaaaaaahhhh!)

--Larry Garfield

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/39547303.NTl641kpUQ%40vulcan.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to