@@ -274,21 +274,36 @@ protected function registerProperties()
274274
275275 $ shortName = (new ReflectionClass ($ this ))->getShortName ();
276276
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+
277290 // Check the registrar class for a method named after this class' shortName
278291 foreach (static ::$ registrars as $ callable ) {
279292 // ignore non-applicable registrars
280293 if (! method_exists ($ callable , $ shortName )) {
281294 continue ; // @codeCoverageIgnore
282295 }
283296
284- $ properties = $ callable ::$ shortName ();
297+ $ currentProps = static ::$ moduleConfig ->registrarHasData ? $ worker ->getProperties ($ this ) : [];
298+ $ properties = $ callable ::$ shortName ($ currentProps );
285299
286300 if (! is_array ($ properties )) {
287301 throw new RuntimeException ('Registrars must return an array of properties and their values. ' );
288302 }
289303
290304 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 ) {
292307 $ this ->{$ property } = array_merge ($ this ->{$ property }, $ value );
293308 } else {
294309 $ this ->{$ property } = $ value ;
0 commit comments