Skip to content

Expand static-analysis normalization coverage for PHPStan pseudo-types#11

Merged
voku merged 3 commits into
mainfrom
copilot/add-full-feature-set
Apr 26, 2026
Merged

Expand static-analysis normalization coverage for PHPStan pseudo-types#11
voku merged 3 commits into
mainfrom
copilot/add-full-feature-set

Conversation

Copilot AI commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

The static-analysis path handled basic refined types, but did not sufficiently validate PHPStan-specific pseudo-types against native/manual-safe stub types. This adds targeted coverage and tightens normalization so PHPStan call map types compare cleanly with stub signatures.

  • Normalization updates

    • Extend TypeNormalizer to collapse additional PHPStan-only syntax into comparable native types:
      • callable signatures with declared return types
      • resource (closed)
      • nullable shorthand handling at the start of a type
    • Keep comparisons aligned with existing native/manual-safe output rather than preserving PHPStan-specific detail.
  • Regression coverage

    • Add a dedicated static-analysis fixture covering representative PHPStan types:
      • list<T>
      • class-string<T>
      • array shapes
      • pure-callable(...)
      • iterable<K, V>
      • int-mask<...>
      • resource (closed)
    • Add a CLI regression test asserting the static_analysis command treats these inputs as equivalent to native/phpDoc stub types.
  • Docs

    • Clarify in the README that the static-analysis flow normalizes PHPStan-only pseudo-types back to comparable native types before reporting mismatches.

Example of the newly covered input shape:

return [
    'phpstan_type_match' => [
        'list<string>',
        'value' => 'non-empty-string',
        'callback' => 'pure-callable(int):literal-string',
        'class' => 'class-string<stdClass>',
        'items' => 'iterable<int,positive-int>',
        'map' => 'array{foo:int,bar?:string}',
        'payload' => 'object{foo:int}',
        'mask' => 'int-mask<1, 2, 4>',
        'stream' => 'resource (closed)',
    ],
];

@voku voku marked this pull request as ready for review April 26, 2026 14:19
@voku voku merged commit 9820b8e into main Apr 26, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants