Hi,
I am getting hint:
'$option' may not support offset operations (or it's type not annotated properly: [0, \ArrayAccess]).
Analyzes offset operations (adding to index, index-based read, write, etc.) and reports issues found.
on code like this, note that I have even annotated the var as type ArrayAccess
/** @var ArrayAccess $option */
$option = $sets[0];
$label = array_key_exists('label', $option) ? $option['label'] : '';
What would be the proper way to use: $option['label'] here to not get the error inspection ?
Thanks in advance!
The given typehint should be sufficient (e.g. I can not reproduce in PS 2016.3.2).
Would you please provide a code for potentially a bug analysis?
Hi,
found the problem. I needed to add also type hinting to $sets variable. Realize of that after to be sure that type hinting was enough.
Assigned values from uncertain variables types make this error happens I guess. Once all variables have types resolved then error is gone.
Thanks!
Super, thanks for an update!
Most helpful comment
Hi,
found the problem. I needed to add also type hinting to
$setsvariable. Realize of that after to be sure that type hinting was enough.Assigned values from uncertain variables types make this error happens I guess. Once all variables have types resolved then error is gone.
Thanks!