Mwjames has uploaded a new change for review.
https://gerrit.wikimedia.org/r/56788
Change subject: Fix DeclareParserFunction name/class
......................................................................
Fix DeclareParserFunction name/class
No logic or process change.
Change-Id: I6712317cc13889c593eb9660b8b236a9b10c94fb
---
M SemanticMediaWiki.hooks.php
M includes/Setup.php
R includes/parserhooks/DeclareParserFunction.php
A tests/phpunit/includes/parserhooks/DeclareParserFunctionTest.php
4 files changed, 70 insertions(+), 14 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticMediaWiki
refs/changes/88/56788/1
diff --git a/SemanticMediaWiki.hooks.php b/SemanticMediaWiki.hooks.php
index c338746..2a4cbff 100644
--- a/SemanticMediaWiki.hooks.php
+++ b/SemanticMediaWiki.hooks.php
@@ -131,7 +131,7 @@
$parser->setFunctionHook( 'concept', array(
'SMW\ConceptParserFunction', 'render' ) );
$parser->setFunctionHook( 'set', array(
'SMW\SetParserFunction', 'render' ) );
$parser->setFunctionHook( 'set_recurring_event', array(
'SMW\RecurringEventsParserFunction', 'render' ) );
- $parser->setFunctionHook( 'declare', array( 'SMWDeclare',
'render' ), SFH_OBJECT_ARGS );
+ $parser->setFunctionHook( 'declare', array(
'SMW\DeclareParserFunction', 'render' ), SFH_OBJECT_ARGS );
return true;
}
@@ -290,6 +290,7 @@
'parserhooks/AskParserFunction',
'parserhooks/ShowParserFunction',
'parserhooks/ConceptParserFunction',
+ 'parserhooks/DeclareParserFunction',
'printers/ResultPrinters',
diff --git a/includes/Setup.php b/includes/Setup.php
index c3467ed..ea9b205 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -205,7 +205,7 @@
$wgAutoloadClasses['SMW\ShowParserFunction'] = $phDir .
'ShowParserFunction.php';
$wgAutoloadClasses['SMWInfo'] = $phDir .
'SMW_Info.php';
$wgAutoloadClasses['SMW\ConceptParserFunction'] = $phDir .
'ConceptParserFunction.php';
- $wgAutoloadClasses['SMWDeclare'] = $phDir .
'SMW_Declare.php';
+ $wgAutoloadClasses['SMW\DeclareParserFunction'] = $phDir .
'DeclareParserFunction.php';
$wgAutoloadClasses['SMWSMWDoc'] = $phDir .
'SMW_SMWDoc.php';
$wgAutoloadClasses['SMW\ParserParameterFormatter'] = $phDir .
'ParserParameterFormatter.php';
$wgAutoloadClasses['SMW\SetParserFunction'] = $phDir .
'SetParserFunction.php';
diff --git a/includes/parserhooks/SMW_Declare.php
b/includes/parserhooks/DeclareParserFunction.php
similarity index 87%
rename from includes/parserhooks/SMW_Declare.php
rename to includes/parserhooks/DeclareParserFunction.php
index 7c61611..b263fab 100644
--- a/includes/parserhooks/SMW_Declare.php
+++ b/includes/parserhooks/DeclareParserFunction.php
@@ -1,30 +1,36 @@
<?php
+namespace SMW;
+
+use Parser;
+use SMWParseData;
+use SMWOutputs;
+
/**
* Class for the 'declare' parser functions.
* @see
http://semantic-mediawiki.org/wiki/Help:Argument_declaration_in_templates
- *
+ *
* @since 1.5.3
- *
+ *
* @file SMW_Declare.php
* @ingroup SMW
* @ingroup ParserHooks
- *
+ *
* @author Markus Krötzsch
* @author Jeroen De Dauw
*/
-class SMWDeclare {
-
+class DeclareParserFunction {
+
/**
* Method for handling the declare parser function.
- *
+ *
* @since 1.5.3
- *
+ *
* @param Parser $parser
* @param PPFrame $frame
* @param array $args
*/
- public static function render( Parser &$parser, PPFrame $frame, array
$args ) {
+ public static function render( Parser &$parser, \PPFrame $frame, array
$args ) {
if ( $frame->isTemplate() ) {
foreach ( $args as $arg )
if ( trim( $arg ) !== '' ) {
@@ -39,7 +45,7 @@
$argumentname = $parts[1];
}
- $property =
SMWPropertyValue::makeUserProperty( $propertystring );
+ $property =
\SMWPropertyValue::makeUserProperty( $propertystring );
$argument = $frame->getArgument(
$argumentname );
$valuestring = $frame->expand(
$argument );
@@ -80,8 +86,8 @@
else {
SMWOutputs::commitToParser( $parser );
}
-
- return '';
+
+ return '';
}
-
+
}
\ No newline at end of file
diff --git a/tests/phpunit/includes/parserhooks/DeclareParserFunctionTest.php
b/tests/phpunit/includes/parserhooks/DeclareParserFunctionTest.php
new file mode 100644
index 0000000..3966160
--- /dev/null
+++ b/tests/phpunit/includes/parserhooks/DeclareParserFunctionTest.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace SMW\Test;
+
+use SMW\DeclareParserFunction;
+
+/**
+ * Tests for the SMW\DeclareParserFunction class
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 1.9
+ *
+ * @ingroup SMW
+ * @ingroup Test
+ *
+ * @group SMW
+ * @group SMWExtension
+ *
+ * @licence GNU GPL v2+
+ * @author mwjames
+ */
+class DeclareParserFunctionTest extends \MediaWikiTestCase {
+
+ // Will be extended in a follow-up
+
+ /**
+ * Test instance
+ *
+ */
+ public function testConstructor() {
+ $instance = new DeclareParserFunction();
+ $this->assertInstanceOf( 'SMW\DeclareParserFunction', $instance
);
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/56788
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6712317cc13889c593eb9660b8b236a9b10c94fb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits