Move all code to PSR-4 compatible namespaces

This patch does intentionally not touch any file name. Some of the
file names are a little weird now, e.g. \Cite\Cite. These can more
easily be renamed in later patches.

I used https://codesearch.wmflabs.org/search/?q=new%20Cite%5C( and it
looks like this code is not used anywhere else.

Change-Id: I5f93a224e9cacf45b7a0d68c216a78723364dd96
This commit is contained in:
Thiemo Kreuz 2019-11-19 15:12:11 +01:00
parent cf6e2baeab
commit ab3063fee5
19 changed files with 100 additions and 54 deletions

View file

@ -27,22 +27,22 @@
},
"APIPropModules": {
"references": {
"class": "ApiQueryReferences"
"class": "Cite\\Api\\ApiQueryReferences"
}
},
"Hooks": {
"ParserAfterParse": "CiteParserHooks::onParserAfterParse",
"ParserBeforeTidy": "CiteParserHooks::onParserBeforeTidy",
"ParserClearState": "CiteParserHooks::onParserClearState",
"ParserCloned": "CiteParserHooks::onParserCloned",
"ParserFirstCallInit": "CiteParserHooks::onParserFirstCallInit",
"ContentHandlerDefaultModelFor": "CiteHooks::onContentHandlerDefaultModelFor",
"ResourceLoaderTestModules": "CiteHooks::onResourceLoaderTestModules",
"ResourceLoaderRegisterModules": "CiteHooks::onResourceLoaderRegisterModules",
"LinksUpdate": "CiteHooks::onLinksUpdate",
"LinksUpdateComplete": "CiteHooks::onLinksUpdateComplete",
"ResourceLoaderGetConfigVars": "CiteHooks::onResourceLoaderGetConfigVars",
"APIQuerySiteInfoGeneralInfo": "CiteHooks::onAPIQuerySiteInfoGeneralInfo"
"APIQuerySiteInfoGeneralInfo": "Cite\\Hooks\\CiteHooks::onAPIQuerySiteInfoGeneralInfo",
"ContentHandlerDefaultModelFor": "Cite\\Hooks\\CiteHooks::onContentHandlerDefaultModelFor",
"LinksUpdate": "Cite\\Hooks\\CiteHooks::onLinksUpdate",
"LinksUpdateComplete": "Cite\\Hooks\\CiteHooks::onLinksUpdateComplete",
"ParserAfterParse": "Cite\\Hooks\\CiteParserHooks::onParserAfterParse",
"ParserBeforeTidy": "Cite\\Hooks\\CiteParserHooks::onParserBeforeTidy",
"ParserClearState": "Cite\\Hooks\\CiteParserHooks::onParserClearState",
"ParserCloned": "Cite\\Hooks\\CiteParserHooks::onParserCloned",
"ParserFirstCallInit": "Cite\\Hooks\\CiteParserHooks::onParserFirstCallInit",
"ResourceLoaderGetConfigVars": "Cite\\Hooks\\CiteHooks::onResourceLoaderGetConfigVars",
"ResourceLoaderRegisterModules": "Cite\\Hooks\\CiteHooks::onResourceLoaderRegisterModules",
"ResourceLoaderTestModules": "Cite\\Hooks\\CiteHooks::onResourceLoaderTestModules"
},
"ResourceModules": {
"ext.cite.styles": {
@ -61,7 +61,7 @@
]
},
"ext.cite.style": {
"class": "CiteCSSFileModule",
"class": "Cite\\ResourceLoader\\CiteCSSFileModule",
"styles": "ext.cite.style.css",
"targets": [
"desktop",
@ -119,15 +119,8 @@
"value": true
}
},
"AutoloadClasses": {
"ApiQueryReferences": "includes/ApiQueryReferences.php",
"Cite": "includes/Cite.php",
"CiteErrorReporter": "includes/CiteErrorReporter.php",
"CiteHooks": "includes/CiteHooks.php",
"CiteDataModule": "includes/CiteDataModule.php",
"CiteCSSFileModule": "includes/CiteCSSFileModule.php",
"CiteParserHooks": "includes/CiteParserHooks.php",
"CiteParserTagHooks": "includes/CiteParserTagHooks.php"
"AutoloadNamespaces": {
"Cite\\": "src/"
},
"TrackingCategories": [
"cite-tracking-category-cite-error"

View file

@ -21,10 +21,17 @@
* @see https://www.mediawiki.org/wiki/Extension:Cite#API
*/
namespace Cite\Api;
use ApiBase;
use ApiQuery;
use ApiResult;
use Cite\Cite;
use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\IDatabase;
class ApiQueryReferences extends ApiQueryBase {
class ApiQueryReferences extends \ApiQueryBase {
/**
* Cache duration when fetching references from the database, in seconds. 18,000 seconds = 5

View file

@ -22,7 +22,16 @@
* @license GPL-2.0-or-later
*/
namespace Cite;
use Exception;
use Html;
use MediaWiki\MediaWikiServices;
use Parser;
use ParserOptions;
use ParserOutput;
use Sanitizer;
use StripState;
class Cite {

View file

@ -1,5 +1,12 @@
<?php
namespace Cite;
use Html;
use Language;
use Parser;
use Sanitizer;
/**
* @license GPL-2.0-or-later
*/

View file

@ -4,8 +4,18 @@
* @license MIT
*/
namespace Cite\Hooks;
use ApiQuerySiteinfo;
use Cite\Cite;
use ExtensionRegistry;
use FormatJson;
use LinksUpdate;
use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
use ResourceLoader;
use Title;
use WANObjectCache;
class CiteHooks {
@ -59,7 +69,7 @@ class CiteHooks {
'ext.cite.visualEditor',
'test.VisualEditor'
],
'localBasePath' => __DIR__ . '/../modules/ve-cite/tests',
'localBasePath' => __DIR__ . '/../../modules/ve-cite/tests',
'remoteExtPath' => 'Cite/modules/ve-cite/tests',
];
}
@ -73,7 +83,7 @@ class CiteHooks {
*/
public static function onResourceLoaderRegisterModules( ResourceLoader $resourceLoader ) {
$uxEnhancementsModule = [
'localBasePath' => __DIR__ . '/../modules',
'localBasePath' => __DIR__ . '/../../modules',
'remoteExtPath' => 'Cite/modules',
'scripts' => [
'ext.cite.a11y.js',
@ -102,7 +112,7 @@ class CiteHooks {
}
$resourceLoader->register( "ext.cite.visualEditor.core", [
'localBasePath' => __DIR__ . '/../modules/ve-cite',
'localBasePath' => __DIR__ . '/../../modules/ve-cite',
'remoteExtPath' => 'Cite/modules/ve-cite',
"scripts" => [
've.dm.MWReferenceModel.js',
@ -135,10 +145,10 @@ class CiteHooks {
] );
$resourceLoader->register( "ext.cite.visualEditor.data",
[ "class" => "CiteDataModule" ] );
[ 'class' => 'Cite\\ResourceLoader\\CiteDataModule' ] );
$resourceLoader->register( "ext.cite.visualEditor", [
'localBasePath' => __DIR__ . '/../modules/ve-cite',
'localBasePath' => __DIR__ . '/../../modules/ve-cite',
'remoteExtPath' => 'Cite/modules/ve-cite',
"scripts" => [
've.ui.MWReferenceGroupInputWidget.js',

View file

@ -1,5 +1,11 @@
<?php
namespace Cite\Hooks;
use Cite\Cite;
use Parser;
use StripState;
/**
* @license GPL-2.0-or-later
*/

View file

@ -1,5 +1,11 @@
<?php
namespace Cite\Hooks;
use Cite\Cite;
use Parser;
use PPFrame;
/**
* @license GPL-2.0-or-later
*/

View file

@ -1,5 +1,7 @@
<?php
namespace Cite\ResourceLoader;
use MediaWiki\MediaWikiServices;
/**
@ -8,7 +10,7 @@ use MediaWiki\MediaWikiServices;
* @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
* @license MIT
*/
class CiteCSSFileModule extends ResourceLoaderFileModule {
class CiteCSSFileModule extends \ResourceLoaderFileModule {
/**
* @inheritDoc

View file

@ -1,5 +1,11 @@
<?php
namespace Cite\ResourceLoader;
use FormatJson;
use ResourceLoader;
use ResourceLoaderContext;
/**
* Resource loader module providing extra data from the server to Cite.
*
@ -8,7 +14,7 @@
* @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
* @license MIT
*/
class CiteDataModule extends ResourceLoaderModule {
class CiteDataModule extends \ResourceLoaderModule {
protected $targets = [ 'desktop', 'mobile' ];

View file

@ -2,12 +2,12 @@
namespace Cite\Tests;
use CiteCSSFileModule;
use Cite\ResourceLoader\CiteCSSFileModule;
use MediaWiki\MediaWikiServices;
use ResourceLoaderContext;
/**
* @covers \CiteCSSFileModule
* @covers \Cite\ResourceLoader\CiteCSSFileModule
*
* @license GPL-2.0-or-later
*/

View file

@ -2,13 +2,13 @@
namespace Cite\Tests;
use CiteErrorReporter;
use Cite\CiteErrorReporter;
use Language;
use MediaWiki\MediaWikiServices;
use Parser;
/**
* @covers \CiteErrorReporter
* @covers \Cite\CiteErrorReporter
*
* @license GPL-2.0-or-later
*/

View file

@ -3,14 +3,14 @@
namespace Cite\Tests;
use ApiQuerySiteinfo;
use CiteHooks;
use Cite\Hooks\CiteHooks;
use HashBagOStuff;
use LinksUpdate;
use Title;
use WANObjectCache;
/**
* @coversDefaultClass \CiteHooks
* @coversDefaultClass \Cite\Hooks\CiteHooks
*
* @license GPL-2.0-or-later
*/

View file

@ -2,7 +2,7 @@
namespace Cite\Tests;
use Cite;
use Cite\Cite;
use Language;
use Parser;
use ParserOptions;
@ -10,7 +10,7 @@ use ParserOutput;
use StripState;
/**
* @coversDefaultClass \Cite
* @coversDefaultClass \Cite\Cite
*
* @license GPL-2.0-or-later
*/

View file

@ -4,14 +4,14 @@ namespace Cite\Tests\Unit;
use ApiMain;
use ApiQuery;
use ApiQueryReferences;
use Cite\Api\ApiQueryReferences;
use IContextSource;
use Wikimedia\AtEase\AtEase;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\TestingAccessWrapper;
/**
* @coversDefaultClass \ApiQueryReferences
* @coversDefaultClass \Cite\Api\ApiQueryReferences
*
* @license GPL-2.0-or-later
*/

View file

@ -2,13 +2,13 @@
namespace Cite\Tests\Unit;
use CiteDataModule;
use Cite\ResourceLoader\CiteDataModule;
use Message;
use ResourceLoaderContext;
use WebRequest;
/**
* @covers \CiteDataModule
* @covers \Cite\ResourceLoader\CiteDataModule
*
* @license GPL-2.0-or-later
*/

View file

@ -2,8 +2,8 @@
namespace Cite\Tests\Unit;
use Cite;
use CiteHooks;
use Cite\Cite;
use Cite\Hooks\CiteHooks;
use HashConfig;
use LinksUpdate;
use ParserOutput;
@ -11,7 +11,7 @@ use ResourceLoader;
use Title;
/**
* @coversDefaultClass \CiteHooks
* @coversDefaultClass \Cite\Hooks\CiteHooks
*
* @license GPL-2.0-or-later
*/

View file

@ -2,15 +2,15 @@
namespace Cite\Tests\Unit;
use Cite;
use CiteParserHooks;
use Cite\Cite;
use Cite\Hooks\CiteParserHooks;
use Parser;
use ParserOptions;
use ParserOutput;
use StripState;
/**
* @coversDefaultClass \CiteParserHooks
* @coversDefaultClass \Cite\Hooks\CiteParserHooks
*
* @license GPL-2.0-or-later
*/

View file

@ -2,14 +2,14 @@
namespace Cite\Tests\Unit;
use Cite;
use CiteParserTagHooks;
use Cite\Cite;
use Cite\Hooks\CiteParserTagHooks;
use Parser;
use ParserOutput;
use PPFrame;
/**
* @coversDefaultClass \CiteParserTagHooks
* @coversDefaultClass \Cite\Hooks\CiteParserTagHooks
*
* @license GPL-2.0-or-later
*/

View file

@ -2,11 +2,11 @@
namespace Cite\Tests\Unit;
use Cite;
use Cite\Cite;
use Wikimedia\TestingAccessWrapper;
/**
* @coversDefaultClass \Cite
* @coversDefaultClass \Cite\Cite
*
* @license GPL-2.0-or-later
*/