Normalise PHP namespaces used in Vector

- `MediaWiki\Skins\Vector\Tests` is now the prefix for all tests in the skin
- we followed PSR conventions of following folder structure after the prefix
- Optimize imports/use order
- update namespace in skin.json

Bug: T303102
Change-Id: Ib76374d81d973c83adfd6c8e7863ff6d797e655d
This commit is contained in:
Mo Abualruz 2022-05-23 09:32:40 +02:00
parent 80fc9dcace
commit e46eef19d0
21 changed files with 63 additions and 60 deletions

View file

@ -1,5 +1,5 @@
<?php
namespace Vector;
namespace MediaWiki\Skins\Vector;
use FatalError;

View file

@ -20,9 +20,9 @@
* @since 1.35
*/
namespace Vector\FeatureManagement;
namespace MediaWiki\Skins\Vector\FeatureManagement;
use Vector\FeatureManagement\Requirements\SimpleRequirement;
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\SimpleRequirement;
use Wikimedia\Assert\Assert;
/**
@ -33,7 +33,7 @@ use Wikimedia\Assert\Assert;
*
* @unstable
*
* @package Vector\FeatureManagement
* @package MediaWiki\Skins\Vector\FeatureManagement
* @internal
*/
final class FeatureManager {

View file

@ -20,7 +20,7 @@
* @since 1.35
*/
namespace Vector\FeatureManagement;
namespace MediaWiki\Skins\Vector\FeatureManagement;
/**
* NOTE: This API hasn't settled. It may change at any time without warning. Please don't bind to
@ -28,7 +28,7 @@ namespace Vector\FeatureManagement;
*
* @unstable
*
* @package Vector\FeatureManagement
* @package MediaWiki\Skins\Vector\FeatureManagement
* @internal
*/
interface Requirement {

View file

@ -20,9 +20,9 @@
* @since 1.35
*/
namespace Vector\FeatureManagement\Requirements;
namespace MediaWiki\Skins\Vector\FeatureManagement\Requirements;
use Vector\FeatureManagement\Requirement;
use MediaWiki\Skins\Vector\FeatureManagement\Requirement;
/**
* Some application state changes throughout the lifetime of the application, e.g. `wgSitename` or
@ -61,7 +61,7 @@ use Vector\FeatureManagement\Requirement;
*
* @unstable
*
* @package Vector\FeatureManagement\Requirements
* @package MediaWiki\Skins\Vector\FeatureManagement\Requirements
* @internal
*/
final class DynamicConfigRequirement implements Requirement {

View file

@ -19,12 +19,12 @@
* @file
*/
namespace Vector\FeatureManagement\Requirements;
namespace MediaWiki\Skins\Vector\FeatureManagement\Requirements;
use CentralIdLookup;
use Config;
use MediaWiki\Skins\Vector\FeatureManagement\Requirement;
use User;
use Vector\FeatureManagement\Requirement;
use WebRequest;
/**
@ -63,7 +63,7 @@ use WebRequest;
* NOTE: This API hasn't settled. It may change at any time without warning. Please don't bind to
* it unless you absolutely need to
*
* @package Vector\FeatureManagement\Requirements
* @package MediaWiki\Skins\Vector\FeatureManagement\Requirements
*/
final class OverridableConfigRequirement implements Requirement {

View file

@ -20,9 +20,9 @@
* @since 1.35
*/
namespace Vector\FeatureManagement\Requirements;
namespace MediaWiki\Skins\Vector\FeatureManagement\Requirements;
use Vector\FeatureManagement\Requirement;
use MediaWiki\Skins\Vector\FeatureManagement\Requirement;
/**
* NOTE: This API hasn't settled. It may change at any time without warning. Please don't bind to
@ -30,7 +30,7 @@ use Vector\FeatureManagement\Requirement;
*
* @unstable
*
* @package Vector\FeatureManagement\Requirements
* @package MediaWiki\Skins\Vector\FeatureManagement\Requirements
* @internal
*/
class SimpleRequirement implements Requirement {

View file

@ -1,6 +1,6 @@
<?php
namespace Vector;
namespace MediaWiki\Skins\Vector;
use Config;
use MediaWiki\Auth\Hook\LocalUserCreatedHook;

View file

@ -1,10 +1,10 @@
<?php
namespace Vector\ResourceLoader;
namespace MediaWiki\Skins\Vector\ResourceLoader;
use MediaWiki\Skins\Vector\Constants;
use ResourceLoaderContext;
use ResourceLoaderUserModule;
use Vector\Constants;
class VectorResourceLoaderUserModule extends ResourceLoaderUserModule {
/**

View file

@ -1,10 +1,10 @@
<?php
namespace Vector\ResourceLoader;
namespace MediaWiki\Skins\Vector\ResourceLoader;
use MediaWiki\Skins\Vector\Constants;
use ResourceLoaderContext;
use ResourceLoaderUserStylesModule;
use Vector\Constants;
class VectorResourceLoaderUserStylesModule extends ResourceLoaderUserStylesModule {
/**

View file

@ -23,10 +23,10 @@
*/
use MediaWiki\MediaWikiServices;
use Vector\Constants;
use Vector\FeatureManagement\FeatureManager;
use Vector\FeatureManagement\Requirements\DynamicConfigRequirement;
use Vector\FeatureManagement\Requirements\OverridableConfigRequirement;
use MediaWiki\Skins\Vector\Constants;
use MediaWiki\Skins\Vector\FeatureManagement\FeatureManager;
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\DynamicConfigRequirement;
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\OverridableConfigRequirement;
return [
Constants::SERVICE_FEATURE_MANAGER => static function ( MediaWikiServices $services ) {

View file

@ -1,6 +1,6 @@
<?php
namespace Vector\Services;
namespace MediaWiki\Skins\Vector\Services;
class LanguageService {
/**

View file

@ -22,7 +22,7 @@
* @ingroup Skins
*/
namespace Vector;
namespace MediaWiki\Skins\Vector;
use ExtensionRegistry;
use Html;

View file

@ -1,6 +1,6 @@
<?php
namespace Vector;
namespace MediaWiki\Skins\Vector;
use MediaWiki\MediaWikiServices;

View file

@ -1,6 +1,6 @@
<?php
namespace Vector;
namespace MediaWiki\Skins\Vector;
/**
* @ingroup Skins

View file

@ -1,10 +1,10 @@
<?php
namespace Vector;
namespace MediaWiki\Skins\Vector;
use MediaWiki\MediaWikiServices;
use Vector\FeatureManagement\FeatureManager;
use Vector\Services\LanguageService;
use MediaWiki\Skins\Vector\FeatureManagement\FeatureManager;
use MediaWiki\Skins\Vector\Services\LanguageService;
/**
* A service locator for services specific to Vector.

View file

@ -25,7 +25,7 @@
},
"ValidSkinNames": {
"vector-2022": {
"class": "Vector\\SkinVector22",
"class": "MediaWiki\\Skins\\Vector\\SkinVector22",
"args": [
{
"name": "vector-2022",
@ -78,7 +78,7 @@
]
},
"vector": {
"class": "Vector\\SkinVectorLegacy",
"class": "MediaWiki\\Skins\\Vector\\SkinVectorLegacy",
"@args": "See SkinVector::__construct for more detail.",
"args": [
{
@ -129,14 +129,17 @@
]
},
"AutoloadNamespaces": {
"Vector\\": "includes/"
"MediaWiki\\Skins\\Vector\\": "includes/"
},
"TestAutoloadNamespaces": {
"MediaWiki\\Skins\\Vector\\Tests\\": "tests/phpunit/"
},
"ConfigRegistry": {
"vector": "GlobalVarConfig::newInstance"
},
"HookHandlers": {
"VectorHooks": {
"class": "Vector\\Hooks"
"class": "MediaWiki\\Skins\\Vector\\Hooks"
}
},
"Hooks": {
@ -151,10 +154,10 @@
"@note": "When modifying skins.vector.styles definition, make sure the installer still works",
"ResourceModules": {
"skins.vector.user": {
"class": "Vector\\ResourceLoader\\VectorResourceLoaderUserModule"
"class": "MediaWiki\\Skins\\Vector\\ResourceLoader\\VectorResourceLoaderUserModule"
},
"skins.vector.user.styles": {
"class": "Vector\\ResourceLoader\\VectorResourceLoaderUserStylesModule"
"class": "MediaWiki\\Skins\\Vector\\ResourceLoader\\VectorResourceLoaderUserStylesModule"
},
"skins.vector.search": {
"es6": true,
@ -170,7 +173,7 @@
"resources/skins.vector.search/App.vue",
{
"name": "resources/skins.vector.search/config.json",
"callback": "Vector\\Hooks::getVectorWvuiSearchResourceLoaderConfig"
"callback": "MediaWiki\\Skins\\Vector\\Hooks::getVectorWvuiSearchResourceLoaderConfig"
}
],
"messages": [
@ -299,7 +302,7 @@
"resources/skins.vector.es6/linkHijack.js",
{
"name": "resources/skins.vector.es6/config.json",
"callback": "Vector\\Hooks::getVectorResourceLoaderConfig"
"callback": "MediaWiki\\Skins\\Vector\\Hooks::getVectorResourceLoaderConfig"
}
],
"dependencies": [
@ -316,7 +319,7 @@
"resources/skins.vector.js/skin.js",
{
"name": "resources/skins.vector.js/config.json",
"callback": "Vector\\Hooks::getVectorResourceLoaderConfig"
"callback": "MediaWiki\\Skins\\Vector\\Hooks::getVectorResourceLoaderConfig"
},
"resources/skins.vector.js/dropdownMenus.js",
"resources/skins.vector.js/sidebar.js",

View file

@ -4,12 +4,12 @@ namespace MediaWiki\Skins\Vector\Tests\Integration;
use Exception;
use HashConfig;
use MediaWiki\MediaWikiServices;
use MediaWiki\Skins\Vector\SkinVector22;
use MediaWiki\Skins\Vector\SkinVectorLegacy;
use MediaWikiIntegrationTestCase;
use ReflectionMethod;
use RequestContext;
use Title;
use Vector\SkinVector22;
use Vector\SkinVectorLegacy;
use Wikimedia\TestingAccessWrapper;
/**
@ -178,7 +178,7 @@ class SkinVectorTest extends MediaWikiIntegrationTestCase {
}
/**
* @covers \Vector\SkinVector22::getTocData
* @covers \MediaWiki\Skins\Vector\SkinVector22::getTocData
* @dataProvider provideGetTOCData
*/
public function testGetTocData(
@ -198,7 +198,7 @@ class SkinVectorTest extends MediaWikiIntegrationTestCase {
}
/**
* @covers \Vector\SkinVector::getTemplateData
* @covers \MediaWiki\Skins\Vector\SkinVector::getTemplateData
*/
public function testGetTemplateData() {
$title = Title::newFromText( 'SkinVector' );
@ -422,7 +422,7 @@ class SkinVectorTest extends MediaWikiIntegrationTestCase {
/**
* @dataProvider providerLanguageAlertRequirements
* @covers \Vector\SkinVector::shouldLanguageAlertBeInSidebar
* @covers \MediaWiki\Skins\Vector\SkinVector::shouldLanguageAlertBeInSidebar
* @param array $requirements
* @param Title $title
* @param array $getLanguagesCached

View file

@ -7,6 +7,10 @@
namespace MediaWiki\Skins\Vector\Tests\Integration;
use HashConfig;
use MediaWiki\Skins\Vector\Constants;
use MediaWiki\Skins\Vector\Hooks;
use MediaWiki\Skins\Vector\SkinVector22;
use MediaWiki\Skins\Vector\SkinVectorLegacy;
use MediaWiki\User\UserOptionsManager;
use MediaWikiIntegrationTestCase;
use ReflectionMethod;
@ -15,16 +19,12 @@ use ResourceLoaderContext;
use RuntimeException;
use Title;
use User;
use Vector\Constants;
use Vector\Hooks;
use Vector\SkinVector22;
use Vector\SkinVectorLegacy;
/**
* Integration tests for Vector Hooks.
*
* @group Vector
* @coversDefaultClass \Vector\Hooks
* @coversDefaultClass \MediaWiki\Skins\Vector\Hooks
*/
class VectorHooksTest extends MediaWikiIntegrationTestCase {

View file

@ -19,14 +19,14 @@
* @since 1.35
*/
namespace Vector\FeatureManagement\Tests;
namespace MediaWiki\Skins\Vector\Tests\Unit\FeatureManagement;
use Vector\FeatureManagement\FeatureManager;
use MediaWiki\Skins\Vector\FeatureManagement\FeatureManager;
/**
* @group Vector
* @group FeatureManagement
* @coversDefaultClass \Vector\FeatureManagement\FeatureManager
* @coversDefaultClass \MediaWiki\Skins\Vector\FeatureManagement\FeatureManager
*/
class FeatureManagerTest extends \MediaWikiUnitTestCase {

View file

@ -20,14 +20,14 @@
* @since 1.35
*/
namespace Vector\FeatureManagement\Tests;
namespace MediaWiki\Skins\Vector\Tests\Unit\FeatureManagement\Requirements;
use Vector\FeatureManagement\Requirements\DynamicConfigRequirement;
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\DynamicConfigRequirement;
/**
* @group Vector
* @group FeatureManagement
* @coversDefaultClass \Vector\FeatureManagement\Requirements\DynamicConfigRequirement
* @coversDefaultClass \MediaWiki\Skins\Vector\FeatureManagement\Requirements\DynamicConfigRequirement
*/
class DynamicConfigRequirementTest extends \MediaWikiUnitTestCase {

View file

@ -18,19 +18,19 @@
* @file
*/
namespace Vector\FeatureManagement\Tests;
namespace MediaWiki\Skins\Vector\Tests\Unit\FeatureManagement\Requirements;
use CentralIdLookup;
use HashConfig;
use MediaWiki\Skins\Vector\Constants;
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\OverridableConfigRequirement;
use User;
use Vector\Constants;
use Vector\FeatureManagement\Requirements\OverridableConfigRequirement;
use WebRequest;
/**
* @group Vector
* @group FeatureManagement
* @coversDefaultClass \Vector\FeatureManagement\Requirements\OverridableConfigRequirement
* @coversDefaultClass \MediaWiki\Skins\Vector\FeatureManagement\Requirements\OverridableConfigRequirement
*/
class OverridableConfigRequirementTest extends \MediaWikiUnitTestCase {