Skip to content

Add AssuranceTypeMapper for IDE-readable type narrowing#2

Draft
alganet wants to merge 1 commit into
mainfrom
ide-narrowing
Draft

Add AssuranceTypeMapper for IDE-readable type narrowing#2
alganet wants to merge 1 commit into
mainfrom
ide-narrowing

Conversation

@alganet

@alganet alganet commented Jun 26, 2026

Copy link
Copy Markdown
Member

Part of a PR group: Fluent - FluentGen - Validation


Generate IDE-readable narrowing PHPDoc from a node's #[Assurance] / fluent mixins narrow types after assert()/check() without a PHPStan extension.

  • New AssuranceTypeMapper maps each assurance shape to a Chain generic: concrete types, argument/element templates, Container subjects, and the Wrap/Container/Elements prefix compositions (with union de-duplication). Argument-wrapping forms stay Chain to avoid retyping Validator parameters to Chain (which would reject raw, non-fluent validators).
  • New NarrowingDoc and TerminalMethod value objects; InterfaceConfig gains emitNarrowing / chainType / templateParam / terminalMethods, threaded through MethodBuilder and MixinGenerator.
  • Unit coverage per bucket plus a MixinGenerator narrowing integration test.

Generate IDE-readable narrowing PHPDoc from a node's #[Assurance] /
fluent mixins narrow types after assert()/check() without a PHPStan extension.

- New AssuranceTypeMapper maps each assurance shape to a Chain<T> generic:
  concrete types, the argument-derived forms (from: Value -> @param T;
  from: TypeString -> @param class-string<T>), element forms, Container
  subjects, and the Wrap/Container/Elements prefix compositions (with union
  de-duplication). #[AssuranceParameter] selects which argument carries the
  type (any position, default first) -- it no longer implies class-string;
  `from` decides the derivation. Argument-wrapping forms stay Chain<mixed> to
  avoid retyping Validator parameters to Chain<T> (which would reject raw,
  non-fluent validators).
- New NarrowingDoc and TerminalMethod value objects; InterfaceConfig gains
  emitNarrowing / chainType / templateParam / terminalMethods, threaded
  through MethodBuilder and MixinGenerator.
- Unit coverage per bucket plus a MixinGenerator narrowing integration test.
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.

1 participant