Commit 69271cf
committed
bug #63478 [Config] Fix ArrayShapeGenerator required keys with deep merging (lacatoire)
This PR was squashed before being merged into the 7.4 branch.
Discussion
----------
[Config] Fix ArrayShapeGenerator required keys with deep merging
| Q | A
| ------------- | ---
| Branch? | 7.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | -
| License | MIT
## Summary
When configuration is deep-merged across files, a required node only needs to be present after the merge, not in every individual file. The `ArrayShapeGenerator` was marking all required keys as non-optional (`node: type`) in the generated array shape, which made PHPStan complain when a required key (e.g. `resource` in `router`) was not set in every single config file.
This PR marks required keys as optional (`node?: type`) in the array shape when the parent node performs deep merging (the default behavior). Only when the parent explicitly disables deep merging (`performNoDeepMerging()`) are required keys kept non-optional.
### Changes
- Add `ArrayNode::shouldPerformDeepMerging()` getter
- Update `ArrayShapeGenerator::dumpNodeKey()` to account for the parent's deep merging setting
- Update existing test and add a new test for the `performNoDeepMerging()` case
Commits
-------
7c05f4ab67c [Config] Fix ArrayShapeGenerator required keys with deep mergingFile tree
3 files changed
+25
-3
lines changed- Definition
- Tests/Definition
3 files changed
+25
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
129 | 137 | | |
130 | 138 | | |
131 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
108 | 120 | | |
109 | 121 | | |
110 | 122 | | |
| |||
0 commit comments