Skip to content

0.15.3

Choose a tag to compare

@dereuromark dereuromark released this 20 May 13:37
· 371 commits to master since this release
d1828e5

Improvements

Allow basic array<x, y> or interable<x, y> usage now in doc blocks. We do not encourage it at this point, as IDEs still don't understand them inside @param and @return, but it is possible to do so now on project level.

Tip: Instead, use @phpstan-* or @psalm-* annotations on top of the current ones where needed. This works then for both developer usability (IDEs) and static analysis.

For a Generator it could look like the following:

/**
 * @phpstan-return \Generator<\My\ClassName>
 *
 * @return \Generator|\My\ClassName[]
 */
public function someCollection(): Generator
{
    yield ...;
}

FQCN class strings can be annotated this way:

/**
 * @phpstan-return class-string<\Foo>[]
 *
 * @return string[]
 */
public function someClassNames(): array
{
    return [
        'Foo' => Foo::class,
    ];
}

Also the type of the key where applicable:

/**
 * @phpstan-return array<string, \Foo>
 *
 * @return \Foo[]
 */
public function someClassNames(): array
{
    return [
        'Foo' => new Foo(),
    ];
}