I want to have type checking on a DsMap variable. In order to do this I've declared a dummy interface and declared types there:
DsMap
/** * @method OtherType offsetGet(MyType $offset) * @method void offsetSet(MyType $offset, OtherType $value) */ interface MyMap extends ArrayAccess, Iterator { }
But when I use it:
/** @var Map|MyMap $map */ $map = new DsMap(); $map[$offset] = $value;
- PhpStorm doesn't recognize it and shows a warning: Illegal array key type MyType. How do I fix that?
Illegal array key type MyType
Use sth like this in the first of your code to say to the phpstorm where is your interface:
use nampespaceMyMap;
1.4m articles
1.4m replys
5 comments
57.0k users