Support PHPStan's annotations for local type aliases and array shapes

Created on 22 July 2023, over 1 year ago

Problem/Motivation

We're trying in 📌 Forbid limited length primary and unique keys, allow only in indexes Needs work to add a local type alias (https://phpstan.org/writing-php-code/phpdoc-types#local-type-aliases) of an array shape (https://phpstan.org/writing-php-code/phpdoc-types#array-shapes), so that we can reuse the definition in multiple docblocks as it happens later for ::validateUniqueKeySchema() and ::validatePrimaryKeySchema(). These aliases can also be imported in other classes with @phpstan-import-type.

Describing the content of arrays is important in code static analysis and it's mandatory in higher PHPStan's levels.

Proposed resolution

Parse @phpstan-type and @phpstan-import-type annotations, and consider them as variable types; while parsing @param @var @return annotations, consider the aliases as valid types.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

2.0

Component

Parser

Created by

🇮🇹Italy mondrake 🇮🇹

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024