refactor(core): ♻️ fix various phpcs issues

This commit is contained in:
alistair3149 2024-11-04 18:41:17 -05:00
parent 7b9522b395
commit 4e48a19503
No known key found for this signature in database
7 changed files with 23 additions and 68 deletions

View file

@ -40,12 +40,6 @@ class ApiWebappManifest extends ApiBase {
/* 1 week */
private const CACHE_MAX_AGE = 604800;
/**
* Constructor
*/
public function __construct() {
}
/**
* Execute the requested Api actions.
*/
@ -124,6 +118,11 @@ class ApiWebappManifest extends ApiBase {
return $icons;
}
/**
* Get src, sizes, and type for each icon for the manifest
*
* @return array|null
*/
private function getIconData( $logoPath, $logoContent ) {
$imageSize = getimagesizefromstring( $logoContent );
if ( $imageSize !== false ) {

View file

@ -38,9 +38,9 @@ class CitizenComponentPageHeading implements CitizenComponent {
/**
* @param MessageLocalizer $localizer
* @param OutputPage $out
* @param Language|StubUserLang $pageLang
* @param Title $title
* @param OutputPage $out
* @param string $titleData
* @param UserIdentity $user
*/
@ -192,7 +192,13 @@ class CitizenComponentPageHeading implements CitizenComponent {
return $localizer->msg( 'citizen-tagline-ns-talk' )->parse();
}
$isRootUserPage = $title->inNamespace( NS_USER ) || ( defined( 'NS_USER_WIKI' ) && $title->inNamespace( NS_USER_WIKI ) ) || ( defined( 'NS_USER_WIKI' ) && $title->inNamespace( NS_USER_PROFILE ) ) && !$title->isSubpage();
$isRootUserPage = (
$title->inNamespace( NS_USER ) ||
( defined( 'NS_USER_WIKI' ) && $title->inNamespace( NS_USER_WIKI ) ) ||
( defined( 'NS_USER_WIKI' ) && $title->inNamespace( NS_USER_PROFILE ) )
) &&
!$title->isSubpage();
if ( $isRootUserPage ) {
// Build user tagline if it is a top-level user page
return $this->buildUserTagline();

View file

@ -43,8 +43,8 @@ class CitizenComponentPageTools implements CitizenComponent {
/**
* @param Config $config
* @param MessageLocalizer $localizer
* @param UserIdentity $user
* @param Title $title
* @param UserIdentity $user
* @param int $numLanguages
* @param array $sidebarData
* @param array $languagesData
@ -137,10 +137,9 @@ class CitizenComponentPageTools implements CitizenComponent {
* @inheritDoc
*/
public function getTemplateData(): array {
$hasLanguages = (
$this->languagesData && $this->languagesData[ 'is-empty'] !== true ||
$this->variantsData && $this->variantsData[ 'is-empty'] !== true
);
$hasLanguages =
( $this->languagesData && $this->languagesData[ 'is-empty' ] !== true ) ||
( $this->variantsData && $this->variantsData[ 'is-empty' ] !== true );
$articleTools = $this->getArticleToolsData();
return [

View file

@ -19,21 +19,16 @@ class CitizenComponentSearchBox implements CitizenComponent {
/** @var array */
private $searchBoxData;
/** @var Skin */
private $skin;
/**
* @param MessageLocalizer $localizer
* @param array $searchBoxData
*/
public function __construct(
MessageLocalizer $localizer,
array $searchBoxData,
Skin $skin
array $searchBoxData
) {
$this->localizer = $localizer;
$this->searchBoxData = $searchBoxData;
$this->skin = $skin;
}
/**
@ -74,13 +69,14 @@ class CitizenComponentSearchBox implements CitizenComponent {
*/
public function getTemplateData(): array {
$searchBoxData = $this->searchBoxData;
$randompageUrl = SpecialPage::getTitleFor( 'Randompage' )->getLocalURL();
return $searchBoxData += [
'array-keyboard-hint' => $this->getKeyboardHintData(),
'msg-citizen-search-footer' => $this->getFooterMessage(),
'msg-citizen-search-toggle-shortcut' => '[/]',
// TODO: Replace with SkinComponentUtils on 1.43
'html-random-href' => SpecialPage::getTitleFor( 'Randompage' )->getLocalURL(),
'html-random-href' => $randompageUrl,
];
}
}

View file

@ -34,13 +34,7 @@ class CitizenComponentSiteStats implements CitizenComponent {
];
/**
* @return Config
*/
private function getConfig(): Config {
return $this->config;
}
/**
* @param Config $config
* @param MessageLocalizer $localizer
* @param Language|StubUserLang $pageLang
*/
@ -75,7 +69,7 @@ class CitizenComponentSiteStats implements CitizenComponent {
* @inheritDoc
*/
public function getTemplateData(): array {
$config = $this->getConfig();
$config = $this->config;
if ( !$config->get( 'CitizenEnableDrawerSiteStats' ) ) {
return [];
}

View file

@ -143,8 +143,7 @@ class SkinCitizen extends SkinMustache {
),
'data-search-box' => new CitizenComponentSearchBox(
$localizer,
$parentData['data-search-box'],
$this
$parentData['data-search-box']
),
'data-site-stats' => new CitizenComponentSiteStats(
$config,

View file

@ -1,38 +0,0 @@
<?php
declare( strict_types=1 );
namespace MediaWiki\Skins\Citizen\Components;
/**
* CitizenComponentMenuListItem component
*/
class CitizenComponentMenuListItem implements CitizenComponent {
/** @var CitizenComponentLink */
private $link;
/** @var string */
private $class;
/** @var string */
private $id;
/**
* @param CitizenComponentLink $link
* @param string $class
* @param string $id
*/
public function __construct( CitizenComponentLink $link, string $class = '', string $id = '' ) {
$this->link = $link;
$this->class = $class;
$this->id = $id;
}
/**
* @inheritDoc
*/
public function getTemplateData(): array {
return $this->link->getTemplateData() + [
'item-class' => $this->class,
'item-id' => $this->id,
];
}
}