Commit 6a3d729
committed
feat(stubs): default convention props to fix PropertyNotSetInConstructor
Nova base classes declare display/attribute props via a `@var` docblock
with no default (`$name`, `$attribute`, `$resource` on Field; `$name` on
Action/Metric/Filter; `$prefix`/`$suffix`/`$format` on TrendResult), so
every concrete subclass that omits its own copy is flagged with
PropertyNotSetInConstructor.
Declare each prop WITH a default on the base-class stub. addStubFile
merges (the stub member wins, real members are kept), so the default
flips `has_default` and the initialization check is skipped for every
subclass that inherits it.
Two constraints drive the shape of these stubs:
- `$name` on Action/Metric/Filter is declared UNTYPED (type in `@var`
only). Subclasses conventionally write `public $name = 'Label'`
untyped; a native signature type on the parent makes each of those
NonInvariantPropertyType. Field's `$name`/`$attribute` have no such
untyped redeclarers, so a native `string` is safe there.
- The new Filter/Metric/TrendResult stubs restate the full real
hierarchy (extends/implements/use). addStubFile replaces the class
signature, so omitting `implements FilterContract` would strip it and
make every `Resource::filters()` raise ImplementedReturnTypeMismatch.
A Lens stub is intentionally not added: it surfaces a MethodSignatureMismatch
on subclasses that widen the `query()` builder param (PHP-legal
contravariance that Psalm only enforces against stub parents, not vendor
parents), which is not worth the few fixes it would provide.
Net on the consuming project: -37 PropertyNotSetInConstructor, no new issues.1 parent c15b713 commit 6a3d729
6 files changed
Lines changed: 84 additions & 0 deletions
File tree
- src
- stubs/Nova
- Actions
- Fields
- Filters
- Metrics
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
| 37 | + | |
36 | 38 | | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
18 | 27 | | |
19 | 28 | | |
20 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
26 | 31 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
0 commit comments