Can you type hint an associative array?
Hi,
I'm trying to type hint an associative array with different type of values such as the following array
$testObject['keyA'] = new Object1;
$testObject['keyB'] = new Object2;
Is this even possible?
Please sign in to leave a comment.
Old question, but: I don't think so. Best I came up with is `/** @var $testObject (Object1|Object2)[] */`. There is an issue at https://youtrack.jetbrains.com/issue/WI-5223 and a plugin (which I did not test) for PhpStorm to partially support a suitable (experimental) syntax: https://plugins.jetbrains.com/plugin/7822-options-completion-plugin