Skip to content

Commit

Permalink
Merge pull request #34 from hallowelt/CS
Browse files Browse the repository at this point in the history
CS
  • Loading branch information
HamishSlater authored Nov 27, 2023
2 parents ba4841f + 4ea2a3e commit c5882de
Show file tree
Hide file tree
Showing 139 changed files with 537 additions and 527 deletions.
2 changes: 1 addition & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
define( 'MWSTAKE_MEDIAWIKI_COMPONENT_COMMONUSERINTERFACE_VERSION', '3.2.4' );

MWStake\MediaWiki\ComponentLoader\Bootstrapper::getInstance()
->register( 'commonuserinterface', function () {
->register( 'commonuserinterface', static function () {
$lessVars = \MWStake\MediaWiki\Component\CommonUserInterface\LessVars::getInstance();

// Provide the list of values
Expand Down
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
}
],
"require": {
"composer/installers": "~1.0|~2",
"mwstake/mediawiki-componentloader": "~1"
},
"require-dev": {
"jakub-onderka/php-parallel-lint": "1.0.0",
"jakub-onderka/php-console-highlighter": "0.4.0",
"mediawiki/mediawiki-codesniffer": "29.0.0",
"mediawiki/minus-x": "1.0.0",
"mediawiki/mediawiki-codesniffer": "39.0.0",
"mediawiki/minus-x": "1.1.1",
"php-parallel-lint/php-console-highlighter": "1.0.0",
"php-parallel-lint/php-parallel-lint": "1.3.2",
"phpunit/phpunit": "^8.5"
},
"autoload": {
Expand All @@ -41,5 +42,10 @@
"minus-x fix .",
"phpcbf"
]
},
"config": {
"allow-plugins": {
"composer/installers": true
}
}
}
22 changes: 11 additions & 11 deletions includes/ServiceWiring.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
use MWStake\MediaWiki\Component\CommonUserInterface\TreeDataGenerator;

return [
'MWStakeCommonUISkinSlotRendererFactory' => function ( MediaWikiServices $services ) {
'MWStakeCommonUISkinSlotRendererFactory' => static function ( MediaWikiServices $services ) {
return new SkinSlotRendererFactory(
$GLOBALS['mwsgCommonUISkinSlotRenderers'],
$services->getObjectFactory()
);
},

'MWStakeCommonUIComponentManager' => function ( MediaWikiServices $services ) {
'MWStakeCommonUIComponentManager' => static function ( MediaWikiServices $services ) {
$componentManager = ComponentManager::singleton(
RequestContext::getMain(),
$GLOBALS['mwsgCommonUISkinSlots'],
Expand All @@ -34,7 +34,7 @@
return $componentManager;
},

'MWStakeCommonUIComponentRendererFactory' => function ( MediaWikiServices $services ) {
'MWStakeCommonUIComponentRendererFactory' => static function ( MediaWikiServices $services ) {
return new ComponentRendererFactory(
$GLOBALS['mwsgCommonUIComponentRendererRegistry'],
$GLOBALS['mwsgCommonUIComponentRegistry'],
Expand All @@ -43,24 +43,24 @@
);
},

'MWStakeCommonUIRendererDataTreeBuilder' => function ( MediaWikiServices $services ) {
'MWStakeCommonUIRendererDataTreeBuilder' => static function ( MediaWikiServices $services ) {
return new RendererDataTreeBuilder(
$services->getService( 'MWStakeCommonUIComponentRendererFactory' )
);
},

'MWStakeCommonUIRendererDataTreeRenderer' => function ( MediaWikiServices $services ) {
'MWStakeCommonUIRendererDataTreeRenderer' => static function ( MediaWikiServices $services ) {
return new RendererDataTreeRenderer(
$services->getService( 'MWStakeCommonUIComponentRendererFactory' )
);
},

'MWStakeCommonUIHtmlIdRegistry' => function ( MediaWikiServices $services ) {
'MWStakeCommonUIHtmlIdRegistry' => static function ( MediaWikiServices $services ) {
$registry = HtmlIdRegistry::singleton();
return $registry;
},

'MWStakeCommonUIGenericComponentRenderer' => function ( MediaWikiServices $services ) {
'MWStakeCommonUIGenericComponentRenderer' => static function ( MediaWikiServices $services ) {
$renderer = new GenericComponentRenderer(
$services->get( 'MWStakeCommonUIComponentManager' ),
$services->get( 'MWStakeCommonUIRendererDataTreeBuilder' ),
Expand All @@ -69,29 +69,29 @@
return $renderer;
},

'MWStakeSkinSlotRegistry' => function ( MediaWikiServices $services ) {
'MWStakeSkinSlotRegistry' => static function ( MediaWikiServices $services ) {
$skinSlotRegistry = SkinSlotRegistry::singleton(
$GLOBALS['mwsgCommonUISkinSlots']
);
return $skinSlotRegistry;
},

'MWStakeLinkFormatter' => function ( MediaWikiServices $services ) {
'MWStakeLinkFormatter' => static function ( MediaWikiServices $services ) {
$linkFormatter = new LinkFormatter(
$services->getMainConfig()->get( 'ExternalLinkTarget' ),
$services->getMainConfig()->get( 'NoFollowLinks' )
);
return $linkFormatter;
},

'MWStakeCommonUITreeDataGenerator' => function ( MediaWikiServices $services ) {
'MWStakeCommonUITreeDataGenerator' => static function ( MediaWikiServices $services ) {
return new TreeDataGenerator(
$GLOBALS['mwsgCommonUIComponentTreeNodeRegistry'],
$services->getObjectFactory()
);
},

'MWStakeCommonUIComponentFilterFactory' => function ( MediaWikiServices $services ) {
'MWStakeCommonUIComponentFilterFactory' => static function ( MediaWikiServices $services ) {
return new ComponentFilterFactory(
$GLOBALS['mwsgCommonUIComponentFilters'],
$services->getObjectFactory()
Expand Down
4 changes: 2 additions & 2 deletions src/AriaAttributesBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static function factory() {
* @param array $data
* @return array
*/
public function build( $data ) : array {
public function build( $data ): array {
$attribs = [];

foreach ( $data as $key => $value ) {
Expand All @@ -35,7 +35,7 @@ public function build( $data ) : array {
* @param array $data
* @return string
*/
public function toString( $data ) : string {
public function toString( $data ): string {
$attribs = $this->build( $data );

return implode( ' ', $attribs );
Expand Down
6 changes: 3 additions & 3 deletions src/Component/Badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ public function __construct( $options ) {
/**
* @inheritDoc
*/
public function getId() : string {
public function getId(): string {
return $this->options['id'];
}

/**
* @inheritDoc
*/
public function getClasses() : array {
public function getClasses(): array {
return $this->options['classes'];
}

/**
* @inheritDoc
*/
public function getText() : Message {
public function getText(): Message {
return $this->options['text'];
}
}
4 changes: 2 additions & 2 deletions src/Component/CallbackLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct( $id, $callback ) {
/**
* @inheritDoc
*/
public function getId() : string {
public function getId(): string {
return $this->id;
}

Expand All @@ -40,7 +40,7 @@ public function getId() : string {
*
* @return string
*/
public function getHtml() : string {
public function getHtml(): string {
return call_user_func_array( $this->callback, [ $this->componentProcessData ] );
}
}
10 changes: 5 additions & 5 deletions src/Component/ComponentBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@ abstract class ComponentBase implements IComponent {
*
* @inheritDoc
*/
public function getRequiredRLModules() : array {
public function getRequiredRLModules(): array {
return [];
}

/**
*
* @inheritDoc
*/
public function getRequiredRLStyles() : array {
public function getRequiredRLStyles(): array {
return [];
}

/**
*
* @inheritDoc
*/
public function getSubComponents() : array {
public function getSubComponents(): array {
return [];
}

/**
*
* @inheritDoc
*/
public function shouldRender( IContextSource $context ) : bool {
public function shouldRender( IContextSource $context ): bool {
return true;
}

Expand All @@ -51,7 +51,7 @@ public function shouldRender( IContextSource $context ) : bool {
* Usually this is SkinTemplate's `$tpl->data`
* @return void
*/
public function setComponentData( $data ) : void {
public function setComponentData( $data ): void {
$this->componentProcessData = $data;
}
}
4 changes: 2 additions & 2 deletions src/Component/Literal.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct( $id, $html ) {
/**
* @inheritDoc
*/
public function getId() : string {
public function getId(): string {
return $this->id;
}

Expand All @@ -40,7 +40,7 @@ public function getId() : string {
*
* @return string
*/
public function getHtml() : string {
public function getHtml(): string {
return $this->html;
}
}
4 changes: 2 additions & 2 deletions src/Component/MessageLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public function __construct( $id, $msg ) {
/**
* @inheritDoc
*/
public function getId() : string {
public function getId(): string {
return $this->id;
}

/**
*
* @return Message
*/
public function getText() : Message {
public function getText(): Message {
return $this->msg;
}
}
4 changes: 2 additions & 2 deletions src/Component/NullComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public function __construct( $id = 'null-component' ) {
/**
* @return string
*/
public function getId() : string {
public function getId(): string {
return $this->id;
}

/**
* @param IContextSource $context
* @return bool
*/
public function shouldRender( IContextSource $context ) : bool {
public function shouldRender( IContextSource $context ): bool {
return false;
}
}
22 changes: 11 additions & 11 deletions src/Component/RestrictedTextLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,78 +35,78 @@ public function __construct( $options ) {
/**
* @inheritDoc
*/
public function getId() : string {
public function getId(): string {
return $this->options['id'];
}

/**
* @inheritDoc
*/
public function getClasses() : array {
public function getClasses(): array {
return $this->options['classes'];
}

/**
* @inheritDoc
*/
public function getRole() : string {
public function getRole(): string {
return $this->options['role'];
}

/**
* @inheritDoc
*/
public function getText() : Message {
public function getText(): Message {
return $this->options['text'];
}

/**
* @inheritDoc
*/
public function getTitle() : Message {
public function getTitle(): Message {
return $this->options['title'];
}

/**
* @inheritDoc
*/
public function getAriaLabel() : Message {
public function getAriaLabel(): Message {
return $this->options['aria-label'];
}

/**
* @inheritDoc
*/
public function getDataAttributes() : array {
public function getDataAttributes(): array {
return $this->options['data'];
}

/**
* @inheritDoc
*/
public function getAriaAttributes() : array {
public function getAriaAttributes(): array {
return $this->options['aria'];
}

/**
* @inheritDoc
*/
public function getHref() : string {
public function getHref(): string {
return $this->options['href'];
}

/**
* @inheritDoc
*/
public function getRel() : string {
public function getRel(): string {
return $this->options['rel'];
}

/**
*
* @return array
*/
public function getPermissions() : array {
public function getPermissions(): array {
return $this->options['permissions'];
}
}
4 changes: 2 additions & 2 deletions src/Component/SimpleAccordion.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public function __construct( $options ) {
/**
* @inheritDoc
*/
public function getId() : string {
public function getId(): string {
return $this->options['id'];
}

/**
* @inheritDoc
*/
public function getSubComponents() : array {
public function getSubComponents(): array {
return $this->options['items'];
}
}
Loading

0 comments on commit c5882de

Please sign in to comment.