I tried using intersection of types
/**
* @param array&nonEmpty $users
*/
function sayHello($users): void {
echo 'Hello, ' . $users[0];
}
but it complains:
PHPDoc tag @param for parameter $users contains unresolvable type.
If I strip the annotation to just nonEmpty
, the error changes to
Parameter $users of function sayHello() has invalid typehint type nonEmpty
I do see the class responsible for the nonEmpty
type in the source tree as well as mentioned several times in the tests and issues but I just could not make it work.