Replace @public PHPDoc with #[Exposed] attribute#39
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@publicPHPDoc marker for strict-module public APIs with a PHP 8 attributePhpModules\Attributes\Exposed, detected via PhpParser'sNameResolveragainst class/enumattrGroups.PhpModules\Attributesmodule (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.DocReader::isPublicand thephpdocfield onClassDefinition(replaced bybool $isExposed).@modules-ignore-next-linestays as a comment since PHP attributes can't be applied tousestatements.Analyzershort-circuits imports ofExposeditself so test fixtures (which don't registerPhpModules\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