mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-23 22:03:39 +00:00
Improve PHP class references
* Declare class names from other namespaces in the `use` block. * Use Foo::class instead of 'Foo' to reference a class name. Change-Id: I5a1aba6b0cc8842d71b6b6df0a0b67e16e5b6453
This commit is contained in:
parent
bb87e3d2de
commit
e85265ada5
|
@ -23,7 +23,11 @@ use MediaWiki\Config\ServiceOptions;
|
|||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Minerva\LanguagesHelper;
|
||||
use MediaWiki\Minerva\Menu\Definitions;
|
||||
use MediaWiki\Minerva\Menu\PageActions as PageActionsMenu;
|
||||
use MediaWiki\Minerva\Menu\PageActions\DefaultOverflowBuilder;
|
||||
use MediaWiki\Minerva\Menu\PageActions\EmptyOverflowBuilder;
|
||||
use MediaWiki\Minerva\Menu\PageActions\PageActionsDirector;
|
||||
use MediaWiki\Minerva\Menu\PageActions\ToolbarBuilder;
|
||||
use MediaWiki\Minerva\Menu\PageActions\UserNamespaceOverflowBuilder;
|
||||
use MediaWiki\Minerva\Permissions\IMinervaPagePermissions;
|
||||
use MediaWiki\Minerva\Permissions\MinervaPagePermissions;
|
||||
use MediaWiki\Minerva\SkinOptions;
|
||||
|
@ -38,7 +42,7 @@ return [
|
|||
);
|
||||
},
|
||||
'Minerva.Menu.PageActionsDirector' =>
|
||||
static function ( MediaWikiServices $services ): PageActionsMenu\PageActionsDirector {
|
||||
static function ( MediaWikiServices $services ): PageActionsDirector {
|
||||
/**
|
||||
* @var SkinOptions $skinOptions
|
||||
* @var SkinMinerva $skin
|
||||
|
@ -65,7 +69,7 @@ return [
|
|||
|
||||
$watchlistManager = $services->getWatchlistManager();
|
||||
|
||||
$toolbarBuilder = new PageActionsMenu\ToolbarBuilder(
|
||||
$toolbarBuilder = new ToolbarBuilder(
|
||||
$title,
|
||||
$user,
|
||||
$context,
|
||||
|
@ -73,28 +77,28 @@ return [
|
|||
$skinOptions,
|
||||
$userPageHelper,
|
||||
$languagesHelper,
|
||||
new ServiceOptions( PageActionsMenu\ToolbarBuilder::CONSTRUCTOR_OPTIONS,
|
||||
new ServiceOptions( ToolbarBuilder::CONSTRUCTOR_OPTIONS,
|
||||
$services->getMainConfig() ),
|
||||
$watchlistManager
|
||||
);
|
||||
if ( $skinOptions->get( SkinOptions::TOOLBAR_SUBMENU ) ) {
|
||||
$overflowBuilder = $userPageHelper->isUserPage() ?
|
||||
new PageActionsMenu\UserNamespaceOverflowBuilder(
|
||||
new UserNamespaceOverflowBuilder(
|
||||
$title,
|
||||
$context,
|
||||
$permissions,
|
||||
$languagesHelper
|
||||
) :
|
||||
new PageActionsMenu\DefaultOverflowBuilder(
|
||||
new DefaultOverflowBuilder(
|
||||
$title,
|
||||
$context,
|
||||
$permissions
|
||||
);
|
||||
} else {
|
||||
$overflowBuilder = new PageActionsMenu\EmptyOverflowBuilder();
|
||||
$overflowBuilder = new EmptyOverflowBuilder();
|
||||
}
|
||||
|
||||
return new PageActionsMenu\PageActionsDirector(
|
||||
return new PageActionsDirector(
|
||||
$toolbarBuilder,
|
||||
$overflowBuilder,
|
||||
$context
|
||||
|
|
|
@ -25,6 +25,7 @@ use MediaWiki\Minerva\Hooks\HookRunner;
|
|||
use MediaWiki\Minerva\Skins\SkinMinerva;
|
||||
use MediaWiki\Minerva\Skins\SkinUserPageHelper;
|
||||
use MobileContext;
|
||||
use OutOfBoundsException;
|
||||
use Skin;
|
||||
|
||||
/**
|
||||
|
@ -99,7 +100,7 @@ final class SkinOptions {
|
|||
public function setMultiple( array $options ) {
|
||||
foreach ( $options as $option => $value ) {
|
||||
if ( !array_key_exists( $option, $this->skinOptions ) ) {
|
||||
throw new \OutOfBoundsException( "SkinOption $option is not defined" );
|
||||
throw new OutOfBoundsException( "SkinOption $option is not defined" );
|
||||
}
|
||||
}
|
||||
$this->skinOptions = array_merge( $this->skinOptions, $options );
|
||||
|
@ -112,7 +113,7 @@ final class SkinOptions {
|
|||
*/
|
||||
public function get( $key ) {
|
||||
if ( !array_key_exists( $key, $this->skinOptions ) ) {
|
||||
throw new \OutOfBoundsException( "SkinOption $key doesn't exist" );
|
||||
throw new OutOfBoundsException( "SkinOption $key doesn't exist" );
|
||||
}
|
||||
return $this->skinOptions[$key];
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace MediaWiki\Minerva\Skins;
|
||||
|
||||
use MediaWiki\Request\WebRequest;
|
||||
use MediaWiki\Skins\Vector\ConfigHelper;
|
||||
use MediaWiki\Title\Title;
|
||||
|
||||
class FeaturesHelper {
|
||||
|
@ -27,8 +28,8 @@ class FeaturesHelper {
|
|||
* @internal only for use inside tests.
|
||||
*/
|
||||
public function shouldDisableNightMode( array $options, WebRequest $request, Title $title = null ) {
|
||||
return class_exists( 'MediaWiki\Skins\Vector\ConfigHelper' ) ?
|
||||
\MediaWiki\Skins\Vector\ConfigHelper::shouldDisable(
|
||||
$options, $request, $title ) : false;
|
||||
return class_exists( ConfigHelper::class ) ?
|
||||
ConfigHelper::shouldDisable( $options, $request, $title ) :
|
||||
false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ use MediaWiki\Minerva\Skins\FeaturesHelper;
|
|||
use MediaWiki\Request\WebRequest;
|
||||
use MediaWiki\Title\Title;
|
||||
use MediaWikiIntegrationTestCase;
|
||||
use RequestContext;
|
||||
|
||||
/**
|
||||
* @group MinervaNeue
|
||||
|
@ -25,9 +26,9 @@ class FeaturesHelperTest extends MediaWikiIntegrationTestCase {
|
|||
]
|
||||
]
|
||||
];
|
||||
$context = new \RequestContext();
|
||||
$context = new RequestContext();
|
||||
$request = $context->getRequest();
|
||||
$editContext = new \RequestContext();
|
||||
$editContext = new RequestContext();
|
||||
$editRequest = $context->getRequest();
|
||||
$editRequest->setVal( 'action', 'edit' );
|
||||
$mainTitle = Title::makeTitle( NS_MAIN, 'Main Page' );
|
||||
|
@ -67,7 +68,7 @@ class FeaturesHelperTest extends MediaWikiIntegrationTestCase {
|
|||
]
|
||||
]
|
||||
];
|
||||
$context = new \RequestContext();
|
||||
$context = new RequestContext();
|
||||
$request = $context->getRequest();
|
||||
$includedTitle = Title::makeTitle( NS_MAIN, 'Included Page' );
|
||||
$featuresHelper = new FeaturesHelper();
|
||||
|
|
Loading…
Reference in a new issue