From: Kevin Israel Date: Wed, 18 Jun 2014 01:40:03 +0000 (-0400) Subject: GlobalFunctions: Deprecate swap() X-Git-Tag: 1.31.0-rc.0~15019^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20%20%20%24self2%20.%20%20%20%22&var_mode_affiche=boucle?a=commitdiff_plain;h=26e1e083e8bfd4f6e95baaeec6a681c2c0d74531;p=lhc%2Fweb%2Fwiklou.git GlobalFunctions: Deprecate swap() This unprefixed function, added in r7198 (2b3f4c749d3d), has been unused since r12411 (f2a59db33f33). It is short and simple enough that on the rare occasions it is needed, it can be inlined or copied into the calling class as a private method. Alternatively, the idiom `list( $a, $b ) = array( $b, $a )` can be used. Change-Id: Ieb4602597a54eb21a5de177fee6dafa7ac71ce1d --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index c95c380541..298ee586a2 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2592,10 +2592,12 @@ function wfIsHHVM() { /** * Swap two variables * + * @deprecated since 1.24 * @param mixed $x * @param mixed $y */ function swap( &$x, &$y ) { + wfDeprecated( __FUNCTION__, '1.24' ); $z = $x; $x = $y; $y = $z; diff --git a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php index 06b512d7ac..91b531d0e4 100644 --- a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php +++ b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php @@ -369,6 +369,8 @@ class GlobalTest extends MediaWikiTestCase { * @covers ::swap */ public function testSwapVarsTest() { + $this->hideDeprecated( 'swap' ); + $var1 = 1; $var2 = 2;