Skip to content

Issue #14, #15 patch - #17

Merged
rcalicdan merged 6 commits into
mainfrom
issue-patch
Aug 11, 2026
Merged

Issue #14, #15 patch#17
rcalicdan merged 6 commits into
mainfrom
issue-patch

Conversation

@rcalicdan

Copy link
Copy Markdown
Member

Summary

This PR fixes #14 and #15 by ensuring class-level type aliases are resolved for properties and enhancing error message precision for nested array shapes within Union types.

1. Fix Class-Level Type Alias Resolution for Properties (#14)

  • Root Cause: ContractParser::parseProperty() previously only extracted aliases from the property's local @var docblock. It omitted class-level @phpstan-type and @phpstan-import-type declarations from the class hierarchy, causing properties using imported aliases (e.g., list<PluginInfo>) to fail resolution and fall back to class-name checks (must be of type PluginInfo).
  • Fix:
    • Updated ContractParser::parseProperty() and parseClassAliases() to pre-load all inherited/imported class-level aliases via parseClassLevelDocs().
    • Updated DocblockExtractor::extractAliases() with !isset() checks to ensure child-class alias definitions take precedence over parent definitions during hierarchy traversal.

2. Preserve Deep Structural Errors in Union Validation (#15)

  • Root Cause: When validating a Union type (e.g., array{...} | null), UnionValidator previously discarded inner structural failure messages if all branches failed. It outputted a generic top-level error (must be of type (array{...} | null)), masking the exact failing nested array key or property.
  • Fix:
    • Updated UnionValidator to detect and prioritize deep structural errors (e.g., $payload['args'][2] must be... or is missing required key).
    • If an array shape or object branch fails deeply, UnionValidator now surfaces that specific error instead of falling back to the generic union message.

resolve #14, Closes #15

@rcalicdan
rcalicdan merged commit a23adac into main Aug 11, 2026
12 checks passed
@rcalicdan
rcalicdan deleted the issue-patch branch August 11, 2026 16:09
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.

Issue on associative array @phpstan-import-type is not recognized

1 participant