Type hinting for foreach?

when you do

foreach($someArray as $k => $v) {

is there any way to tell WebIDE what types $k and $v are? If not, i would like to post feature request for this

As of build #722 WI can infere $v type from $someArray with the help of /** @var $someArray ElementType[] */ annotation, check http://youtrack.jetbrains.net/issue/WI-265 for details. $k type inference and case of object property interation is not yet supported. I filed a request for you, see http://youtrack.jetbrains.net/issue/WI-623 and http://youtrack.jetbrains.net/issue/WI-624


Thanks for quick answer. As for type hinting for $k -- that's my bad, as in php it could be only string or integer and you can't do much with that anyway ). Critical is $v hinting and it's great news that it's supported! yay.


Please sign in to leave a comment.