PHPStorm Type hinting array of different types

前端 未结 2 1899
温柔的废话
温柔的废话 2021-01-12 08:11

Is it possible in PHPStorm to type hint an array with different object types, ie:

public function getThings()
{
    return array (new Thing(), new OtherThing         


        
2条回答
  •  北荒
    北荒 (楼主)
    2021-01-12 08:43

    This is described in the PHPDoc standards

    https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md#713-param

    /**
     * Initializes this class with the given options.
     *
     * @param array $options {
     *     @var bool   $required Whether this element is required
     *     @var string $label    The display name for this element
     * }
     */
    public function __construct(array $options = array())
    {
        <...>
    }
    

提交回复
热议问题