Foxtrott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/275263
Change subject: Use namespaces
......................................................................
Use namespaces
Change-Id: I3b6d10401dc9319e3d87466ea6514c1904206125
---
M extension.json
M src/LingoBackend.php
M src/LingoBasicBackend.php
M src/LingoElement.php
M src/LingoHooks.php
M src/LingoMessageLog.php
M src/LingoParser.php
M src/LingoTree.php
M tests/phpunit/Unit/LingoBackendTest.php
M tests/phpunit/Unit/LingoBasicBackendTest.php
M tests/phpunit/Unit/LingoElementTest.php
M tests/phpunit/Unit/LingoMessageLogTest.php
M tests/phpunit/Unit/LingoParserTest.php
M tests/phpunit/Unit/LingoTreeTest.php
14 files changed, 89 insertions(+), 51 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Lingo
refs/changes/63/275263/1
diff --git a/extension.json b/extension.json
index 3f822ba..3c399ad 100644
--- a/extension.json
+++ b/extension.json
@@ -44,7 +44,7 @@
},
"config": {
"_prefix": "wgex",
- "LingoBackend": "LingoBasicBackend",
+ "LingoBackend": "Extensions\\Lingo\\LingoBasicBackend",
"LingoPage": null,
"LingoDisplayOnce": false,
"LingoCacheType": null,
@@ -60,30 +60,30 @@
"LingoMagic": "src/Lingo.i18n.magic.php"
},
"AutoloadClasses": {
- "LingoHooks": "/src/LingoHooks.php",
- "LingoParser": "/src/LingoParser.php",
- "LingoTree": "/src/LingoTree.php",
- "LingoElement": "/src/LingoElement.php",
- "LingoBackend": "/src/LingoBackend.php",
- "LingoBasicBackend": "/src/LingoBasicBackend.php",
- "LingoMessageLog": "/src/LingoMessageLog.php"
+ "Extensions\\Lingo\\LingoHooks": "/src/LingoHooks.php",
+ "Extensions\\Lingo\\LingoParser": "/src/LingoParser.php",
+ "Extensions\\Lingo\\LingoTree": "/src/LingoTree.php",
+ "Extensions\\Lingo\\LingoElement": "/src/LingoElement.php",
+ "Extensions\\Lingo\\LingoBackend": "/src/LingoBackend.php",
+ "Extensions\\Lingo\\LingoBasicBackend":
"/src/LingoBasicBackend.php",
+ "Extensions\\Lingo\\LingoMessageLog": "/src/LingoMessageLog.php"
},
"Hooks": {
"ParserFirstCallInit": [
- "LingoHooks::registerTags"
+ "Extensions\\Lingo\\LingoHooks::registerTags"
],
"ArticlePurge": [
- "LingoBasicBackend::purgeCache"
+ "Extensions\\Lingo\\LingoBasicBackend::purgeCache"
],
"ArticleSave": [
- "LingoBasicBackend::purgeCache"
+ "Extensions\\Lingo\\LingoBasicBackend::purgeCache"
],
"ParserAfterParse": [
- "LingoHooks::parse"
+ "Extensions\\Lingo\\LingoHooks::parse"
]
},
"ExtensionFunctions": [
- "LingoHooks::initExtension"
+ "Extensions\\Lingo\\LingoHooks::initExtension"
],
"manifest_version": 1
}
diff --git a/src/LingoBackend.php b/src/LingoBackend.php
index 383ee69..1463f85 100644
--- a/src/LingoBackend.php
+++ b/src/LingoBackend.php
@@ -1,7 +1,7 @@
<?php
/**
- * File holding the LingoBackend class
+ * File holding the Extensions\Lingo\LingoBackend class
*
* This file is part of the MediaWiki extension Lingo.
*
@@ -26,8 +26,10 @@
* @ingroup Lingo
*/
+namespace Extensions\Lingo;
+
/**
- * The LingoBackend class.
+ * The Extensions\Lingo\LingoBackend class.
*
* @ingroup Lingo
*/
@@ -36,7 +38,7 @@
protected $mMessageLog;
/**
- * LingoBackend constructor.
+ * Extensions\Lingo\LingoBackend constructor.
* @param LingoMessageLog|null $messages
*/
public function __construct( LingoMessageLog &$messages = null ) {
@@ -59,7 +61,7 @@
* This function returns true if the backend is cache-enabled.
*
* Actual caching is done by the parser, but to be cache-enabled the
backend
- * has to call LingoParser::purgeCache when necessary.
+ * has to call Extensions\Lingo\LingoParser::purgeCache when necessary.
*
* @return boolean
*/
diff --git a/src/LingoBasicBackend.php b/src/LingoBasicBackend.php
index d872cd0..04395ef 100644
--- a/src/LingoBasicBackend.php
+++ b/src/LingoBasicBackend.php
@@ -1,7 +1,7 @@
<?php
/**
- * File holding the LingoBackend class
+ * File holding the Extensions\Lingo\LingoBackend class
*
* This file is part of the MediaWiki extension Lingo.
*
@@ -25,9 +25,18 @@
* @file
* @ingroup Lingo
*/
+namespace Extensions\Lingo;
+
+use ApprovedRevs;
+use Page;
+use Parser;
+use ParserOptions;
+use Revision;
+use Title;
+use User;
/**
- * The LingoBasicBackend class.
+ * The Extensions\Lingo\LingoBasicBackend class.
*
* @ingroup Lingo
*/
@@ -36,7 +45,7 @@
protected $mArticleLines = array();
/**
- * LingoBasicBackend constructor.
+ * Extensions\Lingo\LingoBasicBackend constructor.
* @param LingoMessageLog|null $messages
*/
public function __construct( LingoMessageLog &$messages = null ) {
@@ -85,7 +94,7 @@
/**
* This function returns the next element. The element is an array of
four
- * strings: Term, Definition, Link, Source. For the LingoBasicBackend
Link
+ * strings: Term, Definition, Link, Source. For the
Extensions\Lingo\LingoBasicBackend Link
* and Source are set to null. If there is no next element the function
* returns null.
*
@@ -187,7 +196,7 @@
* The basic backend is cache-enabled so this function returns true.
*
* Actual caching is done by the parser, the backend just calls
- * LingoParser::purgeCache when necessary.
+ * Extensions\Lingo\LingoParser::purgeCache when necessary.
*
* @return boolean
*/
diff --git a/src/LingoElement.php b/src/LingoElement.php
index 5d57c2c..a5bf9c6 100644
--- a/src/LingoElement.php
+++ b/src/LingoElement.php
@@ -1,7 +1,7 @@
<?php
/**
- * File holding the LingoElement class.
+ * File holding the Extensions\Lingo\LingoElement class.
*
* This file is part of the MediaWiki extension Lingo.
*
@@ -27,6 +27,14 @@
* @ingroup Lingo
*/
+namespace Extensions\Lingo;
+use DOMDocument;
+use DOMElement;
+use DOMNode;
+use DOMText;
+use MWException;
+use Title;
+
/**
* This class represents a term-definition pair.
* One term may be related to several definitions.
@@ -50,7 +58,7 @@
static private $mLinkTemplate = null;
/**
- * LingoElement constructor.
+ * Extensions\Lingo\LingoElement constructor.
* @param $term
* @param $definition
*/
diff --git a/src/LingoHooks.php b/src/LingoHooks.php
index 032876e..2bd9f1c 100644
--- a/src/LingoHooks.php
+++ b/src/LingoHooks.php
@@ -1,7 +1,7 @@
<?php
/**
- * File holding the LingoHooks class
+ * File holding the Extensions\Lingo\LingoHooks class
*
* This file is part of the MediaWiki extension Lingo.
*
@@ -26,8 +26,13 @@
* @ingroup Lingo
*/
+namespace Extensions\Lingo;
+use MagicWord;
+use Parser;
+use PPFrame;
+
/**
- * The LingoHooks class.
+ * The Extensions\Lingo\LingoHooks class.
*
* It contains the hook handlers of the extension
*
@@ -71,7 +76,7 @@
* Creates tag hook(s)
*/
public static function registerTags( Parser $parser ) {
- $parser->setHook( 'noglossary',
'LingoHooks::noglossaryTagRenderer' );
+ $parser->setHook( 'noglossary',
'Extensions\Lingo\LingoHooks::noglossaryTagRenderer' );
return true;
}
diff --git a/src/LingoMessageLog.php b/src/LingoMessageLog.php
index 089169a..62a15fd 100644
--- a/src/LingoMessageLog.php
+++ b/src/LingoMessageLog.php
@@ -1,7 +1,7 @@
<?php
/**
- * File holding the LingoMessageLog class.
+ * File holding the Extensions\Lingo\LingoMessageLog class.
*
* This file is part of the MediaWiki extension Lingo.
*
@@ -27,6 +27,11 @@
* @ingroup Lingo
*/
+namespace Extensions\Lingo;
+use Html;
+use Parser;
+use ParserOptions;
+
/**
* This class holds messages (errors, warnings, notices) for Lingo
*
diff --git a/src/LingoParser.php b/src/LingoParser.php
index 6ebc003..2e85dc9 100644
--- a/src/LingoParser.php
+++ b/src/LingoParser.php
@@ -1,7 +1,7 @@
<?php
/**
- * File holding the LingoParser class.
+ * File holding the Extensions\Lingo\LingoParser class.
*
* This file is part of the MediaWiki extension Lingo.
*
@@ -26,6 +26,11 @@
* @file
* @ingroup Lingo
*/
+namespace Extensions\Lingo;
+
+use DOMDocument;
+use DOMXPath;
+use Parser;
/**
* This class parses the given text and enriches it with definitions for
defined
@@ -49,7 +54,7 @@
public static $regex = null;
/**
- * LingoParser constructor.
+ * Extensions\Lingo\LingoParser constructor.
* @param LingoMessageLog|null $messages
*/
public function __construct( LingoMessageLog &$messages = null ) {
@@ -115,9 +120,9 @@
}
/**
- * Returns the list of terms in the glossary as a LingoTree
+ * Returns the list of terms in the glossary as a
Extensions\Lingo\LingoTree
*
- * @return LingoTree a LingoTree mapping terms (keys) to descriptions
(values)
+ * @return LingoTree a Extensions\Lingo\LingoTree mapping terms (keys)
to descriptions (values)
*/
public function getLingoTree() {
@@ -156,6 +161,9 @@
return $this->mLingoTree;
}
+ /**
+ * @return LingoTree
+ */
protected function &buildLingo() {
$lingoTree = new LingoTree();
diff --git a/src/LingoTree.php b/src/LingoTree.php
index 604bb48..ed410c6 100644
--- a/src/LingoTree.php
+++ b/src/LingoTree.php
@@ -1,7 +1,7 @@
<?php
/**
- * File holding the LingoTree class
+ * File holding the Extensions\Lingo\LingoTree class
*
* This file is part of the MediaWiki extension Lingo.
*
@@ -26,9 +26,10 @@
* @file
* @ingroup Lingo
*/
+namespace Extensions\Lingo;
/**
- * The LingoTree class.
+ * The Extensions\Lingo\LingoTree class.
*
* Vocabulary:
* Term - The term as a normal string
diff --git a/tests/phpunit/Unit/LingoBackendTest.php
b/tests/phpunit/Unit/LingoBackendTest.php
index d66f7e7..36d4375 100644
--- a/tests/phpunit/Unit/LingoBackendTest.php
+++ b/tests/phpunit/Unit/LingoBackendTest.php
@@ -31,7 +31,7 @@
* @group extensions-lingo-unit
* @group mediawiki-databaseless
*
- * @coversDefaultClass \LingoBackend
+ * @coversDefaultClass \Extensions\Lingo\LingoBackend
* @covers ::<private>
* @covers ::<protected>
*
@@ -42,7 +42,7 @@
public function testUseCache() {
- $stub = $this->getMockForAbstractClass( '\LingoBackend' );
+ $stub = $this->getMockForAbstractClass(
'\Extensions\Lingo\LingoBackend' );
$this->assertFalse( $stub->useCache() );
}
diff --git a/tests/phpunit/Unit/LingoBasicBackendTest.php
b/tests/phpunit/Unit/LingoBasicBackendTest.php
index ffe3a13..ac2137f 100644
--- a/tests/phpunit/Unit/LingoBasicBackendTest.php
+++ b/tests/phpunit/Unit/LingoBasicBackendTest.php
@@ -31,7 +31,7 @@
* @group extensions-lingo-unit
* @group mediawiki-databaseless
*
- * @coversDefaultClass \LingoBasicBackend
+ * @coversDefaultClass \Extensions\Lingo\LingoBasicBackend
* @covers ::<private>
* @covers ::<protected>
*
@@ -46,8 +46,8 @@
public function testCanConstruct() {
$this->assertInstanceOf(
- '\LingoBasicBackend',
- new \LingoBasicBackend()
+ '\Extensions\Lingo\LingoBasicBackend',
+ new \Extensions\Lingo\LingoBasicBackend()
);
}
diff --git a/tests/phpunit/Unit/LingoElementTest.php
b/tests/phpunit/Unit/LingoElementTest.php
index c4cd525..62dd456 100644
--- a/tests/phpunit/Unit/LingoElementTest.php
+++ b/tests/phpunit/Unit/LingoElementTest.php
@@ -31,7 +31,7 @@
* @group extensions-lingo-unit
* @group mediawiki-databaseless
*
- * @coversDefaultClass \LingoElement
+ * @coversDefaultClass \Extensions\Lingo\LingoElement
* @covers ::<private>
* @covers ::<protected>
*
@@ -49,8 +49,8 @@
$description = array( 'someTerm', 'someDescription' );
$this->assertInstanceOf(
- '\LingoElement',
- new \LingoElement($term, $description)
+ '\Extensions\Lingo\LingoElement',
+ new \Extensions\Lingo\LingoElement($term, $description)
);
}
diff --git a/tests/phpunit/Unit/LingoMessageLogTest.php
b/tests/phpunit/Unit/LingoMessageLogTest.php
index 3fb6258..6ddac5a 100644
--- a/tests/phpunit/Unit/LingoMessageLogTest.php
+++ b/tests/phpunit/Unit/LingoMessageLogTest.php
@@ -31,7 +31,7 @@
* @group extensions-lingo-unit
* @group mediawiki-databaseless
*
- * @coversDefaultClass \LingoMessageLog
+ * @coversDefaultClass \Extensions\Lingo\LingoMessageLog
* @covers ::<private>
* @covers ::<protected>
*
@@ -45,8 +45,8 @@
public function testCanConstruct() {
$this->assertInstanceOf(
- '\LingoMessageLog',
- new \LingoMessageLog()
+ '\Extensions\Lingo\LingoMessageLog',
+ new \Extensions\Lingo\LingoMessageLog()
);
}
diff --git a/tests/phpunit/Unit/LingoParserTest.php
b/tests/phpunit/Unit/LingoParserTest.php
index 2057c25..8b885dd 100644
--- a/tests/phpunit/Unit/LingoParserTest.php
+++ b/tests/phpunit/Unit/LingoParserTest.php
@@ -31,7 +31,7 @@
* @group extensions-lingo-unit
* @group mediawiki-databaseless
*
- * @coversDefaultClass \LingoParser
+ * @coversDefaultClass \Extensions\Lingo\LingoParser
* @covers ::<private>
* @covers ::<protected>
*
@@ -46,8 +46,8 @@
public function testCanConstruct() {
$this->assertInstanceOf(
- '\LingoParser',
- new \LingoParser()
+ '\Extensions\Lingo\LingoParser',
+ new \Extensions\Lingo\LingoParser()
);
}
diff --git a/tests/phpunit/Unit/LingoTreeTest.php
b/tests/phpunit/Unit/LingoTreeTest.php
index de5cd58..cc480cd 100644
--- a/tests/phpunit/Unit/LingoTreeTest.php
+++ b/tests/phpunit/Unit/LingoTreeTest.php
@@ -31,7 +31,7 @@
* @group extensions-lingo-unit
* @group mediawiki-databaseless
*
- * @coversDefaultClass \LingoTree
+ * @coversDefaultClass \Extensions\Lingo\LingoTree
* @covers ::<private>
* @covers ::<protected>
*
@@ -45,8 +45,8 @@
public function testCanConstruct() {
$this->assertInstanceOf(
- '\LingoTree',
- new \LingoTree()
+ '\Extensions\Lingo\LingoTree',
+ new \Extensions\Lingo\LingoTree()
);
}
--
To view, visit https://gerrit.wikimedia.org/r/275263
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3b6d10401dc9319e3d87466ea6514c1904206125
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Lingo
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits