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