diff --git a/core/lib/Drupal/Component/Utility/Unicode.php b/core/lib/Drupal/Component/Utility/Unicode.php index cf979d9..cd48373 100644 --- a/core/lib/Drupal/Component/Utility/Unicode.php +++ b/core/lib/Drupal/Component/Utility/Unicode.php @@ -99,6 +99,15 @@ class Unicode { /** * Get the current status of unicode/multibyte support on this enviroment. + * + * @return int + * The status of multibyte support. It can be one of: + * - \Drupal\Component\Utility\Unicode::STATUS_MULTIBYTE + * Standard PHP (emulated) unicode support. + * - \Drupal\Component\Utility\Unicode::STATUS_SINGLEBYTE + * Full unicode support using an extension. + * - \Drupal\Component\Utility\Unicode::STATUS_ERROR + * An error occured. No unicode support. */ public static function getStatus() { return static::$status; @@ -107,16 +116,19 @@ public static function getStatus() { /** * Sets the value for multibyte support status for the current enviroment. * - * The following header keys are supported: - * - Unicode::STATUS_MULTIBYTE: Standard PHP (emulated) unicode support. - * - Unicode::STATUS_SINGLEBYTE: Full unicode support using an extension. - * - Unicode::STATUS_ERROR: An error occured. No unicode support. + * The following status keys are supported: + * - \Drupal\Component\Utility\Unicode::STATUS_MULTIBYTE + * Standard PHP (emulated) unicode support. + * - \Drupal\Component\Utility\Unicode::STATUS_SINGLEBYTE + * Full unicode support using an extension. + * - \Drupal\Component\Utility\Unicode::STATUS_ERROR + * An error occured. No unicode support. * * @param int $status * The new status of multibyte support. */ public static function setStatus($status) { - if (!in_array($status, array(self::STATUS_SINGLEBYTE, self::STATUS_MULTIBYTE, self::STATUS_ERROR))) { + if (!in_array($status, array(static::STATUS_SINGLEBYTE, static::STATUS_MULTIBYTE, static::STATUS_ERROR))) { throw new \InvalidArgumentException('Invalid status value for unicode support.'); } static::$status = $status; @@ -259,9 +271,9 @@ public static function strtoupper($text) { return mb_strtoupper($text); } else { - // Use C-locale for ASCII-only uppercase + // Use C-locale for ASCII-only uppercase. $text = strtoupper($text); - // Case flip Latin-1 accented letters + // Case flip Latin-1 accented letters. $text = preg_replace_callback('/\xC3[\xA0-\xB6\xB8-\xBE]/', '\Drupal\Component\Utility\Unicode::caseFlip', $text); return $text; } @@ -281,9 +293,9 @@ public static function strtolower($text) { return mb_strtolower($text); } else { - // Use C-locale for ASCII-only lowercase + // Use C-locale for ASCII-only lowercase. $text = strtolower($text); - // Case flip Latin-1 accented letters + // Case flip Latin-1 accented letters. $text = preg_replace_callback('/\xC3[\x80-\x96\x98-\x9E]/', '\Drupal\Component\Utility\Unicode::caseFlip', $text); return $text; } diff --git a/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php b/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php index 0b596a9..5f49a6d 100644 --- a/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php @@ -45,6 +45,12 @@ public function testStatus($value, $expected, $invalid = FALSE) { * Data provider for testStatus(). * * @see testStatus() + * + * @return array + * An array containing: + * - The status value to set. + * - The status value to expect after setting the new value. + * - (optional) Boolean indicating invalid status. Defaults to FALSE. */ public function providerTestStatus() { return array( @@ -72,6 +78,9 @@ public function testMimeHeader($value, $encoded) { * Data provider for testMimeHeader(). * * @see testMimeHeader() + * + * @return array + * An array containing a string and its encoded value. */ public function providerTestMimeHeader() { return array( @@ -95,6 +104,10 @@ public function testStrtolower($text, $expected, $multibyte = FALSE) { * Data provider for testStrtolower(). * * @see testStrtolower() + * + * @return array + * An array containing a string, its lowercase version and whether it should + * be processed as multibyte. */ public function providerStrtolower() { $cases = array( @@ -126,6 +139,10 @@ public function testStrtoupper($text, $expected, $multibyte = FALSE) { * Data provider for testStrtoupper(). * * @see testStrtoupper() + * + * @return array + * An array containing a string, its uppercase version and whether it should + * be processed as multibyte. */ public function providerStrtoupper() { $cases = array( @@ -155,6 +172,9 @@ public function testUcfirst($text, $expected) { * Data provider for testUcfirst(). * * @see testUcfirst() + * + * @return array + * An array containing a string and its uppercase first version. */ public function providerUcfirst() { return array( @@ -180,6 +200,9 @@ public function testStrlen($text, $expected) { * Data provider for testStrlen(). * * @see testStrlen() + * + * @return array + * An array containing a string and its length. */ public function providerStrlen() { return array( @@ -201,6 +224,13 @@ public function testSubstr($text, $start, $length, $expected) { * Data provider for testSubstr(). * * @see testSubstr() + * + * @return array + * An array containing: + * - The string to test. + * - The start number to be processed by substr. + * - The length number to be processed by substr. + * - The expected string result. */ public function providerSubstr() { return array( @@ -245,6 +275,14 @@ public function testTruncate($text, $max_length, $expected, $wordsafe = FALSE, $ * Data provider for testTruncate(). * * @see testTruncate() + * + * @return array + * An array containing: + * - The string to test. + * - The max length to truncate this string to. + * - The expected string result. + * - (optional) Boolean for the $wordsafe flag. Defaults to FALSE. + * - (optional) Boolean for the $add_ellipsis flag. Defaults to FALSE. */ public function providerTruncate() { return array(