Flag Nova convention props as initialised (suppress PropertyNotSetInConstructor) - #7
Merged
Merged
Conversation
PropertyNotSetInConstructor
Nova base classes declare display/attribute props via a `@var` docblock (or a native nullable) with no default: `$name` on Field/Action/Metric/ Filter/Lens, `$attribute`/`$resource` on Field, `$prefix`/`$suffix`/ `$format` on TrendResult. Nova assigns them through the constructor, a setter or reflection, never at declaration, so every concrete subclass that does not redeclare them is reported PropertyNotSetInConstructor. In afterCodebasePopulated, mark each such property as initialised on the class that declares it. ClassAnalyzer::checkPropertyInitialization reads the flag from the declaring class, so the report is silenced on every subclass that inherits the property, while a subclass's own uninitialised typed property still flags. This is per-property precise: no stub with a fictional default value (the runtime value is never that) and no class-level issue suppression (which would hide a subclass's real bugs). The mutation is routed through a helper taking the storage as a parameter so its side effect is visible to Psalm's purity analysis (mirrors the existing suppress() helper). Fixes 47 PropertyNotSetInConstructor reports on the consuming project with no new issues.
alies-dev
force-pushed
the
feat/nova-property-not-set-stubs
branch
from
July 13, 2026 22:59
6a3d729 to
01839f5
Compare
PropertyNotSetInConstructorPropertyNotSetInConstructor)
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.
Problem
Nova base classes declare display/attribute properties via a
@vardocblock (or a native nullable) with no default:Fields\Field:$name,$attribute,$resourceActions\Action,Metrics\Metric,Filters\Filter,Lenses\Lens:$nameMetrics\TrendResult:$prefix,$suffix,$formatNova assigns them through the constructor, a setter, or reflection — never at declaration — so every concrete subclass that does not redeclare them is reported
PropertyNotSetInConstructorin the consuming project.Fix
In
afterCodebasePopulated, mark each such property as initialised on the class that declares it.ClassAnalyzer::checkPropertyInitializationreads that flag from the declaring class, so the report is silenced on every subclass that inherits the property, while a subclass's own uninitialised typed property still flags.This is deliberately chosen over the two alternatives:
public $name = ''): the runtime value is never that — it would be fiction, and it also collapses union types / tripsNonInvariantPropertyTypeon subclasses that legitimately redeclarepublic $name = 'Label'.PropertyNotSetInConstructoris emitted with the concrete class's suppression list, so suppressing would be all-or-nothing and would hide a subclass's genuine unset-property bugs.The mutation is routed through a small helper taking the storage as a parameter so its side effect is visible to Psalm's purity analysis (mirrors the existing
suppress()helper), avoiding a falseMissingPureAnnotation.Impact
Measured on IxDF-web (single-threaded cold runs, baseline ignored, before vs after): -47
PropertyNotSetInConstructor, 0 new issues. Covers Fields, Actions, Metrics, Filters, Lenses and TrendResult subclasses.Local
phpcsandpsalmpass.(Branch name
feat/nova-property-not-set-stubspredates the final approach, which uses the handler rather than stubs.)