@@ -276,21 +276,36 @@ protected function registerProperties()
276
276
277
277
$ shortName = (new ReflectionClass ($ this ))->getShortName ();
278
278
279
+ if (static ::$ moduleConfig ->registrarHasData ) {
280
+ // Get all public properties for this config
281
+ $ worker = new class () {
282
+ /**
283
+ * @return array<string, mixed>
284
+ */
285
+ public function getProperties (BaseConfig $ obj ): array
286
+ {
287
+ return get_object_vars ($ obj );
288
+ }
289
+ };
290
+ }
291
+
279
292
// Check the registrar class for a method named after this class' shortName
280
293
foreach (static ::$ registrars as $ callable ) {
281
294
// ignore non-applicable registrars
282
295
if (! method_exists ($ callable , $ shortName )) {
283
296
continue ; // @codeCoverageIgnore
284
297
}
285
298
286
- $ properties = $ callable ::$ shortName ();
299
+ $ currentProps = static ::$ moduleConfig ->registrarHasData ? $ worker ->getProperties ($ this ) : [];
300
+ $ properties = $ callable ::$ shortName ($ currentProps );
287
301
288
302
if (! is_array ($ properties )) {
289
303
throw new RuntimeException ('Registrars must return an array of properties and their values. ' );
290
304
}
291
305
292
306
foreach ($ properties as $ property => $ value ) {
293
- if (isset ($ this ->{$ property }) && is_array ($ this ->{$ property }) && is_array ($ value )) {
307
+ // TODO: The array check can be removed if the option `registrarHasData` is accepted.
308
+ if (isset ($ this ->{$ property }) && is_array ($ this ->{$ property }) && is_array ($ value ) && ! static ::$ moduleConfig ->registrarHasData ) {
294
309
$ this ->{$ property } = array_merge ($ this ->{$ property }, $ value );
295
310
} else {
296
311
$ this ->{$ property } = $ value ;
0 commit comments