Umherirrender has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/172588

Change subject: Use Parser::SFH_NO_HASH/SFH_OBJECT_ARGS class const
......................................................................

Use Parser::SFH_NO_HASH/SFH_OBJECT_ARGS class const

Instead of the global const

Change-Id: I3e1dcf46fe18a97a05e3406c209815adb7e0e083
---
M includes/parser/CoreParserFunctions.php
M includes/parser/Parser.php
M tests/phpunit/includes/parser/TagHooksTest.php
3 files changed, 14 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/88/172588/1

diff --git a/includes/parser/CoreParserFunctions.php 
b/includes/parser/CoreParserFunctions.php
index d9f1761..6f19a23 100644
--- a/includes/parser/CoreParserFunctions.php
+++ b/includes/parser/CoreParserFunctions.php
@@ -36,7 +36,7 @@
                # Syntax for arguments (see Parser::setFunctionHook):
                #  "name for lookup in localized magic words array",
                #  function callback,
-               #  optional SFH_NO_HASH to omit the hash from calls (e.g. 
{{int:...}}
+               #  optional Parser::SFH_NO_HASH to omit the hash from calls 
(e.g. {{int:...}}
                #    instead of {{#int:...}})
                $noHashFunctions = array(
                        'ns', 'nse', 'urlencode', 'lcfirst', 'ucfirst', 'lc', 
'uc',
@@ -57,24 +57,24 @@
                        'revisiontimestamp', 'revisionuser', 'cascadingsources',
                );
                foreach ( $noHashFunctions as $func ) {
-                       $parser->setFunctionHook( $func, array( __CLASS__, 
$func ), SFH_NO_HASH );
+                       $parser->setFunctionHook( $func, array( __CLASS__, 
$func ), Parser::SFH_NO_HASH );
                }
 
-               $parser->setFunctionHook( 'namespace', array( __CLASS__, 
'mwnamespace' ), SFH_NO_HASH );
-               $parser->setFunctionHook( 'int', array( __CLASS__, 
'intFunction' ), SFH_NO_HASH );
+               $parser->setFunctionHook( 'namespace', array( __CLASS__, 
'mwnamespace' ), Parser::SFH_NO_HASH );
+               $parser->setFunctionHook( 'int', array( __CLASS__, 
'intFunction' ), Parser::SFH_NO_HASH );
                $parser->setFunctionHook( 'special', array( __CLASS__, 
'special' ) );
                $parser->setFunctionHook( 'speciale', array( __CLASS__, 
'speciale' ) );
-               $parser->setFunctionHook( 'tag', array( __CLASS__, 'tagObj' ), 
SFH_OBJECT_ARGS );
+               $parser->setFunctionHook( 'tag', array( __CLASS__, 'tagObj' ), 
Parser::SFH_OBJECT_ARGS );
                $parser->setFunctionHook( 'formatdate', array( __CLASS__, 
'formatDate' ) );
 
                if ( $wgAllowDisplayTitle ) {
-                       $parser->setFunctionHook( 'displaytitle', array( 
__CLASS__, 'displaytitle' ), SFH_NO_HASH );
+                       $parser->setFunctionHook( 'displaytitle', array( 
__CLASS__, 'displaytitle' ), Parser::SFH_NO_HASH );
                }
                if ( $wgAllowSlowParserFunctions ) {
                        $parser->setFunctionHook(
                                'pagesinnamespace',
                                array( __CLASS__, 'pagesinnamespace' ),
-                               SFH_NO_HASH
+                               Parser::SFH_NO_HASH
                        );
                }
        }
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index cd804b5..12f4a29 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -3802,7 +3802,7 @@
                }
 
                $allArgs = array( &$this );
-               if ( $flags & SFH_OBJECT_ARGS ) {
+               if ( $flags & self::SFH_OBJECT_ARGS ) {
                        # Convert arguments to PPNodes and collect for 
appending to $allArgs
                        $funcArgs = array();
                        foreach ( $args as $k => $v ) {
@@ -5204,7 +5204,7 @@
         * The callback function should have the form:
         *    function myParserFunction( &$parser, $arg1, $arg2, $arg3 ) { ... }
         *
-        * Or with SFH_OBJECT_ARGS:
+        * Or with Parser::SFH_OBJECT_ARGS:
         *    function myParserFunction( $parser, $frame, $args ) { ... }
         *
         * The callback may either return the text result of the function, or 
an array with the text
@@ -5218,10 +5218,10 @@
         * @param string $id The magic word ID
         * @param callable $callback The callback function (and object) to use
         * @param int $flags A combination of the following flags:
-        *     SFH_NO_HASH   No leading hash, i.e. {{plural:...}} instead of 
{{#if:...}}
+        *     Parser::SFH_NO_HASH      No leading hash, i.e. {{plural:...}} 
instead of {{#if:...}}
         *
-        *     SFH_OBJECT_ARGS   Pass the template arguments as PPNode objects 
instead of text. This
-        *     allows for conditional expansion of the parse tree, allowing you 
to eliminate dead
+        *     Parser::SFH_OBJECT_ARGS  Pass the template arguments as PPNode 
objects instead of text.
+        *     This allows for conditional expansion of the parse tree, 
allowing you to eliminate dead
         *     branches and thus speed up parsing. It is also possible to 
analyse the parse tree of
         *     the arguments, and to control the way they are expanded.
         *
@@ -5263,7 +5263,7 @@
                                $syn = $wgContLang->lc( $syn );
                        }
                        # Add leading hash
-                       if ( !( $flags & SFH_NO_HASH ) ) {
+                       if ( !( $flags & self::SFH_NO_HASH ) ) {
                                $syn = '#' . $syn;
                        }
                        # Remove trailing colon
diff --git a/tests/phpunit/includes/parser/TagHooksTest.php 
b/tests/phpunit/includes/parser/TagHooksTest.php
index e3c4cc8..251da47 100644
--- a/tests/phpunit/includes/parser/TagHooksTest.php
+++ b/tests/phpunit/includes/parser/TagHooksTest.php
@@ -89,7 +89,7 @@
                global $wgParserConf, $wgContLang;
                $parser = new Parser( $wgParserConf );
 
-               $parser->setFunctionTagHook( $tag, array( $this, 
'functionTagCallback' ), SFH_OBJECT_ARGS );
+               $parser->setFunctionTagHook( $tag, array( $this, 
'functionTagCallback' ), Parser::SFH_OBJECT_ARGS );
                $parser->parse(
                        "Foo<$tag>Bar</$tag>Baz",
                        Title::newFromText( 'Test' ),

-- 
To view, visit https://gerrit.wikimedia.org/r/172588
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3e1dcf46fe18a97a05e3406c209815adb7e0e083
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to