Skip to content

Add support for PHP 8.3 typed class constants#4085

Merged
jaapio merged 2 commits intophpDocumentor:masterfrom
lacatoire:feat/typed-constants-support
Apr 10, 2026
Merged

Add support for PHP 8.3 typed class constants#4085
jaapio merged 2 commits intophpDocumentor:masterfrom
lacatoire:feat/typed-constants-support

Conversation

@lacatoire
Copy link
Copy Markdown
Contributor

@lacatoire lacatoire commented Apr 9, 2026

Summary

Wire the native type from PHP 8.3 typed class constants into the ConstantDescriptor, so it is available for rendering in templates.

  • Pass the type from the reflection Constant to the descriptor in ConstantAssembler, following the same pattern used by PropertyAssembler
  • The HTML template already displays node.type for constants, so typed constants will render their native type automatically

When a native type is present, it takes precedence over @var docblock annotations (consistent with how PHP itself treats type declarations).

Depends on phpDocumentor/Reflection#736.

Fixes #3721

Pass the native type from PHP 8.3 typed class constants through to
the ConstantDescriptor, following the same approach used by
PropertyAssembler.

Requires phpdocumentor/reflection with typed constant support.
@jaapio
Copy link
Copy Markdown
Member

jaapio commented Apr 10, 2026

Thanks, I released phpdocumentor/reflection 6.5.0 you can update this version here to make the pipeline pass.

Reflection 6.5.0 includes typed class constants support,
which this PR depends on.
@jaapio jaapio merged commit 71eab55 into phpDocumentor:master Apr 10, 2026
116 checks passed
@jaapio
Copy link
Copy Markdown
Member

jaapio commented Apr 10, 2026

Very nice, thanks for your help. I will try to prepare a new release soon.

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.

Add support for typed constants

2 participants