From 4675950b19e58ac702111f51336f132ce97adef5 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Thu, 29 Jan 2015 10:30:57 -0800 Subject: [PATCH] StringUtils: throw InvalidArgumentException and move into libs/ Bug: T87863 Change-Id: Iac5bd958c27cad834e35930d0b99adb75c60411b --- autoload.php | 2 +- includes/{utils => libs}/StringUtils.php | 6 +++--- tests/phpunit/includes/{utils => libs}/StringUtilsTest.php | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename includes/{utils => libs}/StringUtils.php (98%) rename tests/phpunit/includes/{utils => libs}/StringUtilsTest.php (100%) diff --git a/autoload.php b/autoload.php index e6f0f89bd7..90cd074d7d 100644 --- a/autoload.php +++ b/autoload.php @@ -1155,7 +1155,7 @@ $wgAutoloadLocalClasses = array( 'StoreFileOp' => __DIR__ . '/includes/filebackend/FileOp.php', 'StreamFile' => __DIR__ . '/includes/StreamFile.php', 'StringPrefixSearch' => __DIR__ . '/includes/PrefixSearch.php', - 'StringUtils' => __DIR__ . '/includes/utils/StringUtils.php', + 'StringUtils' => __DIR__ . '/includes/libs/StringUtils.php', 'StripState' => __DIR__ . '/includes/parser/StripState.php', 'StubObject' => __DIR__ . '/includes/StubObject.php', 'StubUserLang' => __DIR__ . '/includes/StubObject.php', diff --git a/includes/utils/StringUtils.php b/includes/libs/StringUtils.php similarity index 98% rename from includes/utils/StringUtils.php rename to includes/libs/StringUtils.php index 77fff595bd..11ae0b26f2 100644 --- a/includes/utils/StringUtils.php +++ b/includes/libs/StringUtils.php @@ -162,7 +162,7 @@ class StringUtils { * @param callable $callback Function to call on each match * @param string $subject * @param string $flags Regular expression flags - * @throws MWException + * @throws InvalidArgumentException * @return string */ static function delimiterReplaceCallback( $startDelim, $endDelim, $callback, @@ -197,7 +197,7 @@ class StringUtils { $tokenType = 'end'; $tokenLength = strlen( $m[0][0] ); } else { - throw new MWException( 'Invalid delimiter given to ' . __METHOD__ ); + throw new InvalidArgumentException( 'Invalid delimiter given to ' . __METHOD__ ); } if ( $tokenType == 'start' ) { @@ -230,7 +230,7 @@ class StringUtils { } $inputPos = $outputPos = $tokenOffset + $tokenLength; } else { - throw new MWException( 'Invalid delimiter given to ' . __METHOD__ ); + throw new InvalidArgumentException( 'Invalid delimiter given to ' . __METHOD__ ); } } if ( $outputPos < strlen( $subject ) ) { diff --git a/tests/phpunit/includes/utils/StringUtilsTest.php b/tests/phpunit/includes/libs/StringUtilsTest.php similarity index 100% rename from tests/phpunit/includes/utils/StringUtilsTest.php rename to tests/phpunit/includes/libs/StringUtilsTest.php -- 2.20.1