It would be useful if ValidSkinNames accepted ObjectFactory notation. Currently it only accepts "displayname => Class suffix" such as
"ValidSkinNames": { "monobook": "MonoBook" },
Which means no namespacing or other "complex" setup.
/** @suppress PhanTypeInvalidCallableArraySize - https://github.com/phan/phan/issues/1648 */ 'SkinFactory' => function ( MediaWikiServices $services ) : SkinFactory { $factory = new SkinFactory( $services->getObjectFactory() ); $names = $services->getMainConfig()->get( 'ValidSkinNames' ); foreach ( $names as $name => $skin ) { $factory->register( $name, $skin, [ 'class' => "Skin$skin" ] ); } // Register a hidden "fallback" skin $factory->register( 'fallback', 'Fallback', [ 'class' => SkinFallback::class ] ); // Register a hidden skin for api output $factory->register( 'apioutput', 'ApiOutput', [ 'class' => SkinApi::class ] ); return $factory; },
Simplest way forward seems to be replacing
foreach ( $names as $name => $skin ) { $factory->register( $name, $skin, [ 'class' => "Skin$skin" ] ); }
with something like (noting this won't work due to the display name needing to come from somewhere for is_array( $skin )
foreach ( $names as $name => $skin ) { if ( is_array( $skin ) ) { $spec = $skin; //$displayName = ??; } else { $displayName = $skin; $spec = [ 'class' => "Skin$skin" ]; } $factory->register( $name, $displayName, $spec ); }
Can we just add a display name to the objectfactory spec... And leave it? Or unset it when setting up here?
foreach ( $names as $name => $skin ) { if ( is_array( $skin ) ) { $spec = $skin; $displayName = $skin['DisplayName'] ?? $name; } else { $displayName = $skin; $spec = [ 'class' => "Skin$skin" ]; } $factory->register( $name, $displayName, $spec ); }