@@ -276,21 +276,36 @@ protected function registerProperties()
276276
277277 $ shortName = (new ReflectionClass ($ this ))->getShortName ();
278278
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+
279292 // Check the registrar class for a method named after this class' shortName
280293 foreach (static ::$ registrars as $ callable ) {
281294 // ignore non-applicable registrars
282295 if (! method_exists ($ callable , $ shortName )) {
283296 continue ; // @codeCoverageIgnore
284297 }
285298
286- $ properties = $ callable ::$ shortName ();
299+ $ currentProps = static ::$ moduleConfig ->registrarHasData ? $ worker ->getProperties ($ this ) : [];
300+ $ properties = $ callable ::$ shortName ($ currentProps );
287301
288302 if (! is_array ($ properties )) {
289303 throw new RuntimeException ('Registrars must return an array of properties and their values. ' );
290304 }
291305
292306 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 ) {
294309 $ this ->{$ property } = array_merge ($ this ->{$ property }, $ value );
295310 } else {
296311 $ this ->{$ property } = $ value ;
0 commit comments