What is a PHPDoc type?
What is a PHPDoc type?
A PHPDoc type is what’s written in place of [Type] in annotations like @var [Type] or @param [Type] $foo. Learn more about PHPDoc basics »
What are arrayarray and phpstan?
Array shapes allow each key and value to be different. PHPStan allows specifying scalar values as types in PHPDocs: ‘foo’|’bar’ (strings; types can be combined with others) Constant enumerations are also supported: self::SOME_* (all constants on self that start with SOME_) Foo::* (all constants on Foo)
Why use objects instead of arrays in PHP?
An unusual approach is to instead use objects. This doesn’t have to entail using interfaces such as array access. In PHP an object wraps an array for properties. It’s possible to cast an array to an object (without implementation, only properties) and back.
Does PhpStorm support PHPDoc types?
PhpStorm and (PHPStan & Psalm) are supporting some new (and some not that new) array syntax for PHPDoc types, but for now PhpStorm will not auto-generate this types. int []: an array with only INT values – [1, 4, 6, 8, 9, …]