Skip to content

Replace @public PHPDoc with #[Exposed] attribute#39

Merged
JBlaak merged 2 commits intomainfrom
switch-public-attribute
May 4, 2026
Merged

Replace @public PHPDoc with #[Exposed] attribute#39
JBlaak merged 2 commits intomainfrom
switch-public-attribute

Conversation

@JBlaak
Copy link
Copy Markdown
Owner

@JBlaak JBlaak commented Apr 25, 2026

Summary

  • Replace the @public PHPDoc marker for strict-module public APIs with a PHP 8 attribute PhpModules\Attributes\Exposed, detected via PhpParser's NameResolver against class/enum attrGroups.
  • New PhpModules\Attributes module (no deps) hosts the attribute so it can be safely depended on by every other internal module without cycles; modules.php, source classes, README, and all sample fixtures updated accordingly.
  • Drops DocReader::isPublic and the phpdoc field on ClassDefinition (replaced by bool $isExposed). @modules-ignore-next-line stays as a comment since PHP attributes can't be applied to use statements. Analyzer short-circuits imports of Exposed itself so test fixtures (which don't register PhpModules\Attributes) don't trip undefined-module errors, while still marking the dep as used in real codebases.

Test plan

  • ./vendor/bin/phpunit — 27/27 pass
  • ./modules test (project dogfooding) — no errors
  • ./vendor/bin/phpstan analyze — no errors

🤖 Generated with Claude Code

JBlaak and others added 2 commits April 25, 2026 14:26
Switch the strict-module public-API marker from a `@public` PHPDoc tag to
a PHP 8 attribute `PhpModules\Attributes\Exposed`. Detection now reads
class/enum attribute groups via PhpParser's NameResolver instead of
parsing PHPDoc, dropping `DocReader::isPublic` (the import-level
`@modules-ignore-next-line` stays as a comment since PHP attributes are
not allowed on `use` statements).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Analyzer now skips imports that match a hardcoded list of namespaces
(PhpModules\Attributes for the framework's own attributes, Closure for
the PHP built-in) before any module resolution. This removes the need
to register PhpModules\Attributes as a dependency on every module in
modules.php, and replaces the previous Exposed-specific bypass with a
general mechanism.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JBlaak JBlaak merged commit 2415fb2 into main May 4, 2026
4 checks passed
@JBlaak JBlaak deleted the switch-public-attribute branch May 4, 2026 13:52
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