jenkins-bot has submitted this change and it was merged.
Change subject: hook release 4 (v 3.2.0)
......................................................................
hook release 4 (v 3.2.0)
Change-Id: If99e46ec4afe2b4493ad1bfae31ce0bdca34d51a
---
M PhpTagsFunctions.init.php
M PhpTagsFunctions.php
M includes/PhpTagsFuncNativeObject.php
M includes/PhpTagsFuncRef.php
A tests/parser/PhpTagsFunctionsTests.txt
M tests/phpunit/PhpTagsFunctions_DateTime_Test.php
M tests/phpunit/PhpTagsFunctions_String_Test.php
M tests/phpunit/PhpTagsFunctions_Var_Test.php
8 files changed, 54 insertions(+), 34 deletions(-)
Approvals:
Pastakhov: Looks good to me, approved
jenkins-bot: Verified
diff --git a/PhpTagsFunctions.init.php b/PhpTagsFunctions.init.php
index c52d7fa..0655757 100644
--- a/PhpTagsFunctions.init.php
+++ b/PhpTagsFunctions.init.php
@@ -544,7 +544,6 @@
'timezone_offset_get',
'timezone_open',
'timezone_transitions_get',
- 'timezone_abbreviations_list',
'timezone_version_get',
);
}
diff --git a/PhpTagsFunctions.php b/PhpTagsFunctions.php
index 3b6a210..9efb2f3 100644
--- a/PhpTagsFunctions.php
+++ b/PhpTagsFunctions.php
@@ -19,7 +19,7 @@
die( 'ERROR: The <a
href="https://www.mediawiki.org/wiki/Extension:PhpTags">extension PhpTags</a>
must be installed for the extension PhpTags Functions to run!' );
}
-$needVersion = '2.1.0';
+$needVersion = '2.5.0';
if ( version_compare( PHPTAGS_VERSION, $needVersion, '<' ) ) {
die(
'<b>Error:</b> This version of extension PhpTags Functions
needs <a href="https://www.mediawiki.org/wiki/Extension:PhpTags">PhpTags</a> '
. $needVersion . ' or later.
@@ -27,13 +27,13 @@
);
}
-if ( PHPTAGS_HOOK_RELEASE != 3 ) {
+if ( PHPTAGS_HOOK_RELEASE != 4 ) {
die (
'<b>Error:</b> This version of extension PhpTags
Functions is not compatible to current version of extension PhpTags.'
);
}
-define( 'PHPTAGS_FUNCTIONS_VERSION' , '3.1.2' );
+define( 'PHPTAGS_FUNCTIONS_VERSION' , '3.2.0' );
// Register this extension on Special:Version
$wgExtensionCredits['phptags'][] = array(
@@ -71,3 +71,5 @@
$files = array_merge( $files, glob( "$testDir/*Test.php" ) );
return true;
};
+
+$wgParserTestFiles[] = __DIR__ . '/tests/parser/PhpTagsFunctionsTests.txt';
diff --git a/includes/PhpTagsFuncNativeObject.php
b/includes/PhpTagsFuncNativeObject.php
index 3141e2e..3402568 100644
--- a/includes/PhpTagsFuncNativeObject.php
+++ b/includes/PhpTagsFuncNativeObject.php
@@ -70,7 +70,7 @@
}
return $return;
} else {
- throw new
\PhpTags\PhpTagsException( PHPTAGS_EXCEPTION_FATAL_NONSTATIC_CALLED_STATICALLY,
array($object, $subname) );
+ throw new
\PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::FATAL_NONSTATIC_CALLED_STATICALLY, array($object,
$subname) );
}
} catch (ReflectionException $e) {}
diff --git a/includes/PhpTagsFuncRef.php b/includes/PhpTagsFuncRef.php
index 1e77457..7702320 100644
--- a/includes/PhpTagsFuncRef.php
+++ b/includes/PhpTagsFuncRef.php
@@ -82,7 +82,7 @@
$args[0] = self::getValidPattern( $args[0] );
}
} catch ( \Exception $exc ) {
- throw new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_FROM_HOOK, array( 'preg_replace(): ' . $exc->getMessage(),
$exc->getCode() ) );
+ throw new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::EXCEPTION_FROM_HOOK, array( 'preg_replace(): ' .
$exc->getMessage(), $exc->getCode() ) );
}
return call_user_func_array( 'preg_replace', $args );
@@ -99,7 +99,7 @@
if ( $delimPos === false ) {
throw new Exception(
wfMessage(
'phptagsfunctions-preg-bad-delimiter' )->text(),
- PHPTAGS_EXCEPTION_WARNING
+
\PhpTags\PhpTagsException::EXCEPTION_WARNING
);
}
@@ -111,7 +111,7 @@
if ( $pos === false ) {
throw new Exception(
wfMessage(
'phptagsfunctions-preg-no-ending-delimiter', $end )->text(),
- PHPTAGS_EXCEPTION_WARNING
+
\PhpTags\PhpTagsException::EXCEPTION_WARNING
);
}
$backslashes = 0;
@@ -134,7 +134,7 @@
if ( strpos( $regexModifiers, $endRegex[$c] ) === false
) {
throw new Exception(
wfMessage(
'phptagsfunctions-preg-unknown-modifier', $endRegex[$c] )->text(),
- PHPTAGS_EXCEPTION_WARNING
+
\PhpTags\PhpTagsException::EXCEPTION_WARNING
);
}
}
diff --git a/tests/parser/PhpTagsFunctionsTests.txt
b/tests/parser/PhpTagsFunctionsTests.txt
new file mode 100644
index 0000000..8683e16
--- /dev/null
+++ b/tests/parser/PhpTagsFunctionsTests.txt
@@ -0,0 +1,19 @@
+!! article
+Template:Get random argument
+!! text
+<phptag>
+array_shift( $argv ); # $argv is array that contains the passed parameters
($argv[0] is always page name, need to remove it here)
+shuffle ( $argv ); # shuffles the array
+$return = array_pop( $argv ); # get the last value of the array
+echo trim( $return ); # the string can contain unnecessary spaces, remove them
+</phptag>
+!! endarticle
+
+!! test
+Get random argument
+!! input
+{{Get random argument | One }}
+!! result
+<p>One
+</p>
+!! end
\ No newline at end of file
diff --git a/tests/phpunit/PhpTagsFunctions_DateTime_Test.php
b/tests/phpunit/PhpTagsFunctions_DateTime_Test.php
index f41da05..fe3abb2 100644
--- a/tests/phpunit/PhpTagsFunctions_DateTime_Test.php
+++ b/tests/phpunit/PhpTagsFunctions_DateTime_Test.php
@@ -32,71 +32,71 @@
public function testRun_DateTime_exception_1() {
$this->assertEquals(
Runtime::runSource('$date = DateTime(5);',
array('Page') ),
- array( new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_FATAL_CALL_TO_UNDEFINED_FUNCTION, 'DateTime', 1, 'Page' ) )
+ array( new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::FATAL_CALL_TO_UNDEFINED_FUNCTION, 'DateTime', 1,
'Page' ) )
);
}
public function testRun_DateTime_exception_2() {
$this->assertEquals(
Runtime::runSource('$date = new
DateTimeUndefined(5);', array('Page') ),
- array( new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_FATAL_CLASS_NOT_FOUND, 'DateTimeUndefined', 1, 'Page' ) )
+ array( new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::FATAL_CLASS_NOT_FOUND, 'DateTimeUndefined', 1,
'Page' ) )
);
}
public function testRun_DateTime_exception_3() {
$return = Runtime::runSource('$date = new DateTime(5);',
array('Page') );
$this->assertInstanceOf( '\PhpTags\PhpTagsException',
$return[0] );
- $this->assertEquals(
PHPTAGS_EXCEPTION_FATAL_OBJECT_NOT_CREATED, $return[0]->getCode() );
+ $this->assertEquals(
\PhpTags\PhpTagsException::FATAL_OBJECT_NOT_CREATED, $return[0]->getCode() );
}
public function testRun_DateTime_exception_4() {
$this->assertEquals(
Runtime::runSource('$date = new DateTime();
$date->undefined();', array('Page') ),
- array( (string) new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_FATAL_CALL_TO_UNDEFINED_METHOD, array('DateTime',
'undefined'), 1, 'Page' ) )
+ array( (string) new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::FATAL_CALL_TO_UNDEFINED_METHOD, array('DateTime',
'undefined'), 1, 'Page' ) )
);
}
public function testRun_DateTime_exception_5() {
$this->assertEquals(
Runtime::runSource('$date =
date_create_undefined();', array('Page') ),
- array( new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_FATAL_CALL_TO_UNDEFINED_FUNCTION, 'date_create_undefined', 1,
'Page' ) )
+ array( new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::FATAL_CALL_TO_UNDEFINED_FUNCTION,
'date_create_undefined', 1, 'Page' ) )
);
}
public function testRun_DateTime_exception_6() {
$this->assertEquals(
Runtime::runSource('new DateTime() + 5;',
array('Page') ),
- array( new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_NOTICE_OBJECT_CONVERTED, array('DateTime', 'int'), 1, 'Page'
) )
+ array( new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::NOTICE_OBJECT_CONVERTED, array('DateTime', 'int'),
1, 'Page' ) )
);
}
public function testRun_DateTime_exception_7() {
$this->assertEquals(
Runtime::runSource('5 + new
DateInterval("P2Y4DT6H8M");', array('Page') ),
- array( new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_NOTICE_OBJECT_CONVERTED, array('DateInterval', 'int'), 1,
'Page' ) )
+ array( new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::NOTICE_OBJECT_CONVERTED, array('DateInterval',
'int'), 1, 'Page' ) )
);
}
public function testRun_DateTime_exception_8() {
$this->assertEquals(
Runtime::runSource('new DateTime() + new
DateInterval("P2Y4DT6H8M");', array('Page') ),
array(
- new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_NOTICE_OBJECT_CONVERTED, array('DateTime', 'int'), 1, 'Page'
),
- new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_NOTICE_OBJECT_CONVERTED, array('DateInterval', 'int'), 1,
'Page' )
+ new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::NOTICE_OBJECT_CONVERTED, array('DateTime', 'int'),
1, 'Page' ),
+ new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::NOTICE_OBJECT_CONVERTED, array('DateInterval',
'int'), 1, 'Page' )
)
);
}
public function testRun_DateTime_exception_9() {
$this->assertEquals(
Runtime::runSource('new DateTime() . 5;',
array('Page') ),
- array( new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_NOTICE_OBJECT_CONVERTED, array('DateTime', 'string'), 1,
'Page' ) )
+ array( new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::NOTICE_OBJECT_CONVERTED, array('DateTime',
'string'), 1, 'Page' ) )
);
}
public function testRun_DateTime_exception_10() {
$this->assertEquals(
Runtime::runSource('5 . new
DateInterval("P2Y4DT6H8M");', array('Page') ),
- array( new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_NOTICE_OBJECT_CONVERTED, array('DateInterval', 'string'), 1,
'Page' ) )
+ array( new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::NOTICE_OBJECT_CONVERTED, array('DateInterval',
'string'), 1, 'Page' ) )
);
}
public function testRun_DateTime_exception_11() {
$this->assertEquals(
Runtime::runSource('new DateTime() . new
DateInterval("P2Y4DT6H8M");', array('Page') ),
array(
- new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_NOTICE_OBJECT_CONVERTED, array('DateTime', 'string'), 1,
'Page' ),
- new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_NOTICE_OBJECT_CONVERTED, array('DateInterval', 'string'), 1,
'Page' )
+ new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::NOTICE_OBJECT_CONVERTED, array('DateTime',
'string'), 1, 'Page' ),
+ new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::NOTICE_OBJECT_CONVERTED, array('DateInterval',
'string'), 1, 'Page' )
)
);
}
@@ -104,7 +104,7 @@
$this->assertEquals(
Runtime::runSource('echo date_format(5,
"Y-m-d");', array('Page') ),
array(
- new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_WARNING_EXPECTS_PARAMETER, array('date_format', '1',
'DateTime', 'integer'), 1, 'Page' ),
+ new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::WARNING_EXPECTS_PARAMETER, array('date_format', '1',
'DateTime', 'integer'), 1, 'Page' ),
false
)
);
@@ -113,7 +113,7 @@
$this->assertEquals(
Runtime::runSource('echo date_format( new
DateTime(), new DateTime() );', array('Page') ),
array(
- new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_WARNING_EXPECTS_PARAMETER, array('date_format', '2',
'string', 'object'), 1, 'Page' ),
+ new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::WARNING_EXPECTS_PARAMETER, array('date_format', '2',
'string', 'object'), 1, 'Page' ),
false
)
);
@@ -122,7 +122,7 @@
$this->assertEquals(
Runtime::runSource('echo date_format(new
DateTime(), "Y-m-d", 5);', array('Page') ),
array(
- new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_WARNING_EXPECTS_EXACTLY_PARAMETERS, array('date_format', '2',
'3'), 1, 'Page' ),
+ new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::WARNING_EXPECTS_EXACTLY_PARAMETERS,
array('date_format', '2', '3'), 1, 'Page' ),
false
)
);
@@ -131,7 +131,7 @@
$this->assertEquals(
Runtime::runSource('echo date_format(new
DateTime());', array('Page') ),
array(
- new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_WARNING_EXPECTS_EXACTLY_PARAMETERS, array('date_format', '2',
'1'), 1, 'Page' ),
+ new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::WARNING_EXPECTS_EXACTLY_PARAMETERS,
array('date_format', '2', '1'), 1, 'Page' ),
false
)
);
@@ -139,13 +139,13 @@
public function testRun_DateTime_exception_16() {
$this->assertEquals(
Runtime::runSource('echo
DateTime::format("Y-m-d");', array('Page') ),
- array( new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_FATAL_NONSTATIC_CALLED_STATICALLY, array('DateTime',
'format'), 1, 'Page' ) )
+ array( new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::FATAL_NONSTATIC_CALLED_STATICALLY, array('DateTime',
'format'), 1, 'Page' ) )
);
}
public function testRun_DateTime_exception_17() {
$this->assertEquals(
Runtime::runSource('echo new DateTime();',
array('Page') ),
- array( 'object' )
+ array( new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::FATAL_OBJECT_COULD_NOT_BE_CONVERTED,
array('DateTime', 'string'), 1, 'Page' ) )
);
}
@@ -185,7 +185,7 @@
echo $i->yyyyyy;', array('Page') ),
array(
2,
- new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_NOTICE_UNDEFINED_PROPERTY, array('DateInterval', 'yyyyyy'),
4, 'Page' ),
+ new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::NOTICE_UNDEFINED_PROPERTY, array('DateInterval',
'yyyyyy'), 4, 'Page' ),
null,
)
);
@@ -236,7 +236,7 @@
public function testRun_DatePeriod_2() {
$this->assertEquals(
Runtime::runSource( 'echo
DatePeriod::UNDEFINED;', array('Page') ),
- array( new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_NOTICE_UNDEFINED_CLASS_CONSTANT, array('DatePeriod',
'UNDEFINED'), 1, 'Page' ), null )
+ array( new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::NOTICE_UNDEFINED_CLASS_CONSTANT, array('DatePeriod',
'UNDEFINED'), 1, 'Page' ), null )
);
}
public function testRun_DateTime_1() {
@@ -248,7 +248,7 @@
public function testRun_DateTime_2() {
$this->assertEquals(
Runtime::runSource( 'echo
DateTime::BLABLABLA;', array('Page') ),
- array( new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_NOTICE_UNDEFINED_CLASS_CONSTANT, array('DateTime',
'BLABLABLA'), 1, 'Page' ), null )
+ array( new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::NOTICE_UNDEFINED_CLASS_CONSTANT, array('DateTime',
'BLABLABLA'), 1, 'Page' ), null )
);
}
diff --git a/tests/phpunit/PhpTagsFunctions_String_Test.php
b/tests/phpunit/PhpTagsFunctions_String_Test.php
index d5e0650..56bfd8f 100644
--- a/tests/phpunit/PhpTagsFunctions_String_Test.php
+++ b/tests/phpunit/PhpTagsFunctions_String_Test.php
@@ -13,13 +13,13 @@
public function testRun_printf_exception_1() {
$this->assertEquals(
Runtime::runSource('sprintf();', array('Page')
),
- array( new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_WARNING_EXPECTS_AT_LEAST_PARAMETER, array('sprintf', 1, 0),
1, 'Page' ) )
+ array( new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::WARNING_EXPECTS_AT_LEAST_PARAMETER, array('sprintf',
1, 0), 1, 'Page' ) )
);
}
public function testRun_printf_exception_2() {
$this->assertEquals(
Runtime::runSource('sprintf("%d обезьян сидят
на %s", new DateTime(), "дереве");', array('Page') ),
- array( new \PhpTags\PhpTagsException(
PHPTAGS_EXCEPTION_NOTICE_OBJECT_CONVERTED, array('DateTime', 'int'), 1, 'Page'
) )
+ array( new \PhpTags\PhpTagsException(
\PhpTags\PhpTagsException::NOTICE_OBJECT_CONVERTED, array('DateTime', 'int'),
1, 'Page' ) )
);
}
diff --git a/tests/phpunit/PhpTagsFunctions_Var_Test.php
b/tests/phpunit/PhpTagsFunctions_Var_Test.php
index e471d2b..6f7f3bf 100644
--- a/tests/phpunit/PhpTagsFunctions_Var_Test.php
+++ b/tests/phpunit/PhpTagsFunctions_Var_Test.php
@@ -434,7 +434,7 @@
$this->assertEquals(
Runtime::runSource('echo is_null($inexistent) ?
"true" : "false";'),
array(
- (string) new PhpTagsException(
PHPTAGS_EXCEPTION_NOTICE_UNDEFINED_VARIABLE, 'inexistent', 1 ),
+ (string) new PhpTagsException(
\PhpTags\PhpTagsException::NOTICE_UNDEFINED_VARIABLE, 'inexistent', 1 ),
'true'
)
);
--
To view, visit https://gerrit.wikimedia.org/r/146389
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If99e46ec4afe2b4493ad1bfae31ce0bdca34d51a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PhpTagsFunctions
Gerrit-Branch: master
Gerrit-Owner: Pastakhov <[email protected]>
Gerrit-Reviewer: Pastakhov <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits