Support detection of never written properties#291
Merged
Conversation
Properties with @api (or in @api classes) should be treated as both read and written by external code. Without this, @api properties were falsely reported as "never written".
Demonstrates the shipmonk.deadProperty.neverWritten identifier alongside the existing neverRead, deadConstant, deadMethod and deadEnumCase identifiers.
Adds a PropertyWrites test class and corresponding shouldMarkPropertyAsWritten override in the custom provider, verifying the extension point suppresses neverWritten errors independently of other member types.
PropertyAccessCollector only tracked promoted property writes for `new` expressions. This adds tracking for static calls to __construct (e.g. parent::__construct()), so promoted properties in parent classes are correctly marked as written.
Instead of detecting promoted property writes at each call site (new, parent::__construct, etc.), emit them once inside the constructor definition via InClassMethodNode. Transitivity handles propagation from any caller automatically. This also removes getDerivedUsages from ProvidedUsagesCollector, as it is no longer needed — provider-marked constructor usages propagate to promoted property writes through the same transitivity mechanism.
Extract buildTransitiveErrorMessages to produce property-aware
messages ("transitively never read/written") instead of always
saying "transitively also unused".
…e properties Virtual properties (hooks that don't reference the backing value) without a set hook cannot be written to, so they should not be tracked for neverWritten detection. This replaces the previous interface-only check with proper virtual property detection that also handles closures, arrow functions, and anonymous classes inside hook bodies correctly.
Contributor
|
🙌 Thanks for this. Will this be tagged soon 🙏 ? |
Member
Author
|
Expect tag this week :) |
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.
Enable via: