Pastakhov has uploaded a new change for review.

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

Change subject: Update to master version 3.8 (v 3.8.0.26) requere PhpTags >= 5.9
......................................................................

Update to master version 3.8 (v 3.8.0.26) requere PhpTags >= 5.9

* Fix dump functions (v 3.8) requere PhpTags >= 5.9
* Add extension.json file and move setup instructions to it (v 3.7.1)
* Optimize PhpTagsFunc::__callStatic() (v 3.5.3) needs PhpTags 5.2.0
    * use UIDGenerator for function uuid_create()
    * add debug message to !!!firstInit_Test.php
* Update indentation to use tabs

Change-Id: I255e4a41b5c26af151c76c80293f46ccf16274d8
---
M PhpTagsFunctions.hooks.php
M PhpTagsFunctions.json
M PhpTagsFunctions.php
A extension.json
M i18n/en.json
M i18n/ko.json
M includes/PhpTagsFunc.php
M includes/PhpTagsFuncUseful.php
M tests/parser/PhpTagsFunctionsTests.txt
M tests/phpunit/!!!firstInit_Test.php
M tests/phpunit/PhpTagsFunctions_DateTime_Test.php
M tests/phpunit/PhpTagsFunctions_Useful_Test.php
M tests/phpunit/PhpTagsFunctions_Var_Test.php
13 files changed, 201 insertions(+), 124 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PhpTagsFunctions 
refs/changes/42/304442/1

diff --git a/PhpTagsFunctions.hooks.php b/PhpTagsFunctions.hooks.php
index 7767a24..7543e76 100644
--- a/PhpTagsFunctions.hooks.php
+++ b/PhpTagsFunctions.hooks.php
@@ -12,18 +12,24 @@
 class PhpTagsFunctionsHooks {
 
        /**
-        *
+        * Check on version compatibility
         * @return boolean
         */
        public static function onParserFirstCallInit() {
-               if ( !defined( 'PHPTAGS_VERSION' ) ) {
+               $extRegistry = ExtensionRegistry::getInstance();
+               $phpTagsLoaded = $extRegistry->isLoaded( 'PhpTags' );
+               //if ( !$extRegistry->isLoaded( 'PhpTags' ) ) { use 
PHPTAGS_VERSION for backward compatibility
+               if ( !($phpTagsLoaded || defined( 'PHPTAGS_VERSION' )) ) {
                        throw new MWException( "\n\nYou need to have the 
PhpTags extension installed in order to use the PhpTags Functions extension." );
                }
-               $needVersion = '5.1.0';
-               if ( version_compare( PHPTAGS_VERSION, $needVersion, '<' ) ) {
-                       throw new MWException( "\n\nThis version of the PhpTags 
Functions extension requires the PhpTags extension $needVersion or above.\n You 
have " . PHPTAGS_VERSION . ". Please update it." );
+               if ( $phpTagsLoaded ) {
+                       $neededVersion = '5.9';
+                       $phpTagsVersion = 
$extRegistry->getAllThings()['PhpTags']['version'];
+                       if ( version_compare( $phpTagsVersion, $neededVersion, 
'<' ) ) {
+                               throw new MWException( "\n\nThis version of the 
PhpTags Functions extension requires the PhpTags extension $neededVersion or 
above.\n You have $phpTagsVersion. Please update it." );
+                       }
                }
-               if ( PHPTAGS_HOOK_RELEASE != 8 ) {
+               if ( !$phpTagsLoaded || PHPTAGS_HOOK_RELEASE != 8 ) {
                        throw new MWException( "\n\nThis version of the PhpTags 
Functions extension is outdated and not compatible with current version of the 
PhpTags extension.\n Please update it." );
                }
                return true;
@@ -34,7 +40,9 @@
         * @return boolean
         */
        public static function onPhpTagsRuntimeFirstInit() {
-               \PhpTags\Hooks::addJsonFile( __DIR__ . 
'/PhpTagsFunctions.json', PHPTAGS_FUNCTIONS_VERSION );
+               $allThings = ExtensionRegistry::getInstance()->getAllThings();
+               $version = $allThings['PhpTags Functions']['version'];
+               \PhpTags\Hooks::addJsonFile( __DIR__ . 
'/PhpTagsFunctions.json', $version . PHP_VERSION );
                return true;
        }
 
diff --git a/PhpTagsFunctions.json b/PhpTagsFunctions.json
index c367881..9747afd 100644
--- a/PhpTagsFunctions.json
+++ b/PhpTagsFunctions.json
@@ -2970,6 +2970,7 @@
        "constants": {
                "PHPTAGS_FUNCTIONS_VERSION": {
                        "desc": "The current version of the PhpTags Functions 
extension as a string",
+                       "class": "PhpTagsFuncUseful",
                        "type": "string",
                        "link": "mw://Extension:PhpTags_Functions"
                },
diff --git a/PhpTagsFunctions.php b/PhpTagsFunctions.php
index 1435f10..86f0a29 100644
--- a/PhpTagsFunctions.php
+++ b/PhpTagsFunctions.php
@@ -1,47 +1,14 @@
 <?php
-/**
- * Main entry point for the PhpTags Functions extension.
- *
- * @link https://www.mediawiki.org/wiki/Extension:PhpTags_Functions 
Documentation
- * @file PhpTagsFunctions.php
- * @defgroup PhpTags
- * @ingroup Extensions
- * @author Pavel Astakhov <[email protected]>
- * @licence GNU General Public Licence 2.0 or later
- */
-
-// Check to see if we are being called as an extension or directly
-if ( !defined('MEDIAWIKI') ) {
-       die( 'This file is an extension to MediaWiki and thus not a valid entry 
point.' );
+if ( function_exists( 'wfLoadExtension' ) ) {
+       wfLoadExtension( 'PhpTagsFunctions' );
+       // Keep i18n globals so mergeMessageFileList.php doesn't break
+       $wgMessagesDirs['PhpTagsFunctions'] = __DIR__ . '/i18n';
+//     wfWarn(
+//             'Deprecated PHP entry point used for PhpTags Functions 
extension. ' .
+//             'Please use wfLoadExtension instead, ' .
+//             'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
+//     );
+       return;
+} else {
+       die( 'This version of the PhpTags Functions extension requires 
MediaWiki 1.25+' );
 }
-
-const PHPTAGS_FUNCTIONS_VERSION = '3.5.2';
-
-// Register this extension on Special:Version
-$wgExtensionCredits['phptags'][] = array(
-       'path'                          => __FILE__,
-       'name'                          => 'PhpTags Functions',
-       'version'                       => PHPTAGS_FUNCTIONS_VERSION,
-       'url'                           => 
'https://www.mediawiki.org/wiki/Extension:PhpTags_Functions',
-       'author'                        => 
'[https://www.mediawiki.org/wiki/User:Pastakhov Pavel Astakhov]',
-       'descriptionmsg'        => 'phptagsfunctions-desc'
-);
-
-// Allow translations for this extension
-$wgMessagesDirs['PhpTagsFunctions'] = __DIR__ . '/i18n';
-
-//
-$wgHooks['ParserFirstCallInit'][] = 
'PhpTagsFunctionsHooks::onParserFirstCallInit';
-$wgHooks['PhpTagsRuntimeFirstInit'][] = 
'PhpTagsFunctionsHooks::onPhpTagsRuntimeFirstInit';
-$wgHooks['UnitTestsList'][] = 'PhpTagsFunctionsHooks::onUnitTestsList';
-
-// Preparing classes for autoloading
-$wgAutoloadClasses['PhpTagsFunctionsHooks'] = __DIR__ . 
'/PhpTagsFunctions.hooks.php';
-$wgAutoloadClasses['PhpTagsObjects\\PhpTagsFunc'] = __DIR__ . 
'/includes/PhpTagsFunc.php';
-$wgAutoloadClasses['PhpTagsObjects\\PhpTagsFuncUseful'] = __DIR__ . 
'/includes/PhpTagsFuncUseful.php';
-$wgAutoloadClasses['PhpTagsObjects\\PhpTagsFuncNativeObject'] = __DIR__ . 
'/includes/PhpTagsFuncNativeObject.php';
-$wgAutoloadClasses['PhpTagsObjects\\PhpTagsFuncDatePeriod'] = __DIR__ . 
'/includes/PhpTagsFuncDatePeriod.php';
-$wgAutoloadClasses['PhpTagsObjects\\PhpTagsWebRequest'] = __DIR__ . 
'/includes/PhpTagsWebRequest.php';
-
-// add parser tests
-$wgParserTestFiles[] = __DIR__ . '/tests/parser/PhpTagsFunctionsTests.txt';
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..638deb2
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,31 @@
+{
+       "name": "PhpTags Functions",
+       "version": "3.8.0.26",
+       "author": "[https://www.mediawiki.org/wiki/User:Pastakhov Pavel 
Astakhov]",
+       "url": "https://www.mediawiki.org/wiki/Extension:PhpTags_Functions";,
+       "descriptionmsg": "phptagsfunctions-desc",
+       "license-name": "GPL-2.0+",
+       "type": "phptags",
+       "MessagesDirs": {
+               "PhpTagsFunctions": [
+                       "i18n"
+               ]
+       },
+       "AutoloadClasses": {
+               "PhpTagsFunctionsHooks": "PhpTagsFunctions.hooks.php",
+               "PhpTagsObjects\\PhpTagsFunc": "includes/PhpTagsFunc.php",
+               "PhpTagsObjects\\PhpTagsFuncUseful": 
"includes/PhpTagsFuncUseful.php",
+               "PhpTagsObjects\\PhpTagsFuncNativeObject": 
"includes/PhpTagsFuncNativeObject.php",
+               "PhpTagsObjects\\PhpTagsFuncDatePeriod": 
"includes/PhpTagsFuncDatePeriod.php",
+               "PhpTagsObjects\\PhpTagsWebRequest": 
"includes/PhpTagsWebRequest.php"
+       },
+       "Hooks": {
+               "ParserFirstCallInit": 
"PhpTagsFunctionsHooks::onParserFirstCallInit",
+               "PhpTagsRuntimeFirstInit": 
"PhpTagsFunctionsHooks::onPhpTagsRuntimeFirstInit",
+               "UnitTestsList": "PhpTagsFunctionsHooks::onUnitTestsList"
+       },
+       "ParserTestFiles": [
+               "tests/parser/PhpTagsFunctionsTests.txt"
+       ],
+       "manifest_version": 1
+}
diff --git a/i18n/en.json b/i18n/en.json
index 445243e..a3b06fd 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -1,11 +1,11 @@
 {
-    "@metadata": {
-        "authors": [
-            "pastakhov"
-        ]
-    },
-    "phptagsfunctions-desc": "Implements the internal functions of native PHP 
for the extension PhpTags",
-    "phptagsfunctions-preg-bad-delimiter": "Delimiter must not be alphanumeric 
or backslash",
-    "phptagsfunctions-preg-no-ending-delimiter": "No ending delimiter \"$1\" 
found",
-    "phptagsfunctions-preg-unknown-modifier": "Unknown modifier \"$1\""
+       "@metadata": {
+               "authors": [
+                       "pastakhov"
+               ]
+       },
+       "phptagsfunctions-desc": "Implements the internal functions of native 
PHP for the extension PhpTags",
+       "phptagsfunctions-preg-bad-delimiter": "Delimiter must not be 
alphanumeric or backslash",
+       "phptagsfunctions-preg-no-ending-delimiter": "No ending delimiter 
\"$1\" found",
+       "phptagsfunctions-preg-unknown-modifier": "Unknown modifier \"$1\""
 }
diff --git a/i18n/ko.json b/i18n/ko.json
index 1be3b82..802ccab 100644
--- a/i18n/ko.json
+++ b/i18n/ko.json
@@ -1,11 +1,12 @@
 {
        "@metadata": {
                "authors": [
-                       "Priviet"
+                       "Priviet",
+                       "Ykhwong"
                ]
        },
        "phptagsfunctions-desc": "확장 PhpTags를 위한 native PHP 내부 함수를 구현",
-       "phptagsfunctions-preg-bad-delimiter": "구분 기호는 알파벳, 숫자, 백슬래시가 아니여야 합니다",
+       "phptagsfunctions-preg-bad-delimiter": "구분 기호는 영숫자나 백슬래시가 아니어야 합니다",
        "phptagsfunctions-preg-no-ending-delimiter": "\"$1\" 끝 구분 기호를 찾을 수 
없습니다",
        "phptagsfunctions-preg-unknown-modifier": "알 수 없는 수식어 \"$1\""
 }
diff --git a/includes/PhpTagsFunc.php b/includes/PhpTagsFunc.php
index 8ab9ac3..83478ef 100644
--- a/includes/PhpTagsFunc.php
+++ b/includes/PhpTagsFunc.php
@@ -45,13 +45,12 @@
 
        public static function __callStatic( $name, $arguments ) {
                list ( $callType, $subname ) = explode( '_', $name, 2 );
-               $lowSubname = strtolower( $subname );
 
                if ( $callType === 'f' ) {
-                       if ( isset( self::$bannedFunctions[$lowSubname] ) ) {
-                               throw new \PhpTags\PhpTagsException( 
\PhpTags\PhpTagsException::FATAL_CALLFUNCTION_INVALID_HOOK, 
static::getClassName() );
+                       if ( isset( self::$bannedFunctions[$subname] ) ) {
+                               throw new \PhpTags\PhpTagsException( 
\PhpTags\PhpTagsException::FATAL_CALLFUNCTION_INVALID_HOOK, get_called_class() 
);
                        }
-                       if ( $lowSubname === 'array_multisort' ) {
+                       if ( $subname === 'array_multisort' ) {
                                return self::array_multisort( $arguments );
                        }
                        return call_user_func_array( $subname, $arguments );
@@ -97,45 +96,59 @@
        }
 
        public static function f_printf() {
-               $arguments = func_get_args();
-               $ret = call_user_func_array( 'sprintf', $arguments );
+               $args = func_get_args();
+               $v = array();
+               foreach ( $args as $value => $key ) {
+                       $v[$key] = self::getValidDumpValue( $value );
+               }
+               $ret = call_user_func_array( 'sprintf', $v );
                return new \PhpTags\outPrint( strlen($ret), $ret, false, false 
);
        }
 
        public static function f_vprintf() {
-               $arguments = func_get_args();
-               $ret = call_user_func_array( 'vsprintf', $arguments );
+               $args = func_get_args();
+               $v = array();
+               foreach ( $args as $value => $key ) {
+                       $v[$key] = self::getValidDumpValue( $value );
+               }
+               $ret = call_user_func_array( 'vsprintf', $v );
                return new \PhpTags\outPrint( strlen($ret), $ret, false, false 
);
        }
 
        public static function f_var_export( $expression, $return = false ) {
-               if ( $expression instanceof \PhpTags\GenericObject ) {
-                       $expression = $expression->getValue();
-               }
-               $ret = var_export( $expression, true );
+               $v = self::getValidDumpValue( $expression );
+               $ret = var_export( $v, true );
                return $return ? $ret : new \PhpTags\outPrint( null, $ret );
        }
 
        public static function f_var_dump() {
                $args = func_get_args();
-               foreach ( $args as &$value ) {
-                       if ( $value instanceof \PhpTags\GenericObject ) {
-                               $value = $value->getValue();
-                       }
+               $v = array();
+               foreach ( $args as $value => $key ) {
+                       $v[$key] = self::getValidDumpValue( $value );
                }
                ob_start();
-               call_user_func_array( 'var_dump', $args );
+               call_user_func_array( 'var_dump', $v );
                return new \PhpTags\outPrint( null, ob_get_clean() );
        }
 
        public static function f_print_r( $expression, $return = false ) {
-               if ( $expression instanceof \PhpTags\GenericObject ) {
-                       $expression = $expression->getValue();
-               }
-               $ret = print_r( $expression, true );
+               $v = self::getValidDumpValue( $expression );
+               $ret = print_r( $v, true );
                return $return ? $ret : new \PhpTags\outPrint( true, $ret );
        }
 
+       private static function getValidDumpValue( $expression ) {
+               if ( is_object( $expression ) ) {
+                       if ( $expression instanceof \PhpTags\GenericObject ) {
+                               return (array)$expression->getDumpValue();
+                       } else {
+                               throw new PhpTagsException( 
PhpTagsException::FATAL_INTERNAL_ERROR );
+                       }
+               }
+               return $expression;
+       }
+
        /**
         * @todo remove it for PHP >= 5.4.0
         */
diff --git a/includes/PhpTagsFuncUseful.php b/includes/PhpTagsFuncUseful.php
index 0122ddb..cc9eb4a 100644
--- a/includes/PhpTagsFuncUseful.php
+++ b/includes/PhpTagsFuncUseful.php
@@ -15,23 +15,15 @@
                switch ( $constantName ) {
                        case 'UUID':
                                return self::f_uuid_create();
+                       case 'PHPTAGS_FUNCTIONS_VERSION':
+                               $allThings = 
\ExtensionRegistry::getInstance()->getAllThings();
+                               return $allThings['PhpTags 
Functions']['version'];
                }
                parent::getConstantValue( $constantName );
        }
 
        public static function f_uuid_create() {
-               if ( function_exists( 'uuid_create' ) ) {
-                       // create random UUID use PECL uuid extension
-                       return uuid_create();
-               }
-               // Alternate creation method from 
http://aaronsaray.com/blog/2009/01/14/php-and-the-uuid/comment-page-1/#comment-1522
-               // May not be as fast or as accurate to specification as 
php5-uuid
-               return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
-                               mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), 
mt_rand( 0, 0xffff ),
-                               mt_rand( 0, 0x0fff ) | 0x4000,
-                               mt_rand( 0, 0x3fff ) | 0x8000,
-                               mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), 
mt_rand( 0, 0xffff )
-                       );
+               return \UIDGenerator::newUUIDv4();
        }
 
        public static function f_mw_json_decode( $value ) {
@@ -65,11 +57,22 @@
        public static function f_transclude( $template, $parameters = array(), 
$default = null ) {
                $parser = \PhpTags\Renderer::getParser();
                $frame = \PhpTags\Renderer::getFrame();
+
+               foreach ( $parameters as $key => $value ) {
+                       if ( is_scalar( $value ) ) {
+                               $parameters[$key] = (string)$value;
+                               continue;
+                       }
+                       throw new \PhpTags\HookException( 'Expects parameter 2 
to be array that contains only string values' );
+               }
+
                if ( $frame->depth >= $parser->mOptions->getMaxTemplateDepth() 
) {
                        throw new \PhpTags\HookException( 'Template depth limit 
exceeded' );
                }
 
-               if ( $template instanceof \PhpTags\GenericObject ) {
+               if ( $template === false || $template === true || $template === 
null ) {
+                       $title = false;
+               } else if ( $template instanceof \PhpTags\GenericObject ) {
                        $title = $template->value;
                        if ( false === $title instanceof \Title ) {
                                if ( $template->getName() !== 'WTitle' ) {
@@ -83,30 +86,38 @@
                        throw new \PhpTags\PhpTagsException( 
\PhpTags\PhpTagsException::WARNING_EXPECTS_PARAMETER, array(1, 'string or 
WTitle', gettype($template))     );
                }
 
-               if ( \MWNamespace::isNonincludable( $title->getNamespace() ) ) {
-                       throw new \PhpTags\HookException( 'Template inclusion 
denied' );
-               }
-               list( $dom, $finalTitle ) = $parser->getTemplateDom( $title );
-               if ( $dom === false ) {
-                       if ( $default !== null ) {
-                               return $default;
+               if ( $title ) {
+                       if ( \MWNamespace::isNonincludable( 
$title->getNamespace() ) ) {
+                               throw new \PhpTags\HookException( 'Template 
inclusion denied' );
                        }
-                       throw new \PhpTags\HookException( "Template 
\"{$title->getPrefixedText()}\" does not exist" );
-               }
-               if ( !$frame->loopCheck( $finalTitle ) ) {
-                       throw new \PhpTags\HookException( 'Template loop 
detected' );
+                       if ( $title->isExternal() ) {
+                               throw new \PhpTags\HookException( 'Cannot 
transclude external template' );
+                       }
+                       if ( $title->isSpecialPage() ) {
+                               throw new \PhpTags\HookException( 'Cannot 
transclude special page' );
+                       }
+
+                       list( $dom, $finalTitle ) = $parser->getTemplateDom( 
$title );
+                       if ( !$frame->loopCheck( $finalTitle ) ) {
+                               throw new \PhpTags\HookException( 'Template 
loop detected' );
+                       }
                }
 
-               foreach ( $parameters as $key => $value ) {
-                       if ( is_scalar( $value ) ) {
-                               $parameters[$key] = (string)$value;
-                               continue;
+               if ( !$title || !$dom ) {
+                       if ( $default === null ) {
+                               $titleName = $title ? '"' . 
$title->getPrefixedText() . '"' : 'NULL';
+                               throw new \PhpTags\HookException( "Template 
$titleName does not exist" );
                        }
-                       throw new \PhpTags\HookException( 'Expects parameter 2 
to be array that contains only string values' );
+                       $dom = $parser->getPreprocessor()->preprocessToObj(
+                                       str_replace( array( "\r\n", "\r" ), 
"\n", $default ),
+                                       $frame->depth ? 
Parser::PTD_FOR_INCLUSION : 0
+                               );
+                       $newFrame = $parser->getPreprocessor()->newFrame();
+               } else {
+                       $fargs = $parser->getPreprocessor()->newPartNodeArray( 
$parameters );
+                       $newFrame = $frame->newChild( $fargs, $finalTitle, -1 );
                }
 
-               $fargs = $parser->getPreprocessor()->newPartNodeArray( 
$parameters );
-               $newFrame = $frame->newChild( $fargs, $finalTitle, -1 );
                return $newFrame->expand( $dom );
        }
 
diff --git a/tests/parser/PhpTagsFunctionsTests.txt 
b/tests/parser/PhpTagsFunctionsTests.txt
index 44f6c58..a420b6f 100644
--- a/tests/parser/PhpTagsFunctionsTests.txt
+++ b/tests/parser/PhpTagsFunctionsTests.txt
@@ -44,7 +44,40 @@
 <phptag>
 echo "Hello\n\n";
 $foo = transclude( "Echo", ['1', '22', '333', '4444'] );
-echo $foo;
+echo "\n\n$foo";
+echo "\n\nBye";
+</phptag>
+!! result
+<p>Hello
+</p><p><br />
+</p><p>1223334444
+</p><p>Bye
+</p>
+!! end
+
+!! test
+Transclude Echo2
+!! input
+<phptag>
+echo "Hello\n\n";
+$foo = transclude( "Echo", ['1', '22', '333', '4444'], null );
+echo "\n\nBye";
+echo "\n\n$foo";
+</phptag>
+!! result
+<p>Hello
+</p><p><br />
+</p><p>Bye
+</p><p>1223334444
+</p>
+!! end
+
+!! test
+Transclude Echo3
+!! input
+<phptag>
+echo "Hello\n\n";
+echo transclude( false, [], '{{Echo|1|22|333|4444}}' );
 echo "\n\nBye";
 </phptag>
 !! result
@@ -59,8 +92,7 @@
 !! input
 <phptag>
 echo "Hello\n\n";
-$foo = transclude( "Dump", ['1', '22', '333', '4444', 'test'=>'TEST'] );
-echo $foo;
+echo transclude( "Dump", ['1', '22', '333', '4444', 'test'=>'TEST'] );
 echo "\n\nBye";
 </phptag>
 !! result
@@ -83,8 +115,7 @@
 !! text
 <phptag>
 echo "Hello\n\n";
-$foo = transclude( ":Transclude Loop", ['1', '22', '333', '4444', 
'test'=>'TEST'] );
-echo $foo;
+transclude( ":Transclude Loop", ['1', '22', '333', '4444', 'test'=>'TEST'] );
 echo "\n\nBye";
 </phptag>
 !! endarticle
diff --git "a/tests/phpunit/\041\041\041firstInit_Test.php" 
"b/tests/phpunit/\041\041\041firstInit_Test.php"
index ae2df53..2180402 100644
--- "a/tests/phpunit/\041\041\041firstInit_Test.php"
+++ "b/tests/phpunit/\041\041\041firstInit_Test.php"
@@ -1,6 +1,7 @@
 <?php
 
 if ( PhpTags\Renderer::$needInitRuntime ) {
+       wfDebug( 'PHPTags: run hook PhpTagsRuntimeFirstInit ' . __FILE__ );
        \Hooks::run( 'PhpTagsRuntimeFirstInit' );
        \PhpTags\Hooks::loadData();
        \PhpTags\Runtime::$loopsLimit = 1000;
diff --git a/tests/phpunit/PhpTagsFunctions_DateTime_Test.php 
b/tests/phpunit/PhpTagsFunctions_DateTime_Test.php
index 2ed3ece..ddada37 100644
--- a/tests/phpunit/PhpTagsFunctions_DateTime_Test.php
+++ b/tests/phpunit/PhpTagsFunctions_DateTime_Test.php
@@ -93,21 +93,20 @@
        public function testRun_DateTime_exception_9() {
                $this->assertEquals(
                                Runtime::runSource('new DateTime() . 5;', 
array('Page') ),
-                               array( (string) new \PhpTags\PhpTagsException( 
\PhpTags\PhpTagsException::NOTICE_OBJECT_CONVERTED, array('DateTime', 
'string'), 1, 'Page' ) )
+                               array( (string) new \PhpTags\PhpTagsException( 
\PhpTags\PhpTagsException::FATAL_OBJECT_COULD_NOT_BE_CONVERTED, 
array('DateTime', 'string'), 1, 'Page' ) )
                        );
        }
        public function testRun_DateTime_exception_10() {
                $this->assertEquals(
                                Runtime::runSource('5 . new 
DateInterval("P2Y4DT6H8M");', array('Page') ),
-                               array( (string) new \PhpTags\PhpTagsException( 
\PhpTags\PhpTagsException::NOTICE_OBJECT_CONVERTED, array('DateInterval', 
'string'), 1, 'Page' ) )
+                               array( (string) new \PhpTags\PhpTagsException( 
\PhpTags\PhpTagsException::FATAL_OBJECT_COULD_NOT_BE_CONVERTED, 
array('DateInterval', 'string'), 1, 'Page' ) )
                        );
        }
        public function testRun_DateTime_exception_11() {
                $this->assertEquals(
                                Runtime::runSource('new DateTime() . new 
DateInterval("P2Y4DT6H8M");', array('Page') ),
                                array(
-                                       (string) new \PhpTags\PhpTagsException( 
\PhpTags\PhpTagsException::NOTICE_OBJECT_CONVERTED, array('DateTime', 
'string'), 1, 'Page' ),
-                                       (string) new \PhpTags\PhpTagsException( 
\PhpTags\PhpTagsException::NOTICE_OBJECT_CONVERTED, array('DateInterval', 
'string'), 1, 'Page' )
+                                       (string) new \PhpTags\PhpTagsException( 
\PhpTags\PhpTagsException::FATAL_OBJECT_COULD_NOT_BE_CONVERTED, 
array('DateTime', 'string'), 1, 'Page' ),
                                )
                        );
        }
diff --git a/tests/phpunit/PhpTagsFunctions_Useful_Test.php 
b/tests/phpunit/PhpTagsFunctions_Useful_Test.php
index 3c65efd..e8393fc 100644
--- a/tests/phpunit/PhpTagsFunctions_Useful_Test.php
+++ b/tests/phpunit/PhpTagsFunctions_Useful_Test.php
@@ -10,6 +10,14 @@
                        );
        }
 
+       public function testRun_constant_2() {
+               $allThings = \ExtensionRegistry::getInstance()->getAllThings();
+               $this->assertEquals(
+                               Runtime::runSource('echo 
PHPTAGS_FUNCTIONS_VERSION;'),
+                               array( $allThings['PhpTags 
Functions']['version'] )
+                       );
+       }
+
        public function testRun_uuid_create_1() {
                $this->assertEquals(
                                Runtime::runSource('echo strlen( uuid_create() 
);'),
diff --git a/tests/phpunit/PhpTagsFunctions_Var_Test.php 
b/tests/phpunit/PhpTagsFunctions_Var_Test.php
index 0b22a66..c63a589 100644
--- a/tests/phpunit/PhpTagsFunctions_Var_Test.php
+++ b/tests/phpunit/PhpTagsFunctions_Var_Test.php
@@ -167,6 +167,12 @@
                                array('34')
                                );
        }
+       public function testRun_intval_6_1() {
+               $this->assertEquals(
+                               Runtime::runSource('echo intval(-042);'),
+                               array('-34')
+                               );
+       }
        public function testRun_intval_7() {
                $this->assertEquals(
                                Runtime::runSource('echo intval("042");'),

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I255e4a41b5c26af151c76c80293f46ccf16274d8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PhpTagsFunctions
Gerrit-Branch: REL1_26
Gerrit-Owner: Pastakhov <[email protected]>

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

Reply via email to