Merge "Use Parser::SFH_NO_HASH/SFH_OBJECT_ARGS class const"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 27 Nov 2014 05:55:07 +0000 (05:55 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 27 Nov 2014 05:55:07 +0000 (05:55 +0000)
1  2 
includes/Defines.php
includes/parser/Parser.php

diff --combined includes/Defines.php
@@@ -224,12 -224,6 +224,12 @@@ define( 'MW_SUPPORTS_RESOURCE_MODULES'
  /**@{
   * Allowed values for Parser::$mOutputType
   * Parameter to Parser::startExternalParse().
 + * Use of Parser consts is preferred:
 + * - Parser::OT_HTML
 + * - Parser::OT_WIKI
 + * - Parser::OT_PREPROCESS
 + * - Parser::OT_MSG
 + * - Parser::OT_PLAIN
   */
  define( 'OT_HTML', 1 );
  define( 'OT_WIKI', 2 );
@@@ -240,6 -234,9 +240,9 @@@ define( 'OT_PLAIN', 4 )
  
  /**@{
   * Flags for Parser::setFunctionHook
+  * Use of Parser consts is preferred:
+  * - Parser::SFH_NO_HASH
+  * - Parser::SFH_OBJECT_ARGS
   */
  define( 'SFH_NO_HASH', 1 );
  define( 'SFH_OBJECT_ARGS', 2 );
@@@ -79,7 -79,6 +79,6 @@@ class Parser 
        const HALF_PARSED_VERSION = 2;
  
        # Flags for Parser::setFunctionHook
-       # Also available as global constants from Defines.php
        const SFH_NO_HASH = 1;
        const SFH_OBJECT_ARGS = 2;
  
                        // Add on template profiling data
                        $dataByFunc = $this->mProfiler->getFunctionStats();
                        uasort( $dataByFunc, function( $a, $b ) {
 -                              return $a['elapsed'] < $b['elapsed']; // descending order
 +                              return $a['real'] < $b['real']; // descending order
                        } );
 -                      $profileReport = "Top template expansion time report (%,ms,calls,template)\n";
 +                      $profileReport = "Transclusion expansion time report (%,ms,calls,template)\n";
                        foreach ( array_slice( $dataByFunc, 0, 10 ) as $item ) {
 -                              $profileReport .= sprintf( "%6.2f%% %3.6f %6d - %s\n",
 -                                      $item['percent'], $item['elapsed'], $item['calls'],
 +                              $profileReport .= sprintf( "%6.2f%% %8.3f %6d - %s\n",
 +                                      $item['%real'], $item['real'], $item['calls'],
                                        htmlspecialchars($item['name'] ) );
                        }
                        $text .= "\n<!-- \n$profileReport-->\n";
                }
  
                $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 ) {
         * 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
         * @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.
         *
                                $syn = $wgContLang->lc( $syn );
                        }
                        # Add leading hash
-                       if ( !( $flags & SFH_NO_HASH ) ) {
+                       if ( !( $flags & self::SFH_NO_HASH ) ) {
                                $syn = '#' . $syn;
                        }
                        # Remove trailing colon