From b0976c72b707fe7a427d5f03abbdffb7b6ff2306 Mon Sep 17 00:00:00 2001 From: "Daniel St. Jules" Date: Thu, 2 Mar 2017 23:58:05 -0500 Subject: [PATCH 1/8] Fix #116 with breaking change: add locale parameter to toAscii This fixes a previous regression in handling of some umlaut characters, and commits a breaking change by adding the param before $removeUnsupported --- README.md | 8 +++-- src/StaticStringy.php | 2 +- src/Stringy.php | 69 ++++++++++++++++++++++++++++++++++--------- tests/StringyTest.php | 10 +++++-- 4 files changed, 69 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index b77cc97..83bb6f9 100644 --- a/README.md +++ b/README.md @@ -916,14 +916,18 @@ s('i like to watch television')->titleize($ignore); // 'I Like to Watch Television' ``` -##### toAscii() +##### toAscii([, string $locale = 'en' [, bool $removeUnsupported = true ]]) Returns an ASCII version of the string. A set of non-ASCII characters are replaced with their closest ASCII counterparts, and the rest are removed -unless instructed otherwise. +unless instructed otherwise. The locale of the source string can be supplied +for locale-specific transliteration. The locale can be supplied in any of the +following formats: en, en_GB, or en-GB. ```php s('fòôbàř')->toAscii(); // 'foobar' +s('äöü')->toAscii(); // 'aou' +s('äöü')->toAscii('de'); // 'aeoeue' ``` ##### toBoolean() diff --git a/src/StaticStringy.php b/src/StaticStringy.php index f89b18d..4486665 100644 --- a/src/StaticStringy.php +++ b/src/StaticStringy.php @@ -72,7 +72,7 @@ use ReflectionMethod; * @method static string swapCase(string $str, string $encoding = null) * @method static string tidy(string $str, string $encoding = null) * @method static string titleize(string $str, string $encoding = null) - * @method static string toAscii(string $str, bool $removeUnsupported = true, string $encoding = null) + * @method static string toAscii(string $str, string $locale = 'en', bool $removeUnsupported = true, string $encoding = null) * @method static bool toBoolean(string $str, string $encoding = null) * @method static string toLowerCase(string $str, string $encoding = null) * @method static string toSpaces(string $str, int $tabLength = 4, string $encoding = null) diff --git a/src/Stringy.php b/src/Stringy.php index 0c982f0..0ade923 100644 --- a/src/Stringy.php +++ b/src/Stringy.php @@ -1424,16 +1424,22 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess /** * Returns an ASCII version of the string. A set of non-ASCII characters are * replaced with their closest ASCII counterparts, and the rest are removed - * unless instructed otherwise. + * unless instructed otherwise. The locale can be supplied in any of the + * following formats: en, en_GB, or en-GB. * + * @param string $locale Locale of the source string * @param bool $removeUnsupported Whether or not to remove the * unsupported characters * @return static Object whose $str contains only ASCII characters */ - public function toAscii($removeUnsupported = true) + public function toAscii($locale = 'en', $removeUnsupported = true) { $str = $this->str; + foreach ($this->localeSpecificCharsArray($locale) as $key => $value) { + $str = str_replace($value, $key, $str); + } + foreach ($this->charsArray() as $key => $value) { $str = str_replace($value, $key, $str); } @@ -1686,7 +1692,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ', 'အ', - 'ာ', 'ါ', 'ǻ', 'ǎ', 'ª', 'ა', 'अ', 'ا', 'a'), + 'ာ', 'ါ', 'ǻ', 'ǎ', 'ª', 'ა', 'अ', 'ا', 'a', 'ä'), 'b' => array('б', 'β', 'Ъ', 'Ь', 'ب', 'ဗ', 'ბ', 'b'), 'c' => array('ç', 'ć', 'č', 'ĉ', 'ċ', 'c'), 'd' => array('ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', @@ -1715,7 +1721,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess 'o' => array('ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ', 'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő', 'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', - 'о', 'و', 'θ', 'ို', 'ǒ', 'ǿ', 'º', 'ო', 'ओ', 'o'), + 'о', 'و', 'θ', 'ို', 'ǒ', 'ǿ', 'º', 'ო', 'ओ', 'o', + 'ö'), 'p' => array('п', 'π', 'ပ', 'პ', 'پ', 'p'), 'q' => array('ყ', 'q'), 'r' => array('ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر', 'რ', 'r'), @@ -1726,7 +1733,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess 'u' => array('ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', 'ừ', 'ử', 'ữ', 'ự', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у', 'ဉ', 'ု', 'ူ', 'ǔ', 'ǖ', 'ǘ', 'ǚ', 'ǜ', 'უ', 'उ', 'u', - 'ў'), + 'ў', 'ü'), 'v' => array('в', 'ვ', 'ϐ', 'v'), 'w' => array('ŵ', 'ω', 'ώ', 'ဝ', 'ွ', 'w'), 'x' => array('χ', 'ξ', 'x'), @@ -1734,7 +1741,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess 'ϋ', 'ύ', 'ΰ', 'ي', 'ယ', 'y'), 'z' => array('ź', 'ž', 'ż', 'з', 'ζ', 'ز', 'ဇ', 'ზ', 'z'), 'aa' => array('ع', 'आ', 'آ'), - 'ae' => array('ä', 'æ', 'ǽ'), + 'ae' => array('æ', 'ǽ'), 'ai' => array('ऐ'), 'at' => array('@'), 'ch' => array('ч', 'ჩ', 'ჭ', 'چ'), @@ -1747,7 +1754,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess 'kh' => array('х', 'خ', 'ხ'), 'lj' => array('љ'), 'nj' => array('њ'), - 'oe' => array('ö', 'œ', 'ؤ'), + 'oe' => array('œ', 'ؤ'), 'oi' => array('ऑ'), 'oii' => array('ऒ'), 'ps' => array('ψ'), @@ -1757,7 +1764,6 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess 'sx' => array('ŝ'), 'th' => array('þ', 'ϑ', 'ث', 'ذ', 'ظ'), 'ts' => array('ц', 'ც', 'წ'), - 'ue' => array('ü'), 'uu' => array('ऊ'), 'ya' => array('я'), 'yu' => array('ю'), @@ -1767,7 +1773,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess 'Ặ', 'Â', 'Ấ', 'Ầ', 'Ẩ', 'Ẫ', 'Ậ', 'Å', 'Ā', 'Ą', 'Α', 'Ά', 'Ἀ', 'Ἁ', 'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ', 'Ἇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ', 'Ᾱ', - 'Ὰ', 'Ά', 'ᾼ', 'А', 'Ǻ', 'Ǎ', 'A'), + 'Ὰ', 'Ά', 'ᾼ', 'А', 'Ǻ', 'Ǎ', 'A', 'Ä'), 'B' => array('Б', 'Β', 'ब', 'B'), 'C' => array('Ç','Ć', 'Č', 'Ĉ', 'Ċ', 'C'), 'D' => array('Ď', 'Ð', 'Đ', 'Ɖ', 'Ɗ', 'Ƌ', 'ᴅ', 'ᴆ', 'Д', 'Δ', @@ -1791,7 +1797,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess 'O' => array('Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ', 'Ộ', 'Ơ', 'Ớ', 'Ờ', 'Ở', 'Ỡ', 'Ợ', 'Ø', 'Ō', 'Ő', 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ', 'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ', 'Ὸ', - 'Ό', 'О', 'Θ', 'Ө', 'Ǒ', 'Ǿ', 'O'), + 'Ό', 'О', 'Θ', 'Ө', 'Ǒ', 'Ǿ', 'O', 'Ö'), 'P' => array('П', 'Π', 'P'), 'Q' => array('Q'), 'R' => array('Ř', 'Ŕ', 'Р', 'Ρ', 'Ŗ', 'R'), @@ -1799,14 +1805,14 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess 'T' => array('Ť', 'Ţ', 'Ŧ', 'Ț', 'Т', 'Τ', 'T'), 'U' => array('Ú', 'Ù', 'Ủ', 'Ũ', 'Ụ', 'Ư', 'Ứ', 'Ừ', 'Ử', 'Ữ', 'Ự', 'Û', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ų', 'У', 'Ǔ', 'Ǖ', - 'Ǘ', 'Ǚ', 'Ǜ', 'U', 'Ў'), + 'Ǘ', 'Ǚ', 'Ǜ', 'U', 'Ў', 'Ü'), 'V' => array('В', 'V'), 'W' => array('Ω', 'Ώ', 'Ŵ', 'W'), 'X' => array('Χ', 'Ξ', 'X'), 'Y' => array('Ý', 'Ỳ', 'Ỷ', 'Ỹ', 'Ỵ', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ', 'Ы', 'Й', 'Υ', 'Ϋ', 'Ŷ', 'Y'), 'Z' => array('Ź', 'Ž', 'Ż', 'З', 'Ζ', 'Z'), - 'AE' => array('Ä', 'Æ', 'Ǽ'), + 'AE' => array('Æ', 'Ǽ'), 'CH' => array('Ч'), 'DJ' => array('Ђ'), 'DZ' => array('Џ'), @@ -1817,14 +1823,13 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess 'KH' => array('Х'), 'LJ' => array('Љ'), 'NJ' => array('Њ'), - 'OE' => array('Ö', 'Œ'), + 'OE' => array('Œ'), 'PS' => array('Ψ'), 'SH' => array('Ш'), 'SHCH' => array('Щ'), 'SS' => array('ẞ'), 'TH' => array('Þ'), 'TS' => array('Ц'), - 'UE' => array('Ü'), 'YA' => array('Я'), 'YU' => array('Ю'), 'ZH' => array('Ж'), @@ -1837,6 +1842,42 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess ); } + /** + * Returns the locale-specific replacements for the toAscii() method. + * + * @param string $locale Locale of the source string + * @return array An array of replacements. + */ + protected function localeSpecificCharsArray($locale = 'en') + { + $split = preg_split('/[-_]/', $locale); + $locale = strtolower($split[0]); + + static $charsArray = array(); + if (isset($charsArray[$locale])) { + return $charsArray[$locale]; + } + + $localeSpecific = array( + 'de' => array( + 'ae' => array('ä'), + 'oe' => array('ö'), + 'ue' => array('ü'), + 'AE' => array('Ä'), + 'OE' => array('Ö'), + 'UE' => array('Ü') + ) + ); + + if (isset($localeSpecific[$locale])) { + $charsArray[$locale] = $localeSpecific[$locale]; + } else { + $charsArray[$locale] = array(); + } + + return $charsArray[$locale]; + } + /** * Adds the specified amount of left and right padding to the given string. * The default character used is a space. diff --git a/tests/StringyTest.php b/tests/StringyTest.php index 94b1398..f50ab30 100644 --- a/tests/StringyTest.php +++ b/tests/StringyTest.php @@ -653,10 +653,11 @@ class StringyTestCase extends PHPUnit_Framework_TestCase /** * @dataProvider toAsciiProvider() */ - public function testToAscii($expected, $str, $removeUnsupported = true) + public function testToAscii($expected, $str, $locale = 'en', + $removeUnsupported = true) { $stringy = S::create($str); - $result = $stringy->toAscii($removeUnsupported); + $result = $stringy->toAscii($locale, $removeUnsupported); $this->assertStringy($result); $this->assertEquals($expected, $result); $this->assertEquals($str, $stringy); @@ -681,7 +682,10 @@ class StringyTestCase extends PHPUnit_Framework_TestCase array(' ', ' '), // medium mathematical space (U+205F) array(' ', ' '), // ideographic space (U+3000) array('', '𐍉'), // some uncommon, unsupported character (U+10349) - array('𐍉', '𐍉', false), + array('𐍉', '𐍉', 'en', false), + array('aouAOU', 'äöüÄÖÜ'), + array('aeoeueAEOEUE', 'äöüÄÖÜ', 'de'), + array('aeoeueAEOEUE', 'äöüÄÖÜ', 'de_DE') ); } From 75b0cd2e0dd1b6c9156680870e24d047bfac7b41 Mon Sep 17 00:00:00 2001 From: "Daniel St. Jules" Date: Mon, 6 Mar 2017 13:14:15 -0500 Subject: [PATCH 2/8] Drop php 5.3 support --- .travis.yml | 4 ---- README.md | 2 +- composer.json | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 487dba9..e423c5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,10 +10,6 @@ sudo: false matrix: fast_finish: true include: - - php: 5.3 - env: polyfill='true' - - php: 5.3 - env: polyfill='false' - php: 5.4 env: polyfill='true' - php: 5.4 diff --git a/README.md b/README.md index 83bb6f9..6a08086 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![Stringy](http://danielstjules.com/github/stringy-logo.png) A PHP string manipulation library with multibyte support. Compatible with PHP -5.3+, PHP 7, and HHVM. Refer to the [1.x branch](https://github.com/danielstjules/Stringy/tree/1.x) +5.4+, PHP 7, and HHVM. Refer to the [1.x branch](https://github.com/danielstjules/Stringy/tree/1.x) for older documentation. ``` php diff --git a/composer.json b/composer.json index 538e72a..092989f 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": ">=5.3.0", + "php": ">=5.4.0", "symfony/polyfill-mbstring": "~1.1" }, "require-dev": { From f9f3b7f2f21febe2cf17228f6401214d75dae784 Mon Sep 17 00:00:00 2001 From: "Daniel St. Jules" Date: Mon, 6 Mar 2017 13:15:11 -0500 Subject: [PATCH 3/8] Link to 2.x documentation --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6a08086..1a3bed7 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,16 @@ ![Stringy](http://danielstjules.com/github/stringy-logo.png) A PHP string manipulation library with multibyte support. Compatible with PHP -5.4+, PHP 7, and HHVM. Refer to the [1.x branch](https://github.com/danielstjules/Stringy/tree/1.x) -for older documentation. +5.4+, PHP 7, and HHVM. ``` php s('string')->toTitleCase()->ensureRight('y') == 'Stringy' ``` +Refer to the [1.x branch](https://github.com/danielstjules/Stringy/tree/1.x) or +[2.x branch](https://github.com/danielstjules/Stringy/tree/2.x) for older +documentation. + [![Build Status](https://api.travis-ci.org/danielstjules/Stringy.svg?branch=master)](https://travis-ci.org/danielstjules/Stringy) [![Total Downloads](https://poser.pugx.org/danielstjules/stringy/downloads)](https://packagist.org/packages/danielstjules/stringy) [![License](https://poser.pugx.org/danielstjules/stringy/license)](https://packagist.org/packages/danielstjules/stringy) From e01ba7f8480a995464f112a2fa68481ed17f4eae Mon Sep 17 00:00:00 2001 From: "Daniel St. Jules" Date: Mon, 6 Mar 2017 13:43:47 -0500 Subject: [PATCH 4/8] Use short array syntax --- src/StaticStringy.php | 2 +- src/Stringy.php | 376 ++++---- tests/StringyTest.php | 2066 ++++++++++++++++++++--------------------- 3 files changed, 1222 insertions(+), 1222 deletions(-) diff --git a/src/StaticStringy.php b/src/StaticStringy.php index 4486665..83d552f 100644 --- a/src/StaticStringy.php +++ b/src/StaticStringy.php @@ -143,6 +143,6 @@ class StaticStringy $stringy = Stringy::create($str, $encoding); - return call_user_func_array(array($stringy, $name), $args); + return call_user_func_array([$stringy, $name], $args); } } diff --git a/src/Stringy.php b/src/Stringy.php index 0ade923..db34756 100644 --- a/src/Stringy.php +++ b/src/Stringy.php @@ -174,7 +174,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess */ public function chars() { - $chars = array(); + $chars = []; for ($i = 0, $l = $this->length(); $i < $l; $i++) { $chars[] = $this->at($i)->str; } @@ -516,7 +516,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess */ public function humanize() { - $str = str_replace(array('_id', '_'), array('', ' '), $this->str); + $str = str_replace(['_id', '_'], ['', ' '], $this->str); return static::create($str, $this->encoding)->trim()->upperCaseFirst(); } @@ -925,7 +925,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess */ public function pad($length, $padStr = ' ', $padType = 'right') { - if (!in_array($padType, array('left', 'right', 'both'))) { + if (!in_array($padType, ['left', 'right', 'both'])) { throw new InvalidArgumentException('Pad expects $padType ' . "to be one of 'left', 'right' or 'both'"); } @@ -1259,13 +1259,13 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess public function split($pattern, $limit = null) { if ($limit === 0) { - return array(); + return []; } // mb_split errors when supplied an empty pattern in < PHP 5.4.13 // and HHVM < 3.8 if ($pattern === '') { - return array(static::create($this->str, $this->encoding)); + return [static::create($this->str, $this->encoding)]; } $regexEncoding = $this->regexEncoding(); @@ -1337,7 +1337,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess */ public function surround($substring) { - $str = implode('', array($substring, $this->str, $substring)); + $str = implode('', [$substring, $this->str, $substring]); return static::create($str, $this->encoding); } @@ -1376,17 +1376,17 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess */ public function tidy() { - $str = preg_replace(array( + $str = preg_replace([ '/\x{2026}/u', '/[\x{201C}\x{201D}]/u', '/[\x{2018}\x{2019}]/u', '/[\x{2013}\x{2014}]/u', - ), array( + ], [ '...', '"', "'", '-', - ), $this->str); + ], $this->str); return static::create($str, $this->encoding); } @@ -1465,7 +1465,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess public function toBoolean() { $key = $this->toLowerCase()->str; - $map = array( + $map = [ 'true' => true, '1' => true, 'on' => true, @@ -1474,7 +1474,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess '0' => false, 'off' => false, 'no' => false - ); + ]; if (array_key_exists($key, $map)) { return $map[$key]; @@ -1676,170 +1676,170 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess static $charsArray; if (isset($charsArray)) return $charsArray; - return $charsArray = array( - '0' => array('°', '₀', '۰', '0'), - '1' => array('¹', '₁', '۱', '1'), - '2' => array('²', '₂', '۲', '2'), - '3' => array('³', '₃', '۳', '3'), - '4' => array('⁴', '₄', '۴', '٤', '4'), - '5' => array('⁵', '₅', '۵', '٥', '5'), - '6' => array('⁶', '₆', '۶', '٦', '6'), - '7' => array('⁷', '₇', '۷', '7'), - '8' => array('⁸', '₈', '۸', '8'), - '9' => array('⁹', '₉', '۹', '9'), - 'a' => array('à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ', - 'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ā', 'ą', 'å', - 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', - 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά', - 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ', 'အ', - 'ာ', 'ါ', 'ǻ', 'ǎ', 'ª', 'ა', 'अ', 'ا', 'a', 'ä'), - 'b' => array('б', 'β', 'Ъ', 'Ь', 'ب', 'ဗ', 'ბ', 'b'), - 'c' => array('ç', 'ć', 'č', 'ĉ', 'ċ', 'c'), - 'd' => array('ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', - 'д', 'δ', 'د', 'ض', 'ဍ', 'ဒ', 'დ', 'd'), - 'e' => array('é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ', - 'ệ', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ', 'ἐ', - 'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э', - 'є', 'ə', 'ဧ', 'ေ', 'ဲ', 'ე', 'ए', 'إ', 'ئ', 'e'), - 'f' => array('ф', 'φ', 'ف', 'ƒ', 'ფ', 'f'), - 'g' => array('ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ဂ', 'გ', 'گ', - 'g'), - 'h' => array('ĥ', 'ħ', 'η', 'ή', 'ح', 'ه', 'ဟ', 'ှ', 'ჰ', 'h'), - 'i' => array('í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į', - 'ı', 'ι', 'ί', 'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ', - 'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ', - 'ῗ', 'і', 'ї', 'и', 'ဣ', 'ိ', 'ီ', 'ည်', 'ǐ', 'ი', - 'इ', 'ی', 'i'), - 'j' => array('ĵ', 'ј', 'Ј', 'ჯ', 'ج', 'j'), - 'k' => array('ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك', 'က', 'კ', 'ქ', - 'ک', 'k'), - 'l' => array('ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل', 'လ', 'ლ', - 'l'), - 'm' => array('м', 'μ', 'م', 'မ', 'მ', 'm'), - 'n' => array('ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن', 'န', - 'ნ', 'n'), - 'o' => array('ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ', - 'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő', - 'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', - 'о', 'و', 'θ', 'ို', 'ǒ', 'ǿ', 'º', 'ო', 'ओ', 'o', - 'ö'), - 'p' => array('п', 'π', 'ပ', 'პ', 'پ', 'p'), - 'q' => array('ყ', 'q'), - 'r' => array('ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر', 'რ', 'r'), - 's' => array('ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص', 'စ', - 'ſ', 'ს', 's'), - 't' => array('ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط', 'ဋ', 'တ', 'ŧ', - 'თ', 'ტ', 't'), - 'u' => array('ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', 'ừ', 'ử', 'ữ', - 'ự', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у', 'ဉ', - 'ု', 'ူ', 'ǔ', 'ǖ', 'ǘ', 'ǚ', 'ǜ', 'უ', 'उ', 'u', - 'ў', 'ü'), - 'v' => array('в', 'ვ', 'ϐ', 'v'), - 'w' => array('ŵ', 'ω', 'ώ', 'ဝ', 'ွ', 'w'), - 'x' => array('χ', 'ξ', 'x'), - 'y' => array('ý', 'ỳ', 'ỷ', 'ỹ', 'ỵ', 'ÿ', 'ŷ', 'й', 'ы', 'υ', - 'ϋ', 'ύ', 'ΰ', 'ي', 'ယ', 'y'), - 'z' => array('ź', 'ž', 'ż', 'з', 'ζ', 'ز', 'ဇ', 'ზ', 'z'), - 'aa' => array('ع', 'आ', 'آ'), - 'ae' => array('æ', 'ǽ'), - 'ai' => array('ऐ'), - 'at' => array('@'), - 'ch' => array('ч', 'ჩ', 'ჭ', 'چ'), - 'dj' => array('ђ', 'đ'), - 'dz' => array('џ', 'ძ'), - 'ei' => array('ऍ'), - 'gh' => array('غ', 'ღ'), - 'ii' => array('ई'), - 'ij' => array('ij'), - 'kh' => array('х', 'خ', 'ხ'), - 'lj' => array('љ'), - 'nj' => array('њ'), - 'oe' => array('œ', 'ؤ'), - 'oi' => array('ऑ'), - 'oii' => array('ऒ'), - 'ps' => array('ψ'), - 'sh' => array('ш', 'შ', 'ش'), - 'shch' => array('щ'), - 'ss' => array('ß'), - 'sx' => array('ŝ'), - 'th' => array('þ', 'ϑ', 'ث', 'ذ', 'ظ'), - 'ts' => array('ц', 'ც', 'წ'), - 'uu' => array('ऊ'), - 'ya' => array('я'), - 'yu' => array('ю'), - 'zh' => array('ж', 'ჟ', 'ژ'), - '(c)' => array('©'), - 'A' => array('Á', 'À', 'Ả', 'Ã', 'Ạ', 'Ă', 'Ắ', 'Ằ', 'Ẳ', 'Ẵ', - 'Ặ', 'Â', 'Ấ', 'Ầ', 'Ẩ', 'Ẫ', 'Ậ', 'Å', 'Ā', 'Ą', - 'Α', 'Ά', 'Ἀ', 'Ἁ', 'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ', 'Ἇ', - 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ', 'Ᾱ', - 'Ὰ', 'Ά', 'ᾼ', 'А', 'Ǻ', 'Ǎ', 'A', 'Ä'), - 'B' => array('Б', 'Β', 'ब', 'B'), - 'C' => array('Ç','Ć', 'Č', 'Ĉ', 'Ċ', 'C'), - 'D' => array('Ď', 'Ð', 'Đ', 'Ɖ', 'Ɗ', 'Ƌ', 'ᴅ', 'ᴆ', 'Д', 'Δ', - 'D'), - 'E' => array('É', 'È', 'Ẻ', 'Ẽ', 'Ẹ', 'Ê', 'Ế', 'Ề', 'Ể', 'Ễ', - 'Ệ', 'Ë', 'Ē', 'Ę', 'Ě', 'Ĕ', 'Ė', 'Ε', 'Έ', 'Ἐ', - 'Ἑ', 'Ἒ', 'Ἓ', 'Ἔ', 'Ἕ', 'Έ', 'Ὲ', 'Е', 'Ё', 'Э', - 'Є', 'Ə', 'E'), - 'F' => array('Ф', 'Φ', 'F'), - 'G' => array('Ğ', 'Ġ', 'Ģ', 'Г', 'Ґ', 'Γ', 'G'), - 'H' => array('Η', 'Ή', 'Ħ', 'H'), - 'I' => array('Í', 'Ì', 'Ỉ', 'Ĩ', 'Ị', 'Î', 'Ï', 'Ī', 'Ĭ', 'Į', - 'İ', 'Ι', 'Ί', 'Ϊ', 'Ἰ', 'Ἱ', 'Ἳ', 'Ἴ', 'Ἵ', 'Ἶ', - 'Ἷ', 'Ῐ', 'Ῑ', 'Ὶ', 'Ί', 'И', 'І', 'Ї', 'Ǐ', 'ϒ', - 'I'), - 'J' => array('J'), - 'K' => array('К', 'Κ', 'K'), - 'L' => array('Ĺ', 'Ł', 'Л', 'Λ', 'Ļ', 'Ľ', 'Ŀ', 'ल', 'L'), - 'M' => array('М', 'Μ', 'M'), - 'N' => array('Ń', 'Ñ', 'Ň', 'Ņ', 'Ŋ', 'Н', 'Ν', 'N'), - 'O' => array('Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ', - 'Ộ', 'Ơ', 'Ớ', 'Ờ', 'Ở', 'Ỡ', 'Ợ', 'Ø', 'Ō', 'Ő', - 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ', 'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ', 'Ὸ', - 'Ό', 'О', 'Θ', 'Ө', 'Ǒ', 'Ǿ', 'O', 'Ö'), - 'P' => array('П', 'Π', 'P'), - 'Q' => array('Q'), - 'R' => array('Ř', 'Ŕ', 'Р', 'Ρ', 'Ŗ', 'R'), - 'S' => array('Ş', 'Ŝ', 'Ș', 'Š', 'Ś', 'С', 'Σ', 'S'), - 'T' => array('Ť', 'Ţ', 'Ŧ', 'Ț', 'Т', 'Τ', 'T'), - 'U' => array('Ú', 'Ù', 'Ủ', 'Ũ', 'Ụ', 'Ư', 'Ứ', 'Ừ', 'Ử', 'Ữ', - 'Ự', 'Û', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ų', 'У', 'Ǔ', 'Ǖ', - 'Ǘ', 'Ǚ', 'Ǜ', 'U', 'Ў', 'Ü'), - 'V' => array('В', 'V'), - 'W' => array('Ω', 'Ώ', 'Ŵ', 'W'), - 'X' => array('Χ', 'Ξ', 'X'), - 'Y' => array('Ý', 'Ỳ', 'Ỷ', 'Ỹ', 'Ỵ', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ', - 'Ы', 'Й', 'Υ', 'Ϋ', 'Ŷ', 'Y'), - 'Z' => array('Ź', 'Ž', 'Ż', 'З', 'Ζ', 'Z'), - 'AE' => array('Æ', 'Ǽ'), - 'CH' => array('Ч'), - 'DJ' => array('Ђ'), - 'DZ' => array('Џ'), - 'GX' => array('Ĝ'), - 'HX' => array('Ĥ'), - 'IJ' => array('IJ'), - 'JX' => array('Ĵ'), - 'KH' => array('Х'), - 'LJ' => array('Љ'), - 'NJ' => array('Њ'), - 'OE' => array('Œ'), - 'PS' => array('Ψ'), - 'SH' => array('Ш'), - 'SHCH' => array('Щ'), - 'SS' => array('ẞ'), - 'TH' => array('Þ'), - 'TS' => array('Ц'), - 'YA' => array('Я'), - 'YU' => array('Ю'), - 'ZH' => array('Ж'), - ' ' => array("\xC2\xA0", "\xE2\x80\x80", "\xE2\x80\x81", - "\xE2\x80\x82", "\xE2\x80\x83", "\xE2\x80\x84", - "\xE2\x80\x85", "\xE2\x80\x86", "\xE2\x80\x87", - "\xE2\x80\x88", "\xE2\x80\x89", "\xE2\x80\x8A", - "\xE2\x80\xAF", "\xE2\x81\x9F", "\xE3\x80\x80", - "\xEF\xBE\xA0"), - ); + return $charsArray = [ + '0' => ['°', '₀', '۰', '0'], + '1' => ['¹', '₁', '۱', '1'], + '2' => ['²', '₂', '۲', '2'], + '3' => ['³', '₃', '۳', '3'], + '4' => ['⁴', '₄', '۴', '٤', '4'], + '5' => ['⁵', '₅', '۵', '٥', '5'], + '6' => ['⁶', '₆', '۶', '٦', '6'], + '7' => ['⁷', '₇', '۷', '7'], + '8' => ['⁸', '₈', '۸', '8'], + '9' => ['⁹', '₉', '۹', '9'], + 'a' => ['à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ', + 'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ā', 'ą', 'å', + 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', + 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ά', + 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ', 'အ', + 'ာ', 'ါ', 'ǻ', 'ǎ', 'ª', 'ა', 'अ', 'ا', 'a', 'ä'], + 'b' => ['б', 'β', 'Ъ', 'Ь', 'ب', 'ဗ', 'ბ', 'b'], + 'c' => ['ç', 'ć', 'č', 'ĉ', 'ċ', 'c'], + 'd' => ['ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', + 'д', 'δ', 'د', 'ض', 'ဍ', 'ဒ', 'დ', 'd'], + 'e' => ['é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ', + 'ệ', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ', 'ἐ', + 'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э', + 'є', 'ə', 'ဧ', 'ေ', 'ဲ', 'ე', 'ए', 'إ', 'ئ', 'e'], + 'f' => ['ф', 'φ', 'ف', 'ƒ', 'ფ', 'f'], + 'g' => ['ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ဂ', 'გ', 'گ', + 'g'], + 'h' => ['ĥ', 'ħ', 'η', 'ή', 'ح', 'ه', 'ဟ', 'ှ', 'ჰ', 'h'], + 'i' => ['í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į', + 'ı', 'ι', 'ί', 'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ', + 'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ', + 'ῗ', 'і', 'ї', 'и', 'ဣ', 'ိ', 'ီ', 'ည်', 'ǐ', 'ი', + 'इ', 'ی', 'i'], + 'j' => ['ĵ', 'ј', 'Ј', 'ჯ', 'ج', 'j'], + 'k' => ['ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك', 'က', 'კ', 'ქ', + 'ک', 'k'], + 'l' => ['ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل', 'လ', 'ლ', + 'l'], + 'm' => ['м', 'μ', 'م', 'မ', 'მ', 'm'], + 'n' => ['ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن', 'န', + 'ნ', 'n'], + 'o' => ['ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ', + 'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő', + 'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', + 'о', 'و', 'θ', 'ို', 'ǒ', 'ǿ', 'º', 'ო', 'ओ', 'o', + 'ö'], + 'p' => ['п', 'π', 'ပ', 'პ', 'پ', 'p'], + 'q' => ['ყ', 'q'], + 'r' => ['ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر', 'რ', 'r'], + 's' => ['ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص', 'စ', + 'ſ', 'ს', 's'], + 't' => ['ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط', 'ဋ', 'တ', 'ŧ', + 'თ', 'ტ', 't'], + 'u' => ['ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', 'ừ', 'ử', 'ữ', + 'ự', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у', 'ဉ', + 'ု', 'ူ', 'ǔ', 'ǖ', 'ǘ', 'ǚ', 'ǜ', 'უ', 'उ', 'u', + 'ў', 'ü'], + 'v' => ['в', 'ვ', 'ϐ', 'v'], + 'w' => ['ŵ', 'ω', 'ώ', 'ဝ', 'ွ', 'w'], + 'x' => ['χ', 'ξ', 'x'], + 'y' => ['ý', 'ỳ', 'ỷ', 'ỹ', 'ỵ', 'ÿ', 'ŷ', 'й', 'ы', 'υ', + 'ϋ', 'ύ', 'ΰ', 'ي', 'ယ', 'y'], + 'z' => ['ź', 'ž', 'ż', 'з', 'ζ', 'ز', 'ဇ', 'ზ', 'z'], + 'aa' => ['ع', 'आ', 'آ'], + 'ae' => ['æ', 'ǽ'], + 'ai' => ['ऐ'], + 'at' => ['@'], + 'ch' => ['ч', 'ჩ', 'ჭ', 'چ'], + 'dj' => ['ђ', 'đ'], + 'dz' => ['џ', 'ძ'], + 'ei' => ['ऍ'], + 'gh' => ['غ', 'ღ'], + 'ii' => ['ई'], + 'ij' => ['ij'], + 'kh' => ['х', 'خ', 'ხ'], + 'lj' => ['љ'], + 'nj' => ['њ'], + 'oe' => ['œ', 'ؤ'], + 'oi' => ['ऑ'], + 'oii' => ['ऒ'], + 'ps' => ['ψ'], + 'sh' => ['ш', 'შ', 'ش'], + 'shch' => ['щ'], + 'ss' => ['ß'], + 'sx' => ['ŝ'], + 'th' => ['þ', 'ϑ', 'ث', 'ذ', 'ظ'], + 'ts' => ['ц', 'ც', 'წ'], + 'uu' => ['ऊ'], + 'ya' => ['я'], + 'yu' => ['ю'], + 'zh' => ['ж', 'ჟ', 'ژ'], + '(c)' => ['©'], + 'A' => ['Á', 'À', 'Ả', 'Ã', 'Ạ', 'Ă', 'Ắ', 'Ằ', 'Ẳ', 'Ẵ', + 'Ặ', 'Â', 'Ấ', 'Ầ', 'Ẩ', 'Ẫ', 'Ậ', 'Å', 'Ā', 'Ą', + 'Α', 'Ά', 'Ἀ', 'Ἁ', 'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ', 'Ἇ', + 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ', 'Ᾱ', + 'Ὰ', 'Ά', 'ᾼ', 'А', 'Ǻ', 'Ǎ', 'A', 'Ä'], + 'B' => ['Б', 'Β', 'ब', 'B'], + 'C' => ['Ç','Ć', 'Č', 'Ĉ', 'Ċ', 'C'], + 'D' => ['Ď', 'Ð', 'Đ', 'Ɖ', 'Ɗ', 'Ƌ', 'ᴅ', 'ᴆ', 'Д', 'Δ', + 'D'], + 'E' => ['É', 'È', 'Ẻ', 'Ẽ', 'Ẹ', 'Ê', 'Ế', 'Ề', 'Ể', 'Ễ', + 'Ệ', 'Ë', 'Ē', 'Ę', 'Ě', 'Ĕ', 'Ė', 'Ε', 'Έ', 'Ἐ', + 'Ἑ', 'Ἒ', 'Ἓ', 'Ἔ', 'Ἕ', 'Έ', 'Ὲ', 'Е', 'Ё', 'Э', + 'Є', 'Ə', 'E'], + 'F' => ['Ф', 'Φ', 'F'], + 'G' => ['Ğ', 'Ġ', 'Ģ', 'Г', 'Ґ', 'Γ', 'G'], + 'H' => ['Η', 'Ή', 'Ħ', 'H'], + 'I' => ['Í', 'Ì', 'Ỉ', 'Ĩ', 'Ị', 'Î', 'Ï', 'Ī', 'Ĭ', 'Į', + 'İ', 'Ι', 'Ί', 'Ϊ', 'Ἰ', 'Ἱ', 'Ἳ', 'Ἴ', 'Ἵ', 'Ἶ', + 'Ἷ', 'Ῐ', 'Ῑ', 'Ὶ', 'Ί', 'И', 'І', 'Ї', 'Ǐ', 'ϒ', + 'I'], + 'J' => ['J'], + 'K' => ['К', 'Κ', 'K'], + 'L' => ['Ĺ', 'Ł', 'Л', 'Λ', 'Ļ', 'Ľ', 'Ŀ', 'ल', 'L'], + 'M' => ['М', 'Μ', 'M'], + 'N' => ['Ń', 'Ñ', 'Ň', 'Ņ', 'Ŋ', 'Н', 'Ν', 'N'], + 'O' => ['Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ', + 'Ộ', 'Ơ', 'Ớ', 'Ờ', 'Ở', 'Ỡ', 'Ợ', 'Ø', 'Ō', 'Ő', + 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ', 'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ', 'Ὸ', + 'Ό', 'О', 'Θ', 'Ө', 'Ǒ', 'Ǿ', 'O', 'Ö'], + 'P' => ['П', 'Π', 'P'], + 'Q' => ['Q'], + 'R' => ['Ř', 'Ŕ', 'Р', 'Ρ', 'Ŗ', 'R'], + 'S' => ['Ş', 'Ŝ', 'Ș', 'Š', 'Ś', 'С', 'Σ', 'S'], + 'T' => ['Ť', 'Ţ', 'Ŧ', 'Ț', 'Т', 'Τ', 'T'], + 'U' => ['Ú', 'Ù', 'Ủ', 'Ũ', 'Ụ', 'Ư', 'Ứ', 'Ừ', 'Ử', 'Ữ', + 'Ự', 'Û', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ų', 'У', 'Ǔ', 'Ǖ', + 'Ǘ', 'Ǚ', 'Ǜ', 'U', 'Ў', 'Ü'], + 'V' => ['В', 'V'], + 'W' => ['Ω', 'Ώ', 'Ŵ', 'W'], + 'X' => ['Χ', 'Ξ', 'X'], + 'Y' => ['Ý', 'Ỳ', 'Ỷ', 'Ỹ', 'Ỵ', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ', + 'Ы', 'Й', 'Υ', 'Ϋ', 'Ŷ', 'Y'], + 'Z' => ['Ź', 'Ž', 'Ż', 'З', 'Ζ', 'Z'], + 'AE' => ['Æ', 'Ǽ'], + 'CH' => ['Ч'], + 'DJ' => ['Ђ'], + 'DZ' => ['Џ'], + 'GX' => ['Ĝ'], + 'HX' => ['Ĥ'], + 'IJ' => ['IJ'], + 'JX' => ['Ĵ'], + 'KH' => ['Х'], + 'LJ' => ['Љ'], + 'NJ' => ['Њ'], + 'OE' => ['Œ'], + 'PS' => ['Ψ'], + 'SH' => ['Ш'], + 'SHCH' => ['Щ'], + 'SS' => ['ẞ'], + 'TH' => ['Þ'], + 'TS' => ['Ц'], + 'YA' => ['Я'], + 'YU' => ['Ю'], + 'ZH' => ['Ж'], + ' ' => ["\xC2\xA0", "\xE2\x80\x80", "\xE2\x80\x81", + "\xE2\x80\x82", "\xE2\x80\x83", "\xE2\x80\x84", + "\xE2\x80\x85", "\xE2\x80\x86", "\xE2\x80\x87", + "\xE2\x80\x88", "\xE2\x80\x89", "\xE2\x80\x8A", + "\xE2\x80\xAF", "\xE2\x81\x9F", "\xE3\x80\x80", + "\xEF\xBE\xA0"], + ]; } /** @@ -1853,26 +1853,26 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess $split = preg_split('/[-_]/', $locale); $locale = strtolower($split[0]); - static $charsArray = array(); + static $charsArray = []; if (isset($charsArray[$locale])) { return $charsArray[$locale]; } - $localeSpecific = array( - 'de' => array( - 'ae' => array('ä'), - 'oe' => array('ö'), - 'ue' => array('ü'), - 'AE' => array('Ä'), - 'OE' => array('Ö'), - 'UE' => array('Ü') - ) - ); + $localeSpecific = [ + 'de' => [ + 'ae' => ['ä'], + 'oe' => ['ö'], + 'ue' => ['ü'], + 'AE' => ['Ä'], + 'OE' => ['Ö'], + 'UE' => ['Ü'] + ] + ]; if (isset($localeSpecific[$locale])) { $charsArray[$locale] = $localeSpecific[$locale]; } else { - $charsArray[$locale] = array(); + $charsArray[$locale] = []; } return $charsArray[$locale]; @@ -1965,7 +1965,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess protected function supportsEncoding() { - $supported = array('UTF-8' => true, 'ASCII' => true); + $supported = ['UTF-8' => true, 'ASCII' => true]; if (isset($supported[$this->encoding])) { return true; diff --git a/tests/StringyTest.php b/tests/StringyTest.php index f50ab30..051afa8 100644 --- a/tests/StringyTest.php +++ b/tests/StringyTest.php @@ -34,7 +34,7 @@ class StringyTestCase extends PHPUnit_Framework_TestCase */ public function testConstructWithArray() { - (string) new S(array()); + (string) new S([]); $this->fail('Expecting exception when the constructor is passed an array'); } @@ -58,14 +58,14 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function toStringProvider() { - return array( - array('', null), - array('', false), - array('1', true), - array('-9', -9), - array('1.18', 1.18), - array(' string ', ' string ') - ); + return [ + ['', null], + ['', false], + ['1', true], + ['-9', -9], + ['1.18', 1.18], + [' string ', ' string '] + ]; } public function testCreate() @@ -95,18 +95,18 @@ class StringyTestCase extends PHPUnit_Framework_TestCase { $stringy = S::create('Fòô Bàř', 'UTF-8'); - $valResult = array(); + $valResult = []; foreach ($stringy as $char) { $valResult[] = $char; } - $keyValResult = array(); + $keyValResult = []; foreach ($stringy as $pos => $char) { $keyValResult[$pos] = $char; } - $this->assertEquals(array('F', 'ò', 'ô', ' ', 'B', 'à', 'ř'), $valResult); - $this->assertEquals(array('F', 'ò', 'ô', ' ', 'B', 'à', 'ř'), $keyValResult); + $this->assertEquals(['F', 'ò', 'ô', ' ', 'B', 'à', 'ř'], $valResult); + $this->assertEquals(['F', 'ò', 'ô', ' ', 'B', 'à', 'ř'], $keyValResult); } /** @@ -121,14 +121,14 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function offsetExistsProvider() { - return array( - array(true, 0), - array(true, 2), - array(false, 3), - array(true, -1), - array(true, -3), - array(false, -4) - ); + return [ + [true, 0], + [true, 2], + [false, 3], + [true, -1], + [true, -3], + [false, -4] + ]; } public function testOffsetGet() @@ -179,18 +179,18 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function indexOfProvider() { - return array( - array(6, 'foo & bar', 'bar'), - array(6, 'foo & bar', 'bar', 0), - array(false, 'foo & bar', 'baz'), - array(false, 'foo & bar', 'baz', 0), - array(0, 'foo & bar & foo', 'foo', 0), - array(12, 'foo & bar & foo', 'foo', 5), - array(6, 'fòô & bàř', 'bàř', 0, 'UTF-8'), - array(false, 'fòô & bàř', 'baz', 0, 'UTF-8'), - array(0, 'fòô & bàř & fòô', 'fòô', 0, 'UTF-8'), - array(12, 'fòô & bàř & fòô', 'fòô', 5, 'UTF-8'), - ); + return [ + [6, 'foo & bar', 'bar'], + [6, 'foo & bar', 'bar', 0], + [false, 'foo & bar', 'baz'], + [false, 'foo & bar', 'baz', 0], + [0, 'foo & bar & foo', 'foo', 0], + [12, 'foo & bar & foo', 'foo', 5], + [6, 'fòô & bàř', 'bàř', 0, 'UTF-8'], + [false, 'fòô & bàř', 'baz', 0, 'UTF-8'], + [0, 'fòô & bàř & fòô', 'fòô', 0, 'UTF-8'], + [12, 'fòô & bàř & fòô', 'fòô', 5, 'UTF-8'], + ]; } /** @@ -204,18 +204,18 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function indexOfLastProvider() { - return array( - array(6, 'foo & bar', 'bar'), - array(6, 'foo & bar', 'bar', 0), - array(false, 'foo & bar', 'baz'), - array(false, 'foo & bar', 'baz', 0), - array(12, 'foo & bar & foo', 'foo', 0), - array(0, 'foo & bar & foo', 'foo', -5), - array(6, 'fòô & bàř', 'bàř', 0, 'UTF-8'), - array(false, 'fòô & bàř', 'baz', 0, 'UTF-8'), - array(12, 'fòô & bàř & fòô', 'fòô', 0, 'UTF-8'), - array(0, 'fòô & bàř & fòô', 'fòô', -5, 'UTF-8'), - ); + return [ + [6, 'foo & bar', 'bar'], + [6, 'foo & bar', 'bar', 0], + [false, 'foo & bar', 'baz'], + [false, 'foo & bar', 'baz', 0], + [12, 'foo & bar & foo', 'foo', 0], + [0, 'foo & bar & foo', 'foo', -5], + [6, 'fòô & bàř', 'bàř', 0, 'UTF-8'], + [false, 'fòô & bàř', 'baz', 0, 'UTF-8'], + [12, 'fòô & bàř & fòô', 'fòô', 0, 'UTF-8'], + [0, 'fòô & bàř & fòô', 'fòô', -5, 'UTF-8'], + ]; } /** @@ -230,10 +230,10 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function appendProvider() { - return array( - array('foobar', 'foo', 'bar'), - array('fòôbàř', 'fòô', 'bàř', 'UTF-8') - ); + return [ + ['foobar', 'foo', 'bar'], + ['fòôbàř', 'fòô', 'bàř', 'UTF-8'] + ]; } /** @@ -248,10 +248,10 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function prependProvider() { - return array( - array('foobar', 'bar', 'foo'), - array('fòôbàř', 'bàř', 'fòô', 'UTF-8') - ); + return [ + ['foobar', 'bar', 'foo'], + ['fòôbàř', 'bàř', 'fòô', 'UTF-8'] + ]; } /** @@ -269,11 +269,11 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function charsProvider() { - return array( - array(array(), ''), - array(array('T', 'e', 's', 't'), 'Test'), - array(array('F', 'ò', 'ô', ' ', 'B', 'à', 'ř'), 'Fòô Bàř', 'UTF-8') - ); + return [ + [[], ''], + [['T', 'e', 's', 't'], 'Test'], + [['F', 'ò', 'ô', ' ', 'B', 'à', 'ř'], 'Fòô Bàř', 'UTF-8'] + ]; } /** @@ -295,23 +295,23 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function linesProvider() { - return array( - array(array(), ""), - array(array(''), "\r\n"), - array(array('foo', 'bar'), "foo\nbar"), - array(array('foo', 'bar'), "foo\rbar"), - array(array('foo', 'bar'), "foo\r\nbar"), - array(array('foo', '', 'bar'), "foo\r\n\r\nbar"), - array(array('foo', 'bar', ''), "foo\r\nbar\r\n"), - array(array('', 'foo', 'bar'), "\r\nfoo\r\nbar"), - array(array('fòô', 'bàř'), "fòô\nbàř", 'UTF-8'), - array(array('fòô', 'bàř'), "fòô\rbàř", 'UTF-8'), - array(array('fòô', 'bàř'), "fòô\n\rbàř", 'UTF-8'), - array(array('fòô', 'bàř'), "fòô\r\nbàř", 'UTF-8'), - array(array('fòô', '', 'bàř'), "fòô\r\n\r\nbàř", 'UTF-8'), - array(array('fòô', 'bàř', ''), "fòô\r\nbàř\r\n", 'UTF-8'), - array(array('', 'fòô', 'bàř'), "\r\nfòô\r\nbàř", 'UTF-8'), - ); + return [ + [[], ""], + [[''], "\r\n"], + [['foo', 'bar'], "foo\nbar"], + [['foo', 'bar'], "foo\rbar"], + [['foo', 'bar'], "foo\r\nbar"], + [['foo', '', 'bar'], "foo\r\n\r\nbar"], + [['foo', 'bar', ''], "foo\r\nbar\r\n"], + [['', 'foo', 'bar'], "\r\nfoo\r\nbar"], + [['fòô', 'bàř'], "fòô\nbàř", 'UTF-8'], + [['fòô', 'bàř'], "fòô\rbàř", 'UTF-8'], + [['fòô', 'bàř'], "fòô\n\rbàř", 'UTF-8'], + [['fòô', 'bàř'], "fòô\r\nbàř", 'UTF-8'], + [['fòô', '', 'bàř'], "fòô\r\n\r\nbàř", 'UTF-8'], + [['fòô', 'bàř', ''], "fòô\r\nbàř\r\n", 'UTF-8'], + [['', 'fòô', 'bàř'], "\r\nfòô\r\nbàř", 'UTF-8'], + ]; } /** * @dataProvider upperCaseFirstProvider() @@ -325,13 +325,13 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function upperCaseFirstProvider() { - return array( - array('Test', 'Test'), - array('Test', 'test'), - array('1a', '1a'), - array('Σ test', 'σ test', 'UTF-8'), - array(' σ test', ' σ test', 'UTF-8') - ); + return [ + ['Test', 'Test'], + ['Test', 'test'], + ['1a', '1a'], + ['Σ test', 'σ test', 'UTF-8'], + [' σ test', ' σ test', 'UTF-8'] + ]; } /** @@ -348,13 +348,13 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function lowerCaseFirstProvider() { - return array( - array('test', 'Test'), - array('test', 'test'), - array('1a', '1a'), - array('σ test', 'Σ test', 'UTF-8'), - array(' Σ test', ' Σ test', 'UTF-8') - ); + return [ + ['test', 'Test'], + ['test', 'test'], + ['1a', '1a'], + ['σ test', 'Σ test', 'UTF-8'], + [' Σ test', ' Σ test', 'UTF-8'] + ]; } /** @@ -371,27 +371,27 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function camelizeProvider() { - return array( - array('camelCase', 'CamelCase'), - array('camelCase', 'Camel-Case'), - array('camelCase', 'camel case'), - array('camelCase', 'camel -case'), - array('camelCase', 'camel - case'), - array('camelCase', 'camel_case'), - array('camelCTest', 'camel c test'), - array('stringWith1Number', 'string_with1number'), - array('stringWith22Numbers', 'string-with-2-2 numbers'), - array('dataRate', 'data_rate'), - array('backgroundColor', 'background-color'), - array('yesWeCan', 'yes_we_can'), - array('mozSomething', '-moz-something'), - array('carSpeed', '_car_speed_'), - array('serveHTTP', 'ServeHTTP'), - array('1Camel2Case', '1camel2case'), - array('camelΣase', 'camel σase', 'UTF-8'), - array('στανιλCase', 'Στανιλ case', 'UTF-8'), - array('σamelCase', 'σamel Case', 'UTF-8') - ); + return [ + ['camelCase', 'CamelCase'], + ['camelCase', 'Camel-Case'], + ['camelCase', 'camel case'], + ['camelCase', 'camel -case'], + ['camelCase', 'camel - case'], + ['camelCase', 'camel_case'], + ['camelCTest', 'camel c test'], + ['stringWith1Number', 'string_with1number'], + ['stringWith22Numbers', 'string-with-2-2 numbers'], + ['dataRate', 'data_rate'], + ['backgroundColor', 'background-color'], + ['yesWeCan', 'yes_we_can'], + ['mozSomething', '-moz-something'], + ['carSpeed', '_car_speed_'], + ['serveHTTP', 'ServeHTTP'], + ['1Camel2Case', '1camel2case'], + ['camelΣase', 'camel σase', 'UTF-8'], + ['στανιλCase', 'Στανιλ case', 'UTF-8'], + ['σamelCase', 'σamel Case', 'UTF-8'] + ]; } /** @@ -408,21 +408,21 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function upperCamelizeProvider() { - return array( - array('CamelCase', 'camelCase'), - array('CamelCase', 'Camel-Case'), - array('CamelCase', 'camel case'), - array('CamelCase', 'camel -case'), - array('CamelCase', 'camel - case'), - array('CamelCase', 'camel_case'), - array('CamelCTest', 'camel c test'), - array('StringWith1Number', 'string_with1number'), - array('StringWith22Numbers', 'string-with-2-2 numbers'), - array('1Camel2Case', '1camel2case'), - array('CamelΣase', 'camel σase', 'UTF-8'), - array('ΣτανιλCase', 'στανιλ case', 'UTF-8'), - array('ΣamelCase', 'Σamel Case', 'UTF-8') - ); + return [ + ['CamelCase', 'camelCase'], + ['CamelCase', 'Camel-Case'], + ['CamelCase', 'camel case'], + ['CamelCase', 'camel -case'], + ['CamelCase', 'camel - case'], + ['CamelCase', 'camel_case'], + ['CamelCTest', 'camel c test'], + ['StringWith1Number', 'string_with1number'], + ['StringWith22Numbers', 'string-with-2-2 numbers'], + ['1Camel2Case', '1camel2case'], + ['CamelΣase', 'camel σase', 'UTF-8'], + ['ΣτανιλCase', 'στανιλ case', 'UTF-8'], + ['ΣamelCase', 'Σamel Case', 'UTF-8'] + ]; } /** @@ -439,27 +439,27 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function dasherizeProvider() { - return array( - array('test-case', 'testCase'), - array('test-case', 'Test-Case'), - array('test-case', 'test case'), - array('-test-case', '-test -case'), - array('test-case', 'test - case'), - array('test-case', 'test_case'), - array('test-c-test', 'test c test'), - array('test-d-case', 'TestDCase'), - array('test-c-c-test', 'TestCCTest'), - array('string-with1number', 'string_with1number'), - array('string-with-2-2-numbers', 'String-with_2_2 numbers'), - array('1test2case', '1test2case'), - array('data-rate', 'dataRate'), - array('car-speed', 'CarSpeed'), - array('yes-we-can', 'yesWeCan'), - array('background-color', 'backgroundColor'), - array('dash-σase', 'dash Σase', 'UTF-8'), - array('στανιλ-case', 'Στανιλ case', 'UTF-8'), - array('σash-case', 'Σash Case', 'UTF-8') - ); + return [ + ['test-case', 'testCase'], + ['test-case', 'Test-Case'], + ['test-case', 'test case'], + ['-test-case', '-test -case'], + ['test-case', 'test - case'], + ['test-case', 'test_case'], + ['test-c-test', 'test c test'], + ['test-d-case', 'TestDCase'], + ['test-c-c-test', 'TestCCTest'], + ['string-with1number', 'string_with1number'], + ['string-with-2-2-numbers', 'String-with_2_2 numbers'], + ['1test2case', '1test2case'], + ['data-rate', 'dataRate'], + ['car-speed', 'CarSpeed'], + ['yes-we-can', 'yesWeCan'], + ['background-color', 'backgroundColor'], + ['dash-σase', 'dash Σase', 'UTF-8'], + ['στανιλ-case', 'Στανιλ case', 'UTF-8'], + ['σash-case', 'Σash Case', 'UTF-8'] + ]; } /** @@ -476,24 +476,24 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function underscoredProvider() { - return array( - array('test_case', 'testCase'), - array('test_case', 'Test-Case'), - array('test_case', 'test case'), - array('test_case', 'test -case'), - array('_test_case', '-test - case'), - array('test_case', 'test_case'), - array('test_c_test', ' test c test'), - array('test_u_case', 'TestUCase'), - array('test_c_c_test', 'TestCCTest'), - array('string_with1number', 'string_with1number'), - array('string_with_2_2_numbers', 'String-with_2_2 numbers'), - array('1test2case', '1test2case'), - array('yes_we_can', 'yesWeCan'), - array('test_σase', 'test Σase', 'UTF-8'), - array('στανιλ_case', 'Στανιλ case', 'UTF-8'), - array('σash_case', 'Σash Case', 'UTF-8') - ); + return [ + ['test_case', 'testCase'], + ['test_case', 'Test-Case'], + ['test_case', 'test case'], + ['test_case', 'test -case'], + ['_test_case', '-test - case'], + ['test_case', 'test_case'], + ['test_c_test', ' test c test'], + ['test_u_case', 'TestUCase'], + ['test_c_c_test', 'TestCCTest'], + ['string_with1number', 'string_with1number'], + ['string_with_2_2_numbers', 'String-with_2_2 numbers'], + ['1test2case', '1test2case'], + ['yes_we_can', 'yesWeCan'], + ['test_σase', 'test Σase', 'UTF-8'], + ['στανιλ_case', 'Στανιλ case', 'UTF-8'], + ['σash_case', 'Σash Case', 'UTF-8'] + ]; } /** @@ -510,22 +510,22 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function delimitProvider() { - return array( - array('test*case', 'testCase', '*'), - array('test&case', 'Test-Case', '&'), - array('test#case', 'test case', '#'), - array('test**case', 'test -case', '**'), - array('~!~test~!~case', '-test - case', '~!~'), - array('test*case', 'test_case', '*'), - array('test%c%test', ' test c test', '%'), - array('test+u+case', 'TestUCase', '+'), - array('test=c=c=test', 'TestCCTest', '='), - array('string#>with1number', 'string_with1number', '#>'), - array('1test2case', '1test2case', '*'), - array('test ύα σase', 'test Σase', ' ύα ', 'UTF-8',), - array('στανιλαcase', 'Στανιλ case', 'α', 'UTF-8',), - array('σashΘcase', 'Σash Case', 'Θ', 'UTF-8') - ); + return [ + ['test*case', 'testCase', '*'], + ['test&case', 'Test-Case', '&'], + ['test#case', 'test case', '#'], + ['test**case', 'test -case', '**'], + ['~!~test~!~case', '-test - case', '~!~'], + ['test*case', 'test_case', '*'], + ['test%c%test', ' test c test', '%'], + ['test+u+case', 'TestUCase', '+'], + ['test=c=c=test', 'TestCCTest', '='], + ['string#>with1number', 'string_with1number', '#>'], + ['1test2case', '1test2case', '*'], + ['test ύα σase', 'test Σase', ' ύα ', 'UTF-8',], + ['στανιλαcase', 'Στανιλ case', 'α', 'UTF-8',], + ['σashΘcase', 'Σash Case', 'Θ', 'UTF-8'] + ]; } /** @@ -542,12 +542,12 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function swapCaseProvider() { - return array( - array('TESTcASE', 'testCase'), - array('tEST-cASE', 'Test-Case'), - array(' - σASH cASE', ' - Σash Case', 'UTF-8'), - array('νΤΑΝΙΛ', 'Ντανιλ', 'UTF-8') - ); + return [ + ['TESTcASE', 'testCase'], + ['tEST-cASE', 'Test-Case'], + [' - σASH cASE', ' - Σash Case', 'UTF-8'], + ['νΤΑΝΙΛ', 'Ντανιλ', 'UTF-8'] + ]; } /** @@ -565,16 +565,16 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function titleizeProvider() { - $ignore = array('at', 'by', 'for', 'in', 'of', 'on', 'out', 'to', 'the'); + $ignore = ['at', 'by', 'for', 'in', 'of', 'on', 'out', 'to', 'the']; - return array( - array('Title Case', 'TITLE CASE'), - array('Testing The Method', 'testing the method'), - array('Testing the Method', 'testing the method', $ignore), - array('I Like to Watch Dvds at Home', 'i like to watch DVDs at home', - $ignore), - array('Θα Ήθελα Να Φύγει', ' Θα ήθελα να φύγει ', null, 'UTF-8') - ); + return [ + ['Title Case', 'TITLE CASE'], + ['Testing The Method', 'testing the method'], + ['Testing the Method', 'testing the method', $ignore], + ['I Like to Watch Dvds at Home', 'i like to watch DVDs at home', + $ignore], + ['Θα Ήθελα Να Φύγει', ' Θα ήθελα να φύγει ', null, 'UTF-8'] + ]; } /** @@ -591,11 +591,11 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function humanizeProvider() { - return array( - array('Author', 'author_id'), - array('Test user', ' _test_user_'), - array('Συγγραφέας', ' συγγραφέας_id ', 'UTF-8') - ); + return [ + ['Author', 'author_id'], + ['Test user', ' _test_user_'], + ['Συγγραφέας', ' συγγραφέας_id ', 'UTF-8'] + ]; } /** @@ -612,12 +612,12 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function tidyProvider() { - return array( - array('"I see..."', '“I see…”'), - array("'This too'", "‘This too’"), - array('test-dash', 'test—dash'), - array('Ο συγγραφέας είπε...', 'Ο συγγραφέας είπε…') - ); + return [ + ['"I see..."', '“I see…”'], + ["'This too'", "‘This too’"], + ['test-dash', 'test—dash'], + ['Ο συγγραφέας είπε...', 'Ο συγγραφέας είπε…'] + ]; } /** @@ -634,20 +634,20 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function collapseWhitespaceProvider() { - return array( - array('foo bar', ' foo bar '), - array('test string', 'test string'), - array('Ο συγγραφέας', ' Ο συγγραφέας '), - array('123', ' 123 '), - array('', ' ', 'UTF-8'), // no-break space (U+00A0) - array('', '           ', 'UTF-8'), // spaces U+2000 to U+200A - array('', ' ', 'UTF-8'), // narrow no-break space (U+202F) - array('', ' ', 'UTF-8'), // medium mathematical space (U+205F) - array('', ' ', 'UTF-8'), // ideographic space (U+3000) - array('1 2 3', '  1  2  3  ', 'UTF-8'), - array('', ' '), - array('', ''), - ); + return [ + ['foo bar', ' foo bar '], + ['test string', 'test string'], + ['Ο συγγραφέας', ' Ο συγγραφέας '], + ['123', ' 123 '], + ['', ' ', 'UTF-8'], // no-break space (U+00A0) + ['', '           ', 'UTF-8'], // spaces U+2000 to U+200A + ['', ' ', 'UTF-8'], // narrow no-break space (U+202F) + ['', ' ', 'UTF-8'], // medium mathematical space (U+205F) + ['', ' ', 'UTF-8'], // ideographic space (U+3000) + ['1 2 3', '  1  2  3  ', 'UTF-8'], + ['', ' '], + ['', ''], + ]; } /** @@ -665,28 +665,28 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function toAsciiProvider() { - return array( - array('foo bar', 'fòô bàř'), - array(' TEST ', ' ŤÉŚŢ '), - array('f = z = 3', 'φ = ź = 3'), - array('perevirka', 'перевірка'), - array('lysaya gora', 'лысая гора'), - array('shchuka', 'щука'), - array('', '漢字'), - array('xin chao the gioi', 'xin chào thế giới'), - array('XIN CHAO THE GIOI', 'XIN CHÀO THẾ GIỚI'), - array('dam phat chet luon', 'đấm phát chết luôn'), - array(' ', ' '), // no-break space (U+00A0) - array(' ', '           '), // spaces U+2000 to U+200A - array(' ', ' '), // narrow no-break space (U+202F) - array(' ', ' '), // medium mathematical space (U+205F) - array(' ', ' '), // ideographic space (U+3000) - array('', '𐍉'), // some uncommon, unsupported character (U+10349) - array('𐍉', '𐍉', 'en', false), - array('aouAOU', 'äöüÄÖÜ'), - array('aeoeueAEOEUE', 'äöüÄÖÜ', 'de'), - array('aeoeueAEOEUE', 'äöüÄÖÜ', 'de_DE') - ); + return [ + ['foo bar', 'fòô bàř'], + [' TEST ', ' ŤÉŚŢ '], + ['f = z = 3', 'φ = ź = 3'], + ['perevirka', 'перевірка'], + ['lysaya gora', 'лысая гора'], + ['shchuka', 'щука'], + ['', '漢字'], + ['xin chao the gioi', 'xin chào thế giới'], + ['XIN CHAO THE GIOI', 'XIN CHÀO THẾ GIỚI'], + ['dam phat chet luon', 'đấm phát chết luôn'], + [' ', ' '], // no-break space (U+00A0) + [' ', '           '], // spaces U+2000 to U+200A + [' ', ' '], // narrow no-break space (U+202F) + [' ', ' '], // medium mathematical space (U+205F) + [' ', ' '], // ideographic space (U+3000) + ['', '𐍉'], // some uncommon, unsupported character (U+10349) + ['𐍉', '𐍉', 'en', false], + ['aouAOU', 'äöüÄÖÜ'], + ['aeoeueAEOEUE', 'äöüÄÖÜ', 'de'], + ['aeoeueAEOEUE', 'äöüÄÖÜ', 'de_DE'] + ]; } /** @@ -704,27 +704,27 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function padProvider() { - return array( + return [ // length <= str - array('foo bar', 'foo bar', -1), - array('foo bar', 'foo bar', 7), - array('fòô bàř', 'fòô bàř', 7, ' ', 'right', 'UTF-8'), + ['foo bar', 'foo bar', -1], + ['foo bar', 'foo bar', 7], + ['fòô bàř', 'fòô bàř', 7, ' ', 'right', 'UTF-8'], // right - array('foo bar ', 'foo bar', 9), - array('foo bar_*', 'foo bar', 9, '_*', 'right'), - array('fòô bàř¬ø¬', 'fòô bàř', 10, '¬ø', 'right', 'UTF-8'), + ['foo bar ', 'foo bar', 9], + ['foo bar_*', 'foo bar', 9, '_*', 'right'], + ['fòô bàř¬ø¬', 'fòô bàř', 10, '¬ø', 'right', 'UTF-8'], // left - array(' foo bar', 'foo bar', 9, ' ', 'left'), - array('_*foo bar', 'foo bar', 9, '_*', 'left'), - array('¬ø¬fòô bàř', 'fòô bàř', 10, '¬ø', 'left', 'UTF-8'), + [' foo bar', 'foo bar', 9, ' ', 'left'], + ['_*foo bar', 'foo bar', 9, '_*', 'left'], + ['¬ø¬fòô bàř', 'fòô bàř', 10, '¬ø', 'left', 'UTF-8'], // both - array('foo bar ', 'foo bar', 8, ' ', 'both'), - array('¬fòô bàř¬ø', 'fòô bàř', 10, '¬ø', 'both', 'UTF-8'), - array('¬øfòô bàř¬øÿ', 'fòô bàř', 12, '¬øÿ', 'both', 'UTF-8') - ); + ['foo bar ', 'foo bar', 8, ' ', 'both'], + ['¬fòô bàř¬ø', 'fòô bàř', 10, '¬ø', 'both', 'UTF-8'], + ['¬øfòô bàř¬øÿ', 'fòô bàř', 12, '¬øÿ', 'both', 'UTF-8'] + ]; } /** @@ -751,15 +751,15 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function padLeftProvider() { - return array( - array(' foo bar', 'foo bar', 9), - array('_*foo bar', 'foo bar', 9, '_*'), - array('_*_foo bar', 'foo bar', 10, '_*'), - array(' fòô bàř', 'fòô bàř', 9, ' ', 'UTF-8'), - array('¬øfòô bàř', 'fòô bàř', 9, '¬ø', 'UTF-8'), - array('¬ø¬fòô bàř', 'fòô bàř', 10, '¬ø', 'UTF-8'), - array('¬ø¬øfòô bàř', 'fòô bàř', 11, '¬ø', 'UTF-8'), - ); + return [ + [' foo bar', 'foo bar', 9], + ['_*foo bar', 'foo bar', 9, '_*'], + ['_*_foo bar', 'foo bar', 10, '_*'], + [' fòô bàř', 'fòô bàř', 9, ' ', 'UTF-8'], + ['¬øfòô bàř', 'fòô bàř', 9, '¬ø', 'UTF-8'], + ['¬ø¬fòô bàř', 'fòô bàř', 10, '¬ø', 'UTF-8'], + ['¬ø¬øfòô bàř', 'fòô bàř', 11, '¬ø', 'UTF-8'], + ]; } /** @@ -777,15 +777,15 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function padRightProvider() { - return array( - array('foo bar ', 'foo bar', 9), - array('foo bar_*', 'foo bar', 9, '_*'), - array('foo bar_*_', 'foo bar', 10, '_*'), - array('fòô bàř ', 'fòô bàř', 9, ' ', 'UTF-8'), - array('fòô bàř¬ø', 'fòô bàř', 9, '¬ø', 'UTF-8'), - array('fòô bàř¬ø¬', 'fòô bàř', 10, '¬ø', 'UTF-8'), - array('fòô bàř¬ø¬ø', 'fòô bàř', 11, '¬ø', 'UTF-8'), - ); + return [ + ['foo bar ', 'foo bar', 9], + ['foo bar_*', 'foo bar', 9, '_*'], + ['foo bar_*_', 'foo bar', 10, '_*'], + ['fòô bàř ', 'fòô bàř', 9, ' ', 'UTF-8'], + ['fòô bàř¬ø', 'fòô bàř', 9, '¬ø', 'UTF-8'], + ['fòô bàř¬ø¬', 'fòô bàř', 10, '¬ø', 'UTF-8'], + ['fòô bàř¬ø¬ø', 'fòô bàř', 11, '¬ø', 'UTF-8'], + ]; } /** @@ -803,19 +803,19 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function padBothProvider() { - return array( - array('foo bar ', 'foo bar', 8), - array(' foo bar ', 'foo bar', 9, ' '), - array('fòô bàř ', 'fòô bàř', 8, ' ', 'UTF-8'), - array(' fòô bàř ', 'fòô bàř', 9, ' ', 'UTF-8'), - array('fòô bàř¬', 'fòô bàř', 8, '¬ø', 'UTF-8'), - array('¬fòô bàř¬', 'fòô bàř', 9, '¬ø', 'UTF-8'), - array('¬fòô bàř¬ø', 'fòô bàř', 10, '¬ø', 'UTF-8'), - array('¬øfòô bàř¬ø', 'fòô bàř', 11, '¬ø', 'UTF-8'), - array('¬fòô bàř¬ø', 'fòô bàř', 10, '¬øÿ', 'UTF-8'), - array('¬øfòô bàř¬ø', 'fòô bàř', 11, '¬øÿ', 'UTF-8'), - array('¬øfòô bàř¬øÿ', 'fòô bàř', 12, '¬øÿ', 'UTF-8') - ); + return [ + ['foo bar ', 'foo bar', 8], + [' foo bar ', 'foo bar', 9, ' '], + ['fòô bàř ', 'fòô bàř', 8, ' ', 'UTF-8'], + [' fòô bàř ', 'fòô bàř', 9, ' ', 'UTF-8'], + ['fòô bàř¬', 'fòô bàř', 8, '¬ø', 'UTF-8'], + ['¬fòô bàř¬', 'fòô bàř', 9, '¬ø', 'UTF-8'], + ['¬fòô bàř¬ø', 'fòô bàř', 10, '¬ø', 'UTF-8'], + ['¬øfòô bàř¬ø', 'fòô bàř', 11, '¬ø', 'UTF-8'], + ['¬fòô bàř¬ø', 'fòô bàř', 10, '¬øÿ', 'UTF-8'], + ['¬øfòô bàř¬ø', 'fòô bàř', 11, '¬øÿ', 'UTF-8'], + ['¬øfòô bàř¬øÿ', 'fòô bàř', 12, '¬øÿ', 'UTF-8'] + ]; } /** @@ -833,19 +833,19 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function startsWithProvider() { - return array( - array(true, 'foo bars', 'foo bar'), - array(true, 'FOO bars', 'foo bar', false), - array(true, 'FOO bars', 'foo BAR', false), - array(true, 'FÒÔ bàřs', 'fòô bàř', false, 'UTF-8'), - array(true, 'fòô bàřs', 'fòô BÀŘ', false, 'UTF-8'), - array(false, 'foo bar', 'bar'), - array(false, 'foo bar', 'foo bars'), - array(false, 'FOO bar', 'foo bars'), - array(false, 'FOO bars', 'foo BAR'), - array(false, 'FÒÔ bàřs', 'fòô bàř', true, 'UTF-8'), - array(false, 'fòô bàřs', 'fòô BÀŘ', true, 'UTF-8'), - ); + return [ + [true, 'foo bars', 'foo bar'], + [true, 'FOO bars', 'foo bar', false], + [true, 'FOO bars', 'foo BAR', false], + [true, 'FÒÔ bàřs', 'fòô bàř', false, 'UTF-8'], + [true, 'fòô bàřs', 'fòô BÀŘ', false, 'UTF-8'], + [false, 'foo bar', 'bar'], + [false, 'foo bar', 'foo bars'], + [false, 'FOO bar', 'foo bars'], + [false, 'FOO bars', 'foo BAR'], + [false, 'FÒÔ bàřs', 'fòô bàř', true, 'UTF-8'], + [false, 'fòô bàřs', 'fòô BÀŘ', true, 'UTF-8'], + ]; } /** @@ -863,19 +863,19 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function startsWithProviderAny() { - return array( - array(true, 'foo bars', array('foo bar')), - array(true, 'FOO bars', array('foo bar'), false), - array(true, 'FOO bars', array('foo bar', 'foo BAR'), false), - array(true, 'FÒÔ bàřs', array('foo bar', 'fòô bàř'), false, 'UTF-8'), - array(true, 'fòô bàřs', array('foo bar', 'fòô BÀŘ'), false, 'UTF-8'), - array(false, 'foo bar', array('bar')), - array(false, 'foo bar', array('foo bars')), - array(false, 'FOO bar', array('foo bars')), - array(false, 'FOO bars', array('foo BAR')), - array(false, 'FÒÔ bàřs', array('fòô bàř'), true, 'UTF-8'), - array(false, 'fòô bàřs', array('fòô BÀŘ'), true, 'UTF-8'), - ); + return [ + [true, 'foo bars', ['foo bar']], + [true, 'FOO bars', ['foo bar'], false], + [true, 'FOO bars', ['foo bar', 'foo BAR'], false], + [true, 'FÒÔ bàřs', ['foo bar', 'fòô bàř'], false, 'UTF-8'], + [true, 'fòô bàřs', ['foo bar', 'fòô BÀŘ'], false, 'UTF-8'], + [false, 'foo bar', ['bar']], + [false, 'foo bar', ['foo bars']], + [false, 'FOO bar', ['foo bars']], + [false, 'FOO bars', ['foo BAR']], + [false, 'FÒÔ bàřs', ['fòô bàř'], true, 'UTF-8'], + [false, 'fòô bàřs', ['fòô BÀŘ'], true, 'UTF-8'], + ]; } /** @@ -893,19 +893,19 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function endsWithProvider() { - return array( - array(true, 'foo bars', 'o bars'), - array(true, 'FOO bars', 'o bars', false), - array(true, 'FOO bars', 'o BARs', false), - array(true, 'FÒÔ bàřs', 'ô bàřs', false, 'UTF-8'), - array(true, 'fòô bàřs', 'ô BÀŘs', false, 'UTF-8'), - array(false, 'foo bar', 'foo'), - array(false, 'foo bar', 'foo bars'), - array(false, 'FOO bar', 'foo bars'), - array(false, 'FOO bars', 'foo BARS'), - array(false, 'FÒÔ bàřs', 'fòô bàřs', true, 'UTF-8'), - array(false, 'fòô bàřs', 'fòô BÀŘS', true, 'UTF-8'), - ); + return [ + [true, 'foo bars', 'o bars'], + [true, 'FOO bars', 'o bars', false], + [true, 'FOO bars', 'o BARs', false], + [true, 'FÒÔ bàřs', 'ô bàřs', false, 'UTF-8'], + [true, 'fòô bàřs', 'ô BÀŘs', false, 'UTF-8'], + [false, 'foo bar', 'foo'], + [false, 'foo bar', 'foo bars'], + [false, 'FOO bar', 'foo bars'], + [false, 'FOO bars', 'foo BARS'], + [false, 'FÒÔ bàřs', 'fòô bàřs', true, 'UTF-8'], + [false, 'fòô bàřs', 'fòô BÀŘS', true, 'UTF-8'], + ]; } /** @@ -923,19 +923,19 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function endsWithAnyProvider() { - return array( - array(true, 'foo bars', array('foo', 'o bars')), - array(true, 'FOO bars', array('foo', 'o bars'), false), - array(true, 'FOO bars', array('foo', 'o BARs'), false), - array(true, 'FÒÔ bàřs', array('foo', 'ô bàřs'), false, 'UTF-8'), - array(true, 'fòô bàřs', array('foo', 'ô BÀŘs'), false, 'UTF-8'), - array(false, 'foo bar', array('foo')), - array(false, 'foo bar', array('foo', 'foo bars')), - array(false, 'FOO bar', array('foo', 'foo bars')), - array(false, 'FOO bars', array('foo', 'foo BARS')), - array(false, 'FÒÔ bàřs', array('fòô', 'fòô bàřs'), true, 'UTF-8'), - array(false, 'fòô bàřs', array('fòô', 'fòô BÀŘS'), true, 'UTF-8'), - ); + return [ + [true, 'foo bars', ['foo', 'o bars']], + [true, 'FOO bars', ['foo', 'o bars'], false], + [true, 'FOO bars', ['foo', 'o BARs'], false], + [true, 'FÒÔ bàřs', ['foo', 'ô bàřs'], false, 'UTF-8'], + [true, 'fòô bàřs', ['foo', 'ô BÀŘs'], false, 'UTF-8'], + [false, 'foo bar', ['foo']], + [false, 'foo bar', ['foo', 'foo bars']], + [false, 'FOO bar', ['foo', 'foo bars']], + [false, 'FOO bars', ['foo', 'foo BARS']], + [false, 'FÒÔ bàřs', ['fòô', 'fòô bàřs'], true, 'UTF-8'], + [false, 'fòô bàřs', ['fòô', 'fòô BÀŘS'], true, 'UTF-8'], + ]; } /** @@ -952,23 +952,23 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function toBooleanProvider() { - return array( - array(true, 'true'), - array(true, '1'), - array(true, 'on'), - array(true, 'ON'), - array(true, 'yes'), - array(true, '999'), - array(false, 'false'), - array(false, '0'), - array(false, 'off'), - array(false, 'OFF'), - array(false, 'no'), - array(false, '-999'), - array(false, ''), - array(false, ' '), - array(false, '  ', 'UTF-8') // narrow no-break space (U+202F) - ); + return [ + [true, 'true'], + [true, '1'], + [true, 'on'], + [true, 'ON'], + [true, 'yes'], + [true, '999'], + [false, 'false'], + [false, '0'], + [false, 'off'], + [false, 'OFF'], + [false, 'no'], + [false, '-999'], + [false, ''], + [false, ' '], + [false, '  ', 'UTF-8'] // narrow no-break space (U+202F) + ]; } /** @@ -985,14 +985,14 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function toSpacesProvider() { - return array( - array(' foo bar ', ' foo bar '), - array(' foo bar ', ' foo bar ', 5), - array(' foo bar ', ' foo bar ', 2), - array('foobar', ' foo bar ', 0), - array(" foo\n bar", " foo\n bar"), - array(" fòô\n bàř", " fòô\n bàř") - ); + return [ + [' foo bar ', ' foo bar '], + [' foo bar ', ' foo bar ', 5], + [' foo bar ', ' foo bar ', 2], + ['foobar', ' foo bar ', 0], + [" foo\n bar", " foo\n bar"], + [" fòô\n bàř", " fòô\n bàř"] + ]; } /** @@ -1009,13 +1009,13 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function toTabsProvider() { - return array( - array(' foo bar ', ' foo bar '), - array(' foo bar ', ' foo bar ', 5), - array(' foo bar ', ' foo bar ', 2), - array(" foo\n bar", " foo\n bar"), - array(" fòô\n bàř", " fòô\n bàř") - ); + return [ + [' foo bar ', ' foo bar '], + [' foo bar ', ' foo bar ', 5], + [' foo bar ', ' foo bar ', 2], + [" foo\n bar", " foo\n bar"], + [" fòô\n bàř", " fòô\n bàř"] + ]; } /** @@ -1032,13 +1032,13 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function toLowerCaseProvider() { - return array( - array('foo bar', 'FOO BAR'), - array(' foo_bar ', ' FOO_bar '), - array('fòô bàř', 'FÒÔ BÀŘ', 'UTF-8'), - array(' fòô_bàř ', ' FÒÔ_bàř ', 'UTF-8'), - array('αυτοκίνητο', 'ΑΥΤΟΚΊΝΗΤΟ', 'UTF-8'), - ); + return [ + ['foo bar', 'FOO BAR'], + [' foo_bar ', ' FOO_bar '], + ['fòô bàř', 'FÒÔ BÀŘ', 'UTF-8'], + [' fòô_bàř ', ' FÒÔ_bàř ', 'UTF-8'], + ['αυτοκίνητο', 'ΑΥΤΟΚΊΝΗΤΟ', 'UTF-8'], + ]; } /** @@ -1055,13 +1055,13 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function toTitleCaseProvider() { - return array( - array('Foo Bar', 'foo bar'), - array(' Foo_Bar ', ' foo_bar '), - array('Fòô Bàř', 'fòô bàř', 'UTF-8'), - array(' Fòô_Bàř ', ' fòô_bàř ', 'UTF-8'), - array('Αυτοκίνητο Αυτοκίνητο', 'αυτοκίνητο αυτοκίνητο', 'UTF-8'), - ); + return [ + ['Foo Bar', 'foo bar'], + [' Foo_Bar ', ' foo_bar '], + ['Fòô Bàř', 'fòô bàř', 'UTF-8'], + [' Fòô_Bàř ', ' fòô_bàř ', 'UTF-8'], + ['Αυτοκίνητο Αυτοκίνητο', 'αυτοκίνητο αυτοκίνητο', 'UTF-8'], + ]; } /** @@ -1078,13 +1078,13 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function toUpperCaseProvider() { - return array( - array('FOO BAR', 'foo bar'), - array(' FOO_BAR ', ' FOO_bar '), - array('FÒÔ BÀŘ', 'fòô bàř', 'UTF-8'), - array(' FÒÔ_BÀŘ ', ' FÒÔ_bàř ', 'UTF-8'), - array('ΑΥΤΟΚΊΝΗΤΟ', 'αυτοκίνητο', 'UTF-8'), - ); + return [ + ['FOO BAR', 'foo bar'], + [' FOO_BAR ', ' FOO_bar '], + ['FÒÔ BÀŘ', 'fòô bàř', 'UTF-8'], + [' FÒÔ_BÀŘ ', ' FÒÔ_bàř ', 'UTF-8'], + ['ΑΥΤΟΚΊΝΗΤΟ', 'αυτοκίνητο', 'UTF-8'], + ]; } /** @@ -1101,23 +1101,23 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function slugifyProvider() { - return array( - array('foo-bar', ' foo bar '), - array('foo-bar', 'foo -.-"-...bar'), - array('another-foo-bar', 'another..& foo -.-"-...bar'), - array('foo-dbar', " Foo d'Bar "), - array('a-string-with-dashes', 'A string-with-dashes'), - array('using-strings-like-foo-bar', 'Using strings like fòô bàř'), - array('numbers-1234', 'numbers 1234'), - array('perevirka-ryadka', 'перевірка рядка'), - array('bukvar-s-bukvoy-y', 'букварь с буквой ы'), - array('podekhal-k-podezdu-moego-doma', 'подъехал к подъезду моего дома'), - array('foo:bar:baz', 'Foo bar baz', ':'), - array('a_string_with_underscores', 'A_string with_underscores', '_'), - array('a_string_with_dashes', 'A string-with-dashes', '_'), - array('a\string\with\dashes', 'A string-with-dashes', '\\'), - array('an_odd_string', '-- An odd__ string-_', '_') - ); + return [ + ['foo-bar', ' foo bar '], + ['foo-bar', 'foo -.-"-...bar'], + ['another-foo-bar', 'another..& foo -.-"-...bar'], + ['foo-dbar', " Foo d'Bar "], + ['a-string-with-dashes', 'A string-with-dashes'], + ['using-strings-like-foo-bar', 'Using strings like fòô bàř'], + ['numbers-1234', 'numbers 1234'], + ['perevirka-ryadka', 'перевірка рядка'], + ['bukvar-s-bukvoy-y', 'букварь с буквой ы'], + ['podekhal-k-podezdu-moego-doma', 'подъехал к подъезду моего дома'], + ['foo:bar:baz', 'Foo bar baz', ':'], + ['a_string_with_underscores', 'A_string with_underscores', '_'], + ['a_string_with_dashes', 'A string-with-dashes', '_'], + ['a\string\with\dashes', 'A string-with-dashes', '\\'], + ['an_odd_string', '-- An odd__ string-_', '_'] + ]; } /** @@ -1135,24 +1135,24 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function betweenProvider() { - return array( - array('', 'foo', '{', '}'), - array('', '{foo', '{', '}'), - array('foo', '{foo}', '{', '}'), - array('{foo', '{{foo}', '{', '}'), - array('', '{}foo}', '{', '}'), - array('foo', '}{foo}', '{', '}'), - array('foo', 'A description of {foo} goes here', '{', '}'), - array('bar', '{foo} and {bar}', '{', '}', 1), - array('', 'fòô', '{', '}', 0, 'UTF-8'), - array('', '{fòô', '{', '}', 0, 'UTF-8'), - array('fòô', '{fòô}', '{', '}', 0, 'UTF-8'), - array('{fòô', '{{fòô}', '{', '}', 0, 'UTF-8'), - array('', '{}fòô}', '{', '}', 0, 'UTF-8'), - array('fòô', '}{fòô}', '{', '}', 0, 'UTF-8'), - array('fòô', 'A description of {fòô} goes here', '{', '}', 0, 'UTF-8'), - array('bàř', '{fòô} and {bàř}', '{', '}', 1, 'UTF-8') - ); + return [ + ['', 'foo', '{', '}'], + ['', '{foo', '{', '}'], + ['foo', '{foo}', '{', '}'], + ['{foo', '{{foo}', '{', '}'], + ['', '{}foo}', '{', '}'], + ['foo', '}{foo}', '{', '}'], + ['foo', 'A description of {foo} goes here', '{', '}'], + ['bar', '{foo} and {bar}', '{', '}', 1], + ['', 'fòô', '{', '}', 0, 'UTF-8'], + ['', '{fòô', '{', '}', 0, 'UTF-8'], + ['fòô', '{fòô}', '{', '}', 0, 'UTF-8'], + ['{fòô', '{{fòô}', '{', '}', 0, 'UTF-8'], + ['', '{}fòô}', '{', '}', 0, 'UTF-8'], + ['fòô', '}{fòô}', '{', '}', 0, 'UTF-8'], + ['fòô', 'A description of {fòô} goes here', '{', '}', 0, 'UTF-8'], + ['bàř', '{fòô} and {bàř}', '{', '}', 1, 'UTF-8'] + ]; } /** @@ -1170,29 +1170,29 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function containsProvider() { - return array( - array(true, 'Str contains foo bar', 'foo bar'), - array(true, '12398!@(*%!@# @!%#*&^%', ' @!%#*&^%'), - array(true, 'Ο συγγραφέας είπε', 'συγγραφέας', 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'å´¥©', true, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'å˚ ∆', true, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'øœ¬', true, 'UTF-8'), - array(false, 'Str contains foo bar', 'Foo bar'), - array(false, 'Str contains foo bar', 'foobar'), - array(false, 'Str contains foo bar', 'foo bar '), - array(false, 'Ο συγγραφέας είπε', ' συγγραφέας ', true, 'UTF-8'), - array(false, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ' ßå˚', true, 'UTF-8'), - array(true, 'Str contains foo bar', 'Foo bar', false), - array(true, '12398!@(*%!@# @!%#*&^%', ' @!%#*&^%', false), - array(true, 'Ο συγγραφέας είπε', 'ΣΥΓΓΡΑΦΈΑΣ', false, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'Å´¥©', false, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'Å˚ ∆', false, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'ØŒ¬', false, 'UTF-8'), - array(false, 'Str contains foo bar', 'foobar', false), - array(false, 'Str contains foo bar', 'foo bar ', false), - array(false, 'Ο συγγραφέας είπε', ' συγγραφέας ', false, 'UTF-8'), - array(false, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ' ßÅ˚', false, 'UTF-8') - ); + return [ + [true, 'Str contains foo bar', 'foo bar'], + [true, '12398!@(*%!@# @!%#*&^%', ' @!%#*&^%'], + [true, 'Ο συγγραφέας είπε', 'συγγραφέας', 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'å´¥©', true, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'å˚ ∆', true, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'øœ¬', true, 'UTF-8'], + [false, 'Str contains foo bar', 'Foo bar'], + [false, 'Str contains foo bar', 'foobar'], + [false, 'Str contains foo bar', 'foo bar '], + [false, 'Ο συγγραφέας είπε', ' συγγραφέας ', true, 'UTF-8'], + [false, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ' ßå˚', true, 'UTF-8'], + [true, 'Str contains foo bar', 'Foo bar', false], + [true, '12398!@(*%!@# @!%#*&^%', ' @!%#*&^%', false], + [true, 'Ο συγγραφέας είπε', 'ΣΥΓΓΡΑΦΈΑΣ', false, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'Å´¥©', false, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'Å˚ ∆', false, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'ØŒ¬', false, 'UTF-8'], + [false, 'Str contains foo bar', 'foobar', false], + [false, 'Str contains foo bar', 'foo bar ', false], + [false, 'Ο συγγραφέας είπε', ' συγγραφέας ', false, 'UTF-8'], + [false, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ' ßÅ˚', false, 'UTF-8'] + ]; } /** @@ -1212,36 +1212,36 @@ class StringyTestCase extends PHPUnit_Framework_TestCase { // One needle $singleNeedle = array_map(function ($array) { - $array[2] = array($array[2]); + $array[2] = [$array[2]]; return $array; }, $this->containsProvider()); - $provider = array( + $provider = [ // No needles - array(false, 'Str contains foo bar', array()), + [false, 'Str contains foo bar', []], // Multiple needles - array(true, 'Str contains foo bar', array('foo', 'bar')), - array(true, '12398!@(*%!@# @!%#*&^%', array(' @!%#*', '&^%')), - array(true, 'Ο συγγραφέας είπε', array('συγγρ', 'αφέας'), 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array('å´¥', '©'), true, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array('å˚ ', '∆'), true, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array('øœ', '¬'), true, 'UTF-8'), - array(false, 'Str contains foo bar', array('Foo', 'Bar')), - array(false, 'Str contains foo bar', array('foobar', 'bar ')), - array(false, 'Str contains foo bar', array('foo bar ', ' foo')), - array(false, 'Ο συγγραφέας είπε', array(' συγγραφέας ', ' συγγραφ '), true, 'UTF-8'), - array(false, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array(' ßå˚', ' ß '), true, 'UTF-8'), - array(true, 'Str contains foo bar', array('Foo bar', 'bar'), false), - array(true, '12398!@(*%!@# @!%#*&^%', array(' @!%#*&^%', '*&^%'), false), - array(true, 'Ο συγγραφέας είπε', array('ΣΥΓΓΡΑΦΈΑΣ', 'ΑΦΈΑ'), false, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array('Å´¥©', '¥©'), false, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array('Å˚ ∆', ' ∆'), false, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array('ØŒ¬', 'Œ'), false, 'UTF-8'), - array(false, 'Str contains foo bar', array('foobar', 'none'), false), - array(false, 'Str contains foo bar', array('foo bar ', ' ba '), false), - array(false, 'Ο συγγραφέας είπε', array(' συγγραφέας ', ' ραφέ '), false, 'UTF-8'), - array(false, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array(' ßÅ˚', ' Å˚ '), false, 'UTF-8'), - ); + [true, 'Str contains foo bar', ['foo', 'bar']], + [true, '12398!@(*%!@# @!%#*&^%', [' @!%#*', '&^%']], + [true, 'Ο συγγραφέας είπε', ['συγγρ', 'αφέας'], 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ['å´¥', '©'], true, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ['å˚ ', '∆'], true, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ['øœ', '¬'], true, 'UTF-8'], + [false, 'Str contains foo bar', ['Foo', 'Bar']], + [false, 'Str contains foo bar', ['foobar', 'bar ']], + [false, 'Str contains foo bar', ['foo bar ', ' foo']], + [false, 'Ο συγγραφέας είπε', [' συγγραφέας ', ' συγγραφ '], true, 'UTF-8'], + [false, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', [' ßå˚', ' ß '], true, 'UTF-8'], + [true, 'Str contains foo bar', ['Foo bar', 'bar'], false], + [true, '12398!@(*%!@# @!%#*&^%', [' @!%#*&^%', '*&^%'], false], + [true, 'Ο συγγραφέας είπε', ['ΣΥΓΓΡΑΦΈΑΣ', 'ΑΦΈΑ'], false, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ['Å´¥©', '¥©'], false, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ['Å˚ ∆', ' ∆'], false, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ['ØŒ¬', 'Œ'], false, 'UTF-8'], + [false, 'Str contains foo bar', ['foobar', 'none'], false], + [false, 'Str contains foo bar', ['foo bar ', ' ba '], false], + [false, 'Ο συγγραφέας είπε', [' συγγραφέας ', ' ραφέ '], false, 'UTF-8'], + [false, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', [' ßÅ˚', ' Å˚ '], false, 'UTF-8'], + ]; return array_merge($singleNeedle, $provider); } @@ -1263,36 +1263,36 @@ class StringyTestCase extends PHPUnit_Framework_TestCase { // One needle $singleNeedle = array_map(function ($array) { - $array[2] = array($array[2]); + $array[2] = [$array[2]]; return $array; }, $this->containsProvider()); - $provider = array( + $provider = [ // One needle - array(false, 'Str contains foo bar', array()), + [false, 'Str contains foo bar', []], // Multiple needles - array(true, 'Str contains foo bar', array('foo', 'bar')), - array(true, '12398!@(*%!@# @!%#*&^%', array(' @!%#*', '&^%')), - array(true, 'Ο συγγραφέας είπε', array('συγγρ', 'αφέας'), 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array('å´¥', '©'), true, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array('å˚ ', '∆'), true, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array('øœ', '¬'), true, 'UTF-8'), - array(false, 'Str contains foo bar', array('Foo', 'bar')), - array(false, 'Str contains foo bar', array('foobar', 'bar')), - array(false, 'Str contains foo bar', array('foo bar ', 'bar')), - array(false, 'Ο συγγραφέας είπε', array(' συγγραφέας ', ' συγγραφ '), true, 'UTF-8'), - array(false, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array(' ßå˚', ' ß '), true, 'UTF-8'), - array(true, 'Str contains foo bar', array('Foo bar', 'bar'), false), - array(true, '12398!@(*%!@# @!%#*&^%', array(' @!%#*&^%', '*&^%'), false), - array(true, 'Ο συγγραφέας είπε', array('ΣΥΓΓΡΑΦΈΑΣ', 'ΑΦΈΑ'), false, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array('Å´¥©', '¥©'), false, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array('Å˚ ∆', ' ∆'), false, 'UTF-8'), - array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array('ØŒ¬', 'Œ'), false, 'UTF-8'), - array(false, 'Str contains foo bar', array('foobar', 'none'), false), - array(false, 'Str contains foo bar', array('foo bar ', ' ba'), false), - array(false, 'Ο συγγραφέας είπε', array(' συγγραφέας ', ' ραφέ '), false, 'UTF-8'), - array(false, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', array(' ßÅ˚', ' Å˚ '), false, 'UTF-8'), - ); + [true, 'Str contains foo bar', ['foo', 'bar']], + [true, '12398!@(*%!@# @!%#*&^%', [' @!%#*', '&^%']], + [true, 'Ο συγγραφέας είπε', ['συγγρ', 'αφέας'], 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ['å´¥', '©'], true, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ['å˚ ', '∆'], true, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ['øœ', '¬'], true, 'UTF-8'], + [false, 'Str contains foo bar', ['Foo', 'bar']], + [false, 'Str contains foo bar', ['foobar', 'bar']], + [false, 'Str contains foo bar', ['foo bar ', 'bar']], + [false, 'Ο συγγραφέας είπε', [' συγγραφέας ', ' συγγραφ '], true, 'UTF-8'], + [false, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', [' ßå˚', ' ß '], true, 'UTF-8'], + [true, 'Str contains foo bar', ['Foo bar', 'bar'], false], + [true, '12398!@(*%!@# @!%#*&^%', [' @!%#*&^%', '*&^%'], false], + [true, 'Ο συγγραφέας είπε', ['ΣΥΓΓΡΑΦΈΑΣ', 'ΑΦΈΑ'], false, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ['Å´¥©', '¥©'], false, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ['Å˚ ∆', ' ∆'], false, 'UTF-8'], + [true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ['ØŒ¬', 'Œ'], false, 'UTF-8'], + [false, 'Str contains foo bar', ['foobar', 'none'], false], + [false, 'Str contains foo bar', ['foo bar ', ' ba'], false], + [false, 'Ο συγγραφέας είπε', [' συγγραφέας ', ' ραφέ '], false, 'UTF-8'], + [false, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', [' ßÅ˚', ' Å˚ '], false, 'UTF-8'], + ]; return array_merge($singleNeedle, $provider); } @@ -1311,13 +1311,13 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function surroundProvider() { - return array( - array('__foobar__', 'foobar', '__'), - array('test', 'test', ''), - array('**', '', '*'), - array('¬fòô bàř¬', 'fòô bàř', '¬'), - array('ßå∆˚ test ßå∆˚', ' test ', 'ßå∆˚') - ); + return [ + ['__foobar__', 'foobar', '__'], + ['test', 'test', ''], + ['**', '', '*'], + ['¬fòô bàř¬', 'fòô bàř', '¬'], + ['ßå∆˚ test ßå∆˚', ' test ', 'ßå∆˚'] + ]; } /** @@ -1335,16 +1335,16 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function insertProvider() { - return array( - array('foo bar', 'oo bar', 'f', 0), - array('foo bar', 'f bar', 'oo', 1), - array('f bar', 'f bar', 'oo', 20), - array('foo bar', 'foo ba', 'r', 6), - array('fòôbàř', 'fòôbř', 'à', 4, 'UTF-8'), - array('fòô bàř', 'òô bàř', 'f', 0, 'UTF-8'), - array('fòô bàř', 'f bàř', 'òô', 1, 'UTF-8'), - array('fòô bàř', 'fòô bà', 'ř', 6, 'UTF-8') - ); + return [ + ['foo bar', 'oo bar', 'f', 0], + ['foo bar', 'f bar', 'oo', 1], + ['f bar', 'f bar', 'oo', 20], + ['foo bar', 'foo ba', 'r', 6], + ['fòôbàř', 'fòôbř', 'à', 4, 'UTF-8'], + ['fòô bàř', 'òô bàř', 'f', 0, 'UTF-8'], + ['fòô bàř', 'f bàř', 'òô', 1, 'UTF-8'], + ['fòô bàř', 'fòô bà', 'ř', 6, 'UTF-8'] + ]; } /** @@ -1362,30 +1362,30 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function truncateProvider() { - return array( - array('Test foo bar', 'Test foo bar', 12), - array('Test foo ba', 'Test foo bar', 11), - array('Test foo', 'Test foo bar', 8), - array('Test fo', 'Test foo bar', 7), - array('Test', 'Test foo bar', 4), - array('Test foo bar', 'Test foo bar', 12, '...'), - array('Test foo...', 'Test foo bar', 11, '...'), - array('Test ...', 'Test foo bar', 8, '...'), - array('Test...', 'Test foo bar', 7, '...'), - array('T...', 'Test foo bar', 4, '...'), - array('Test fo....', 'Test foo bar', 11, '....'), - array('Test fòô bàř', 'Test fòô bàř', 12, '', 'UTF-8'), - array('Test fòô bà', 'Test fòô bàř', 11, '', 'UTF-8'), - array('Test fòô', 'Test fòô bàř', 8, '', 'UTF-8'), - array('Test fò', 'Test fòô bàř', 7, '', 'UTF-8'), - array('Test', 'Test fòô bàř', 4, '', 'UTF-8'), - array('Test fòô bàř', 'Test fòô bàř', 12, 'ϰϰ', 'UTF-8'), - array('Test fòô ϰϰ', 'Test fòô bàř', 11, 'ϰϰ', 'UTF-8'), - array('Test fϰϰ', 'Test fòô bàř', 8, 'ϰϰ', 'UTF-8'), - array('Test ϰϰ', 'Test fòô bàř', 7, 'ϰϰ', 'UTF-8'), - array('Teϰϰ', 'Test fòô bàř', 4, 'ϰϰ', 'UTF-8'), - array('What are your pl...', 'What are your plans today?', 19, '...') - ); + return [ + ['Test foo bar', 'Test foo bar', 12], + ['Test foo ba', 'Test foo bar', 11], + ['Test foo', 'Test foo bar', 8], + ['Test fo', 'Test foo bar', 7], + ['Test', 'Test foo bar', 4], + ['Test foo bar', 'Test foo bar', 12, '...'], + ['Test foo...', 'Test foo bar', 11, '...'], + ['Test ...', 'Test foo bar', 8, '...'], + ['Test...', 'Test foo bar', 7, '...'], + ['T...', 'Test foo bar', 4, '...'], + ['Test fo....', 'Test foo bar', 11, '....'], + ['Test fòô bàř', 'Test fòô bàř', 12, '', 'UTF-8'], + ['Test fòô bà', 'Test fòô bàř', 11, '', 'UTF-8'], + ['Test fòô', 'Test fòô bàř', 8, '', 'UTF-8'], + ['Test fò', 'Test fòô bàř', 7, '', 'UTF-8'], + ['Test', 'Test fòô bàř', 4, '', 'UTF-8'], + ['Test fòô bàř', 'Test fòô bàř', 12, 'ϰϰ', 'UTF-8'], + ['Test fòô ϰϰ', 'Test fòô bàř', 11, 'ϰϰ', 'UTF-8'], + ['Test fϰϰ', 'Test fòô bàř', 8, 'ϰϰ', 'UTF-8'], + ['Test ϰϰ', 'Test fòô bàř', 7, 'ϰϰ', 'UTF-8'], + ['Teϰϰ', 'Test fòô bàř', 4, 'ϰϰ', 'UTF-8'], + ['What are your pl...', 'What are your plans today?', 19, '...'] + ]; } /** @@ -1403,30 +1403,30 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function safeTruncateProvider() { - return array( - array('Test foo bar', 'Test foo bar', 12), - array('Test foo', 'Test foo bar', 11), - array('Test foo', 'Test foo bar', 8), - array('Test', 'Test foo bar', 7), - array('Test', 'Test foo bar', 4), - array('Test foo bar', 'Test foo bar', 12, '...'), - array('Test foo...', 'Test foo bar', 11, '...'), - array('Test...', 'Test foo bar', 8, '...'), - array('Test...', 'Test foo bar', 7, '...'), - array('T...', 'Test foo bar', 4, '...'), - array('Test....', 'Test foo bar', 11, '....'), - array('Tëst fòô bàř', 'Tëst fòô bàř', 12, '', 'UTF-8'), - array('Tëst fòô', 'Tëst fòô bàř', 11, '', 'UTF-8'), - array('Tëst fòô', 'Tëst fòô bàř', 8, '', 'UTF-8'), - array('Tëst', 'Tëst fòô bàř', 7, '', 'UTF-8'), - array('Tëst', 'Tëst fòô bàř', 4, '', 'UTF-8'), - array('Tëst fòô bàř', 'Tëst fòô bàř', 12, 'ϰϰ', 'UTF-8'), - array('Tëst fòôϰϰ', 'Tëst fòô bàř', 11, 'ϰϰ', 'UTF-8'), - array('Tëstϰϰ', 'Tëst fòô bàř', 8, 'ϰϰ', 'UTF-8'), - array('Tëstϰϰ', 'Tëst fòô bàř', 7, 'ϰϰ', 'UTF-8'), - array('Tëϰϰ', 'Tëst fòô bàř', 4, 'ϰϰ', 'UTF-8'), - array('What are your plans...', 'What are your plans today?', 22, '...') - ); + return [ + ['Test foo bar', 'Test foo bar', 12], + ['Test foo', 'Test foo bar', 11], + ['Test foo', 'Test foo bar', 8], + ['Test', 'Test foo bar', 7], + ['Test', 'Test foo bar', 4], + ['Test foo bar', 'Test foo bar', 12, '...'], + ['Test foo...', 'Test foo bar', 11, '...'], + ['Test...', 'Test foo bar', 8, '...'], + ['Test...', 'Test foo bar', 7, '...'], + ['T...', 'Test foo bar', 4, '...'], + ['Test....', 'Test foo bar', 11, '....'], + ['Tëst fòô bàř', 'Tëst fòô bàř', 12, '', 'UTF-8'], + ['Tëst fòô', 'Tëst fòô bàř', 11, '', 'UTF-8'], + ['Tëst fòô', 'Tëst fòô bàř', 8, '', 'UTF-8'], + ['Tëst', 'Tëst fòô bàř', 7, '', 'UTF-8'], + ['Tëst', 'Tëst fòô bàř', 4, '', 'UTF-8'], + ['Tëst fòô bàř', 'Tëst fòô bàř', 12, 'ϰϰ', 'UTF-8'], + ['Tëst fòôϰϰ', 'Tëst fòô bàř', 11, 'ϰϰ', 'UTF-8'], + ['Tëstϰϰ', 'Tëst fòô bàř', 8, 'ϰϰ', 'UTF-8'], + ['Tëstϰϰ', 'Tëst fòô bàř', 7, 'ϰϰ', 'UTF-8'], + ['Tëϰϰ', 'Tëst fòô bàř', 4, 'ϰϰ', 'UTF-8'], + ['What are your plans...', 'What are your plans today?', 22, '...'] + ]; } /** @@ -1443,13 +1443,13 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function reverseProvider() { - return array( - array('', ''), - array('raboof', 'foobar'), - array('řàbôòf', 'fòôbàř', 'UTF-8'), - array('řàb ôòf', 'fòô bàř', 'UTF-8'), - array('∂∆ ˚åß', 'ßå˚ ∆∂', 'UTF-8') - ); + return [ + ['', ''], + ['raboof', 'foobar'], + ['řàbôòf', 'fòôbàř', 'UTF-8'], + ['řàb ôòf', 'fòô bàř', 'UTF-8'], + ['∂∆ ˚åß', 'ßå˚ ∆∂', 'UTF-8'] + ]; } /** @@ -1466,15 +1466,15 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function repeatProvider() { - return array( - array('', 'foo', 0), - array('foo', 'foo', 1), - array('foofoo', 'foo', 2), - array('foofoofoo', 'foo', 3), - array('fòô', 'fòô', 1, 'UTF-8'), - array('fòôfòô', 'fòô', 2, 'UTF-8'), - array('fòôfòôfòô', 'fòô', 3, 'UTF-8') - ); + return [ + ['', 'foo', 0], + ['foo', 'foo', 1], + ['foofoo', 'foo', 2], + ['foofoofoo', 'foo', 3], + ['fòô', 'fòô', 1, 'UTF-8'], + ['fòôfòô', 'fòô', 2, 'UTF-8'], + ['fòôfòôfòô', 'fòô', 3, 'UTF-8'] + ]; } /** @@ -1502,11 +1502,11 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function shuffleProvider() { - return array( - array('foo bar'), - array('∂∆ ˚åß', 'UTF-8'), - array('å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'UTF-8') - ); + return [ + ['foo bar'], + ['∂∆ ˚åß', 'UTF-8'], + ['å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'UTF-8'] + ]; } /** @@ -1523,20 +1523,20 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function trimProvider() { - return array( - array('foo bar', ' foo bar '), - array('foo bar', ' foo bar'), - array('foo bar', 'foo bar '), - array('foo bar', "\n\t foo bar \n\t"), - array('fòô bàř', ' fòô bàř '), - array('fòô bàř', ' fòô bàř'), - array('fòô bàř', 'fòô bàř '), - array(' foo bar ', "\n\t foo bar \n\t", "\n\t"), - array('fòô bàř', "\n\t fòô bàř \n\t", null, 'UTF-8'), - array('fòô', ' fòô ', null, 'UTF-8'), // narrow no-break space (U+202F) - array('fòô', '  fòô  ', null, 'UTF-8'), // medium mathematical space (U+205F) - array('fòô', '           fòô', null, 'UTF-8') // spaces U+2000 to U+200A - ); + return [ + ['foo bar', ' foo bar '], + ['foo bar', ' foo bar'], + ['foo bar', 'foo bar '], + ['foo bar', "\n\t foo bar \n\t"], + ['fòô bàř', ' fòô bàř '], + ['fòô bàř', ' fòô bàř'], + ['fòô bàř', 'fòô bàř '], + [' foo bar ', "\n\t foo bar \n\t", "\n\t"], + ['fòô bàř', "\n\t fòô bàř \n\t", null, 'UTF-8'], + ['fòô', ' fòô ', null, 'UTF-8'], // narrow no-break space (U+202F) + ['fòô', '  fòô  ', null, 'UTF-8'], // medium mathematical space (U+205F) + ['fòô', '           fòô', null, 'UTF-8'] // spaces U+2000 to U+200A + ]; } /** @@ -1554,21 +1554,21 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function trimLeftProvider() { - return array( - array('foo bar ', ' foo bar '), - array('foo bar', ' foo bar'), - array('foo bar ', 'foo bar '), - array("foo bar \n\t", "\n\t foo bar \n\t"), - array('fòô bàř ', ' fòô bàř '), - array('fòô bàř', ' fòô bàř'), - array('fòô bàř ', 'fòô bàř '), - array('foo bar', '--foo bar', '-'), - array('fòô bàř', 'òòfòô bàř', 'ò', 'UTF-8'), - array("fòô bàř \n\t", "\n\t fòô bàř \n\t", null, 'UTF-8'), - array('fòô ', ' fòô ', null, 'UTF-8'), // narrow no-break space (U+202F) - array('fòô  ', '  fòô  ', null, 'UTF-8'), // medium mathematical space (U+205F) - array('fòô', '           fòô', null, 'UTF-8') // spaces U+2000 to U+200A - ); + return [ + ['foo bar ', ' foo bar '], + ['foo bar', ' foo bar'], + ['foo bar ', 'foo bar '], + ["foo bar \n\t", "\n\t foo bar \n\t"], + ['fòô bàř ', ' fòô bàř '], + ['fòô bàř', ' fòô bàř'], + ['fòô bàř ', 'fòô bàř '], + ['foo bar', '--foo bar', '-'], + ['fòô bàř', 'òòfòô bàř', 'ò', 'UTF-8'], + ["fòô bàř \n\t", "\n\t fòô bàř \n\t", null, 'UTF-8'], + ['fòô ', ' fòô ', null, 'UTF-8'], // narrow no-break space (U+202F) + ['fòô  ', '  fòô  ', null, 'UTF-8'], // medium mathematical space (U+205F) + ['fòô', '           fòô', null, 'UTF-8'] // spaces U+2000 to U+200A + ]; } /** @@ -1586,21 +1586,21 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function trimRightProvider() { - return array( - array(' foo bar', ' foo bar '), - array('foo bar', 'foo bar '), - array(' foo bar', ' foo bar'), - array("\n\t foo bar", "\n\t foo bar \n\t"), - array(' fòô bàř', ' fòô bàř '), - array('fòô bàř', 'fòô bàř '), - array(' fòô bàř', ' fòô bàř'), - array('foo bar', 'foo bar--', '-'), - array('fòô bàř', 'fòô bàřòò', 'ò', 'UTF-8'), - array("\n\t fòô bàř", "\n\t fòô bàř \n\t", null, 'UTF-8'), - array(' fòô', ' fòô ', null, 'UTF-8'), // narrow no-break space (U+202F) - array('  fòô', '  fòô  ', null, 'UTF-8'), // medium mathematical space (U+205F) - array('fòô', 'fòô           ', null, 'UTF-8') // spaces U+2000 to U+200A - ); + return [ + [' foo bar', ' foo bar '], + ['foo bar', 'foo bar '], + [' foo bar', ' foo bar'], + ["\n\t foo bar", "\n\t foo bar \n\t"], + [' fòô bàř', ' fòô bàř '], + ['fòô bàř', 'fòô bàř '], + [' fòô bàř', ' fòô bàř'], + ['foo bar', 'foo bar--', '-'], + ['fòô bàř', 'fòô bàřòò', 'ò', 'UTF-8'], + ["\n\t fòô bàř", "\n\t fòô bàř \n\t", null, 'UTF-8'], + [' fòô', ' fòô ', null, 'UTF-8'], // narrow no-break space (U+202F) + ['  fòô', '  fòô  ', null, 'UTF-8'], // medium mathematical space (U+205F) + ['fòô', 'fòô           ', null, 'UTF-8'] // spaces U+2000 to U+200A + ]; } /** @@ -1618,18 +1618,18 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function longestCommonPrefixProvider() { - return array( - array('foo', 'foobar', 'foo bar'), - array('foo bar', 'foo bar', 'foo bar'), - array('f', 'foo bar', 'far boo'), - array('', 'toy car', 'foo bar'), - array('', 'foo bar', ''), - array('fòô', 'fòôbar', 'fòô bar', 'UTF-8'), - array('fòô bar', 'fòô bar', 'fòô bar', 'UTF-8'), - array('fò', 'fòô bar', 'fòr bar', 'UTF-8'), - array('', 'toy car', 'fòô bar', 'UTF-8'), - array('', 'fòô bar', '', 'UTF-8'), - ); + return [ + ['foo', 'foobar', 'foo bar'], + ['foo bar', 'foo bar', 'foo bar'], + ['f', 'foo bar', 'far boo'], + ['', 'toy car', 'foo bar'], + ['', 'foo bar', ''], + ['fòô', 'fòôbar', 'fòô bar', 'UTF-8'], + ['fòô bar', 'fòô bar', 'fòô bar', 'UTF-8'], + ['fò', 'fòô bar', 'fòr bar', 'UTF-8'], + ['', 'toy car', 'fòô bar', 'UTF-8'], + ['', 'fòô bar', '', 'UTF-8'], + ]; } /** @@ -1647,18 +1647,18 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function longestCommonSuffixProvider() { - return array( - array('bar', 'foobar', 'foo bar'), - array('foo bar', 'foo bar', 'foo bar'), - array('ar', 'foo bar', 'boo far'), - array('', 'foo bad', 'foo bar'), - array('', 'foo bar', ''), - array('bàř', 'fòôbàř', 'fòô bàř', 'UTF-8'), - array('fòô bàř', 'fòô bàř', 'fòô bàř', 'UTF-8'), - array(' bàř', 'fòô bàř', 'fòr bàř', 'UTF-8'), - array('', 'toy car', 'fòô bàř', 'UTF-8'), - array('', 'fòô bàř', '', 'UTF-8'), - ); + return [ + ['bar', 'foobar', 'foo bar'], + ['foo bar', 'foo bar', 'foo bar'], + ['ar', 'foo bar', 'boo far'], + ['', 'foo bad', 'foo bar'], + ['', 'foo bar', ''], + ['bàř', 'fòôbàř', 'fòô bàř', 'UTF-8'], + ['fòô bàř', 'fòô bàř', 'fòô bàř', 'UTF-8'], + [' bàř', 'fòô bàř', 'fòr bàř', 'UTF-8'], + ['', 'toy car', 'fòô bàř', 'UTF-8'], + ['', 'fòô bàř', '', 'UTF-8'], + ]; } /** @@ -1676,18 +1676,18 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function longestCommonSubstringProvider() { - return array( - array('foo', 'foobar', 'foo bar'), - array('foo bar', 'foo bar', 'foo bar'), - array('oo ', 'foo bar', 'boo far'), - array('foo ba', 'foo bad', 'foo bar'), - array('', 'foo bar', ''), - array('fòô', 'fòôbàř', 'fòô bàř', 'UTF-8'), - array('fòô bàř', 'fòô bàř', 'fòô bàř', 'UTF-8'), - array(' bàř', 'fòô bàř', 'fòr bàř', 'UTF-8'), - array(' ', 'toy car', 'fòô bàř', 'UTF-8'), - array('', 'fòô bàř', '', 'UTF-8'), - ); + return [ + ['foo', 'foobar', 'foo bar'], + ['foo bar', 'foo bar', 'foo bar'], + ['oo ', 'foo bar', 'boo far'], + ['foo ba', 'foo bad', 'foo bar'], + ['', 'foo bar', ''], + ['fòô', 'fòôbàř', 'fòô bàř', 'UTF-8'], + ['fòô bàř', 'fòô bàř', 'fòô bàř', 'UTF-8'], + [' bàř', 'fòô bàř', 'fòr bàř', 'UTF-8'], + [' ', 'toy car', 'fòô bàř', 'UTF-8'], + ['', 'fòô bàř', '', 'UTF-8'], + ]; } /** @@ -1704,12 +1704,12 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function lengthProvider() { - return array( - array(11, ' foo bar '), - array(1, 'f'), - array(0, ''), - array(7, 'fòô bàř', 'UTF-8') - ); + return [ + [11, ' foo bar '], + [1, 'f'], + [0, ''], + [7, 'fòô bàř', 'UTF-8'] + ]; } /** @@ -1727,24 +1727,24 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function sliceProvider() { - return array( - array('foobar', 'foobar', 0), - array('foobar', 'foobar', 0, null), - array('foobar', 'foobar', 0, 6), - array('fooba', 'foobar', 0, 5), - array('', 'foobar', 3, 0), - array('', 'foobar', 3, 2), - array('ba', 'foobar', 3, 5), - array('ba', 'foobar', 3, -1), - array('fòôbàř', 'fòôbàř', 0, null, 'UTF-8'), - array('fòôbàř', 'fòôbàř', 0, null), - array('fòôbàř', 'fòôbàř', 0, 6, 'UTF-8'), - array('fòôbà', 'fòôbàř', 0, 5, 'UTF-8'), - array('', 'fòôbàř', 3, 0, 'UTF-8'), - array('', 'fòôbàř', 3, 2, 'UTF-8'), - array('bà', 'fòôbàř', 3, 5, 'UTF-8'), - array('bà', 'fòôbàř', 3, -1, 'UTF-8') - ); + return [ + ['foobar', 'foobar', 0], + ['foobar', 'foobar', 0, null], + ['foobar', 'foobar', 0, 6], + ['fooba', 'foobar', 0, 5], + ['', 'foobar', 3, 0], + ['', 'foobar', 3, 2], + ['ba', 'foobar', 3, 5], + ['ba', 'foobar', 3, -1], + ['fòôbàř', 'fòôbàř', 0, null, 'UTF-8'], + ['fòôbàř', 'fòôbàř', 0, null], + ['fòôbàř', 'fòôbàř', 0, 6, 'UTF-8'], + ['fòôbà', 'fòôbàř', 0, 5, 'UTF-8'], + ['', 'fòôbàř', 3, 0, 'UTF-8'], + ['', 'fòôbàř', 3, 2, 'UTF-8'], + ['bà', 'fòôbàř', 3, 5, 'UTF-8'], + ['bà', 'fòôbàř', 3, -1, 'UTF-8'] + ]; } /** @@ -1768,27 +1768,27 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function splitProvider() { - return array( - array(array('foo,bar,baz'), 'foo,bar,baz', ''), - array(array('foo,bar,baz'), 'foo,bar,baz', '-'), - array(array('foo', 'bar', 'baz'), 'foo,bar,baz', ','), - array(array('foo', 'bar', 'baz'), 'foo,bar,baz', ',', null), - array(array('foo', 'bar', 'baz'), 'foo,bar,baz', ',', -1), - array(array(), 'foo,bar,baz', ',', 0), - array(array('foo'), 'foo,bar,baz', ',', 1), - array(array('foo', 'bar'), 'foo,bar,baz', ',', 2), - array(array('foo', 'bar', 'baz'), 'foo,bar,baz', ',', 3), - array(array('foo', 'bar', 'baz'), 'foo,bar,baz', ',', 10), - array(array('fòô,bàř,baz'), 'fòô,bàř,baz', '-', null, 'UTF-8'), - array(array('fòô', 'bàř', 'baz'), 'fòô,bàř,baz', ',', null, 'UTF-8'), - array(array('fòô', 'bàř', 'baz'), 'fòô,bàř,baz', ',', null, 'UTF-8'), - array(array('fòô', 'bàř', 'baz'), 'fòô,bàř,baz', ',', -1, 'UTF-8'), - array(array(), 'fòô,bàř,baz', ',', 0, 'UTF-8'), - array(array('fòô'), 'fòô,bàř,baz', ',', 1, 'UTF-8'), - array(array('fòô', 'bàř'), 'fòô,bàř,baz', ',', 2, 'UTF-8'), - array(array('fòô', 'bàř', 'baz'), 'fòô,bàř,baz', ',', 3, 'UTF-8'), - array(array('fòô', 'bàř', 'baz'), 'fòô,bàř,baz', ',', 10, 'UTF-8') - ); + return [ + [['foo,bar,baz'], 'foo,bar,baz', ''], + [['foo,bar,baz'], 'foo,bar,baz', '-'], + [['foo', 'bar', 'baz'], 'foo,bar,baz', ','], + [['foo', 'bar', 'baz'], 'foo,bar,baz', ',', null], + [['foo', 'bar', 'baz'], 'foo,bar,baz', ',', -1], + [[], 'foo,bar,baz', ',', 0], + [['foo'], 'foo,bar,baz', ',', 1], + [['foo', 'bar'], 'foo,bar,baz', ',', 2], + [['foo', 'bar', 'baz'], 'foo,bar,baz', ',', 3], + [['foo', 'bar', 'baz'], 'foo,bar,baz', ',', 10], + [['fòô,bàř,baz'], 'fòô,bàř,baz', '-', null, 'UTF-8'], + [['fòô', 'bàř', 'baz'], 'fòô,bàř,baz', ',', null, 'UTF-8'], + [['fòô', 'bàř', 'baz'], 'fòô,bàř,baz', ',', null, 'UTF-8'], + [['fòô', 'bàř', 'baz'], 'fòô,bàř,baz', ',', -1, 'UTF-8'], + [[], 'fòô,bàř,baz', ',', 0, 'UTF-8'], + [['fòô'], 'fòô,bàř,baz', ',', 1, 'UTF-8'], + [['fòô', 'bàř'], 'fòô,bàř,baz', ',', 2, 'UTF-8'], + [['fòô', 'bàř', 'baz'], 'fòô,bàř,baz', ',', 3, 'UTF-8'], + [['fòô', 'bàř', 'baz'], 'fòô,bàř,baz', ',', 10, 'UTF-8'] + ]; } /** @@ -1805,20 +1805,20 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function stripWhitespaceProvider() { - return array( - array('foobar', ' foo bar '), - array('teststring', 'test string'), - array('Οσυγγραφέας', ' Ο συγγραφέας '), - array('123', ' 123 '), - array('', ' ', 'UTF-8'), // no-break space (U+00A0) - array('', '           ', 'UTF-8'), // spaces U+2000 to U+200A - array('', ' ', 'UTF-8'), // narrow no-break space (U+202F) - array('', ' ', 'UTF-8'), // medium mathematical space (U+205F) - array('', ' ', 'UTF-8'), // ideographic space (U+3000) - array('123', '  1  2  3  ', 'UTF-8'), - array('', ' '), - array('', ''), - ); + return [ + ['foobar', ' foo bar '], + ['teststring', 'test string'], + ['Οσυγγραφέας', ' Ο συγγραφέας '], + ['123', ' 123 '], + ['', ' ', 'UTF-8'], // no-break space (U+00A0) + ['', '           ', 'UTF-8'], // spaces U+2000 to U+200A + ['', ' ', 'UTF-8'], // narrow no-break space (U+202F) + ['', ' ', 'UTF-8'], // medium mathematical space (U+205F) + ['', ' ', 'UTF-8'], // ideographic space (U+3000) + ['123', '  1  2  3  ', 'UTF-8'], + ['', ' '], + ['', ''], + ]; } /** @@ -1836,17 +1836,17 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function substrProvider() { - return array( - array('foo bar', 'foo bar', 0), - array('bar', 'foo bar', 4), - array('bar', 'foo bar', 4, null), - array('o b', 'foo bar', 2, 3), - array('', 'foo bar', 4, 0), - array('fòô bàř', 'fòô bàř', 0, null, 'UTF-8'), - array('bàř', 'fòô bàř', 4, null, 'UTF-8'), - array('ô b', 'fòô bàř', 2, 3, 'UTF-8'), - array('', 'fòô bàř', 4, 0, 'UTF-8') - ); + return [ + ['foo bar', 'foo bar', 0], + ['bar', 'foo bar', 4], + ['bar', 'foo bar', 4, null], + ['o b', 'foo bar', 2, 3], + ['', 'foo bar', 4, 0], + ['fòô bàř', 'fòô bàř', 0, null, 'UTF-8'], + ['bàř', 'fòô bàř', 4, null, 'UTF-8'], + ['ô b', 'fòô bàř', 2, 3, 'UTF-8'], + ['', 'fòô bàř', 4, 0, 'UTF-8'] + ]; } /** @@ -1863,16 +1863,16 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function atProvider() { - return array( - array('f', 'foo bar', 0), - array('o', 'foo bar', 1), - array('r', 'foo bar', 6), - array('', 'foo bar', 7), - array('f', 'fòô bàř', 0, 'UTF-8'), - array('ò', 'fòô bàř', 1, 'UTF-8'), - array('ř', 'fòô bàř', 6, 'UTF-8'), - array('', 'fòô bàř', 7, 'UTF-8'), - ); + return [ + ['f', 'foo bar', 0], + ['o', 'foo bar', 1], + ['r', 'foo bar', 6], + ['', 'foo bar', 7], + ['f', 'fòô bàř', 0, 'UTF-8'], + ['ò', 'fòô bàř', 1, 'UTF-8'], + ['ř', 'fòô bàř', 6, 'UTF-8'], + ['', 'fòô bàř', 7, 'UTF-8'], + ]; } /** @@ -1889,20 +1889,20 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function firstProvider() { - return array( - array('', 'foo bar', -5), - array('', 'foo bar', 0), - array('f', 'foo bar', 1), - array('foo', 'foo bar', 3), - array('foo bar', 'foo bar', 7), - array('foo bar', 'foo bar', 8), - array('', 'fòô bàř', -5, 'UTF-8'), - array('', 'fòô bàř', 0, 'UTF-8'), - array('f', 'fòô bàř', 1, 'UTF-8'), - array('fòô', 'fòô bàř', 3, 'UTF-8'), - array('fòô bàř', 'fòô bàř', 7, 'UTF-8'), - array('fòô bàř', 'fòô bàř', 8, 'UTF-8'), - ); + return [ + ['', 'foo bar', -5], + ['', 'foo bar', 0], + ['f', 'foo bar', 1], + ['foo', 'foo bar', 3], + ['foo bar', 'foo bar', 7], + ['foo bar', 'foo bar', 8], + ['', 'fòô bàř', -5, 'UTF-8'], + ['', 'fòô bàř', 0, 'UTF-8'], + ['f', 'fòô bàř', 1, 'UTF-8'], + ['fòô', 'fòô bàř', 3, 'UTF-8'], + ['fòô bàř', 'fòô bàř', 7, 'UTF-8'], + ['fòô bàř', 'fòô bàř', 8, 'UTF-8'], + ]; } /** @@ -1919,20 +1919,20 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function lastProvider() { - return array( - array('', 'foo bar', -5), - array('', 'foo bar', 0), - array('r', 'foo bar', 1), - array('bar', 'foo bar', 3), - array('foo bar', 'foo bar', 7), - array('foo bar', 'foo bar', 8), - array('', 'fòô bàř', -5, 'UTF-8'), - array('', 'fòô bàř', 0, 'UTF-8'), - array('ř', 'fòô bàř', 1, 'UTF-8'), - array('bàř', 'fòô bàř', 3, 'UTF-8'), - array('fòô bàř', 'fòô bàř', 7, 'UTF-8'), - array('fòô bàř', 'fòô bàř', 8, 'UTF-8'), - ); + return [ + ['', 'foo bar', -5], + ['', 'foo bar', 0], + ['r', 'foo bar', 1], + ['bar', 'foo bar', 3], + ['foo bar', 'foo bar', 7], + ['foo bar', 'foo bar', 8], + ['', 'fòô bàř', -5, 'UTF-8'], + ['', 'fòô bàř', 0, 'UTF-8'], + ['ř', 'fòô bàř', 1, 'UTF-8'], + ['bàř', 'fòô bàř', 3, 'UTF-8'], + ['fòô bàř', 'fòô bàř', 7, 'UTF-8'], + ['fòô bàř', 'fòô bàř', 8, 'UTF-8'], + ]; } /** @@ -1949,18 +1949,18 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function ensureLeftProvider() { - return array( - array('foobar', 'foobar', 'f'), - array('foobar', 'foobar', 'foo'), - array('foo/foobar', 'foobar', 'foo/'), - array('http://foobar', 'foobar', 'http://'), - array('http://foobar', 'http://foobar', 'http://'), - array('fòôbàř', 'fòôbàř', 'f', 'UTF-8'), - array('fòôbàř', 'fòôbàř', 'fòô', 'UTF-8'), - array('fòô/fòôbàř', 'fòôbàř', 'fòô/', 'UTF-8'), - array('http://fòôbàř', 'fòôbàř', 'http://', 'UTF-8'), - array('http://fòôbàř', 'http://fòôbàř', 'http://', 'UTF-8'), - ); + return [ + ['foobar', 'foobar', 'f'], + ['foobar', 'foobar', 'foo'], + ['foo/foobar', 'foobar', 'foo/'], + ['http://foobar', 'foobar', 'http://'], + ['http://foobar', 'http://foobar', 'http://'], + ['fòôbàř', 'fòôbàř', 'f', 'UTF-8'], + ['fòôbàř', 'fòôbàř', 'fòô', 'UTF-8'], + ['fòô/fòôbàř', 'fòôbàř', 'fòô/', 'UTF-8'], + ['http://fòôbàř', 'fòôbàř', 'http://', 'UTF-8'], + ['http://fòôbàř', 'http://fòôbàř', 'http://', 'UTF-8'], + ]; } /** @@ -1977,18 +1977,18 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function ensureRightProvider() { - return array( - array('foobar', 'foobar', 'r'), - array('foobar', 'foobar', 'bar'), - array('foobar/bar', 'foobar', '/bar'), - array('foobar.com/', 'foobar', '.com/'), - array('foobar.com/', 'foobar.com/', '.com/'), - array('fòôbàř', 'fòôbàř', 'ř', 'UTF-8'), - array('fòôbàř', 'fòôbàř', 'bàř', 'UTF-8'), - array('fòôbàř/bàř', 'fòôbàř', '/bàř', 'UTF-8'), - array('fòôbàř.com/', 'fòôbàř', '.com/', 'UTF-8'), - array('fòôbàř.com/', 'fòôbàř.com/', '.com/', 'UTF-8'), - ); + return [ + ['foobar', 'foobar', 'r'], + ['foobar', 'foobar', 'bar'], + ['foobar/bar', 'foobar', '/bar'], + ['foobar.com/', 'foobar', '.com/'], + ['foobar.com/', 'foobar.com/', '.com/'], + ['fòôbàř', 'fòôbàř', 'ř', 'UTF-8'], + ['fòôbàř', 'fòôbàř', 'bàř', 'UTF-8'], + ['fòôbàř/bàř', 'fòôbàř', '/bàř', 'UTF-8'], + ['fòôbàř.com/', 'fòôbàř', '.com/', 'UTF-8'], + ['fòôbàř.com/', 'fòôbàř.com/', '.com/', 'UTF-8'], + ]; } /** @@ -2005,20 +2005,20 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function removeLeftProvider() { - return array( - array('foo bar', 'foo bar', ''), - array('oo bar', 'foo bar', 'f'), - array('bar', 'foo bar', 'foo '), - array('foo bar', 'foo bar', 'oo'), - array('foo bar', 'foo bar', 'oo bar'), - array('oo bar', 'foo bar', S::create('foo bar')->first(1), 'UTF-8'), - array('oo bar', 'foo bar', S::create('foo bar')->at(0), 'UTF-8'), - array('fòô bàř', 'fòô bàř', '', 'UTF-8'), - array('òô bàř', 'fòô bàř', 'f', 'UTF-8'), - array('bàř', 'fòô bàř', 'fòô ', 'UTF-8'), - array('fòô bàř', 'fòô bàř', 'òô', 'UTF-8'), - array('fòô bàř', 'fòô bàř', 'òô bàř', 'UTF-8') - ); + return [ + ['foo bar', 'foo bar', ''], + ['oo bar', 'foo bar', 'f'], + ['bar', 'foo bar', 'foo '], + ['foo bar', 'foo bar', 'oo'], + ['foo bar', 'foo bar', 'oo bar'], + ['oo bar', 'foo bar', S::create('foo bar')->first(1), 'UTF-8'], + ['oo bar', 'foo bar', S::create('foo bar')->at(0), 'UTF-8'], + ['fòô bàř', 'fòô bàř', '', 'UTF-8'], + ['òô bàř', 'fòô bàř', 'f', 'UTF-8'], + ['bàř', 'fòô bàř', 'fòô ', 'UTF-8'], + ['fòô bàř', 'fòô bàř', 'òô', 'UTF-8'], + ['fòô bàř', 'fòô bàř', 'òô bàř', 'UTF-8'] + ]; } /** @@ -2035,20 +2035,20 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function removeRightProvider() { - return array( - array('foo bar', 'foo bar', ''), - array('foo ba', 'foo bar', 'r'), - array('foo', 'foo bar', ' bar'), - array('foo bar', 'foo bar', 'ba'), - array('foo bar', 'foo bar', 'foo ba'), - array('foo ba', 'foo bar', S::create('foo bar')->last(1), 'UTF-8'), - array('foo ba', 'foo bar', S::create('foo bar')->at(6), 'UTF-8'), - array('fòô bàř', 'fòô bàř', '', 'UTF-8'), - array('fòô bà', 'fòô bàř', 'ř', 'UTF-8'), - array('fòô', 'fòô bàř', ' bàř', 'UTF-8'), - array('fòô bàř', 'fòô bàř', 'bà', 'UTF-8'), - array('fòô bàř', 'fòô bàř', 'fòô bà', 'UTF-8') - ); + return [ + ['foo bar', 'foo bar', ''], + ['foo ba', 'foo bar', 'r'], + ['foo', 'foo bar', ' bar'], + ['foo bar', 'foo bar', 'ba'], + ['foo bar', 'foo bar', 'foo ba'], + ['foo ba', 'foo bar', S::create('foo bar')->last(1), 'UTF-8'], + ['foo ba', 'foo bar', S::create('foo bar')->at(6), 'UTF-8'], + ['fòô bàř', 'fòô bàř', '', 'UTF-8'], + ['fòô bà', 'fòô bàř', 'ř', 'UTF-8'], + ['fòô', 'fòô bàř', ' bàř', 'UTF-8'], + ['fòô bàř', 'fòô bàř', 'bà', 'UTF-8'], + ['fòô bàř', 'fòô bàř', 'fòô bà', 'UTF-8'] + ]; } /** @@ -2065,18 +2065,18 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function isAlphaProvider() { - return array( - array(true, ''), - array(true, 'foobar'), - array(false, 'foo bar'), - array(false, 'foobar2'), - array(true, 'fòôbàř', 'UTF-8'), - array(false, 'fòô bàř', 'UTF-8'), - array(false, 'fòôbàř2', 'UTF-8'), - array(true, 'ҠѨњфгШ', 'UTF-8'), - array(false, 'ҠѨњ¨ˆфгШ', 'UTF-8'), - array(true, '丹尼爾', 'UTF-8') - ); + return [ + [true, ''], + [true, 'foobar'], + [false, 'foo bar'], + [false, 'foobar2'], + [true, 'fòôbàř', 'UTF-8'], + [false, 'fòô bàř', 'UTF-8'], + [false, 'fòôbàř2', 'UTF-8'], + [true, 'ҠѨњфгШ', 'UTF-8'], + [false, 'ҠѨњ¨ˆфгШ', 'UTF-8'], + [true, '丹尼爾', 'UTF-8'] + ]; } /** @@ -2093,21 +2093,21 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function isAlphanumericProvider() { - return array( - array(true, ''), - array(true, 'foobar1'), - array(false, 'foo bar'), - array(false, 'foobar2"'), - array(false, "\nfoobar\n"), - array(true, 'fòôbàř1', 'UTF-8'), - array(false, 'fòô bàř', 'UTF-8'), - array(false, 'fòôbàř2"', 'UTF-8'), - array(true, 'ҠѨњфгШ', 'UTF-8'), - array(false, 'ҠѨњ¨ˆфгШ', 'UTF-8'), - array(true, '丹尼爾111', 'UTF-8'), - array(true, 'دانيال1', 'UTF-8'), - array(false, 'دانيال1 ', 'UTF-8') - ); + return [ + [true, ''], + [true, 'foobar1'], + [false, 'foo bar'], + [false, 'foobar2"'], + [false, "\nfoobar\n"], + [true, 'fòôbàř1', 'UTF-8'], + [false, 'fòô bàř', 'UTF-8'], + [false, 'fòôbàř2"', 'UTF-8'], + [true, 'ҠѨњфгШ', 'UTF-8'], + [false, 'ҠѨњ¨ˆфгШ', 'UTF-8'], + [true, '丹尼爾111', 'UTF-8'], + [true, 'دانيال1', 'UTF-8'], + [false, 'دانيال1 ', 'UTF-8'] + ]; } /** @@ -2124,23 +2124,23 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function isBlankProvider() { - return array( - array(true, ''), - array(true, ' '), - array(true, "\n\t "), - array(true, "\n\t \v\f"), - array(false, "\n\t a \v\f"), - array(false, "\n\t ' \v\f"), - array(false, "\n\t 2 \v\f"), - array(true, '', 'UTF-8'), - array(true, ' ', 'UTF-8'), // no-break space (U+00A0) - array(true, '           ', 'UTF-8'), // spaces U+2000 to U+200A - array(true, ' ', 'UTF-8'), // narrow no-break space (U+202F) - array(true, ' ', 'UTF-8'), // medium mathematical space (U+205F) - array(true, ' ', 'UTF-8'), // ideographic space (U+3000) - array(false, ' z', 'UTF-8'), - array(false, ' 1', 'UTF-8'), - ); + return [ + [true, ''], + [true, ' '], + [true, "\n\t "], + [true, "\n\t \v\f"], + [false, "\n\t a \v\f"], + [false, "\n\t ' \v\f"], + [false, "\n\t 2 \v\f"], + [true, '', 'UTF-8'], + [true, ' ', 'UTF-8'], // no-break space (U+00A0) + [true, '           ', 'UTF-8'], // spaces U+2000 to U+200A + [true, ' ', 'UTF-8'], // narrow no-break space (U+202F) + [true, ' ', 'UTF-8'], // medium mathematical space (U+205F) + [true, ' ', 'UTF-8'], // ideographic space (U+3000) + [false, ' z', 'UTF-8'], + [false, ' 1', 'UTF-8'], + ]; } /** @@ -2157,28 +2157,28 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function isJsonProvider() { - return array( - array(false, ''), - array(false, ' '), - array(true, 'null'), - array(true, 'true'), - array(true, 'false'), - array(true, '[]'), - array(true, '{}'), - array(true, '123'), - array(true, '{"foo": "bar"}'), - array(false, '{"foo":"bar",}'), - array(false, '{"foo"}'), - array(true, '["foo"]'), - array(false, '{"foo": "bar"]'), - array(true, '123', 'UTF-8'), - array(true, '{"fòô": "bàř"}', 'UTF-8'), - array(false, '{"fòô":"bàř",}', 'UTF-8'), - array(false, '{"fòô"}', 'UTF-8'), - array(false, '["fòô": "bàř"]', 'UTF-8'), - array(true, '["fòô"]', 'UTF-8'), - array(false, '{"fòô": "bàř"]', 'UTF-8'), - ); + return [ + [false, ''], + [false, ' '], + [true, 'null'], + [true, 'true'], + [true, 'false'], + [true, '[]'], + [true, '{}'], + [true, '123'], + [true, '{"foo": "bar"}'], + [false, '{"foo":"bar",}'], + [false, '{"foo"}'], + [true, '["foo"]'], + [false, '{"foo": "bar"]'], + [true, '123', 'UTF-8'], + [true, '{"fòô": "bàř"}', 'UTF-8'], + [false, '{"fòô":"bàř",}', 'UTF-8'], + [false, '{"fòô"}', 'UTF-8'], + [false, '["fòô": "bàř"]', 'UTF-8'], + [true, '["fòô"]', 'UTF-8'], + [false, '{"fòô": "bàř"]', 'UTF-8'], + ]; } /** @@ -2195,16 +2195,16 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function isLowerCaseProvider() { - return array( - array(true, ''), - array(true, 'foobar'), - array(false, 'foo bar'), - array(false, 'Foobar'), - array(true, 'fòôbàř', 'UTF-8'), - array(false, 'fòôbàř2', 'UTF-8'), - array(false, 'fòô bàř', 'UTF-8'), - array(false, 'fòôbÀŘ', 'UTF-8'), - ); + return [ + [true, ''], + [true, 'foobar'], + [false, 'foo bar'], + [false, 'Foobar'], + [true, 'fòôbàř', 'UTF-8'], + [false, 'fòôbàř2', 'UTF-8'], + [false, 'fòô bàř', 'UTF-8'], + [false, 'fòôbÀŘ', 'UTF-8'], + ]; } /** @@ -2221,20 +2221,20 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function hasLowerCaseProvider() { - return array( - array(false, ''), - array(true, 'foobar'), - array(false, 'FOO BAR'), - array(true, 'fOO BAR'), - array(true, 'foO BAR'), - array(true, 'FOO BAr'), - array(true, 'Foobar'), - array(false, 'FÒÔBÀŘ', 'UTF-8'), - array(true, 'fòôbàř', 'UTF-8'), - array(true, 'fòôbàř2', 'UTF-8'), - array(true, 'Fòô bàř', 'UTF-8'), - array(true, 'fòôbÀŘ', 'UTF-8'), - ); + return [ + [false, ''], + [true, 'foobar'], + [false, 'FOO BAR'], + [true, 'fOO BAR'], + [true, 'foO BAR'], + [true, 'FOO BAr'], + [true, 'Foobar'], + [false, 'FÒÔBÀŘ', 'UTF-8'], + [true, 'fòôbàř', 'UTF-8'], + [true, 'fòôbàř2', 'UTF-8'], + [true, 'Fòô bàř', 'UTF-8'], + [true, 'fòôbÀŘ', 'UTF-8'], + ]; } /** @@ -2251,15 +2251,15 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function isSerializedProvider() { - return array( - array(false, ''), - array(true, 'a:1:{s:3:"foo";s:3:"bar";}'), - array(false, 'a:1:{s:3:"foo";s:3:"bar"}'), - array(true, serialize(array('foo' => 'bar'))), - array(true, 'a:1:{s:5:"fòô";s:5:"bàř";}', 'UTF-8'), - array(false, 'a:1:{s:5:"fòô";s:5:"bàř"}', 'UTF-8'), - array(true, serialize(array('fòô' => 'bár')), 'UTF-8'), - ); + return [ + [false, ''], + [true, 'a:1:{s:3:"foo";s:3:"bar";}'], + [false, 'a:1:{s:3:"foo";s:3:"bar"}'], + [true, serialize(['foo' => 'bar'])], + [true, 'a:1:{s:5:"fòô";s:5:"bàř";}', 'UTF-8'], + [false, 'a:1:{s:5:"fòô";s:5:"bàř"}', 'UTF-8'], + [true, serialize(['fòô' => 'bár']), 'UTF-8'], + ]; } /** @@ -2276,15 +2276,15 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function isBase64Provider() { - return array( - array(false, ' '), - array(true, ''), - array(true, base64_encode('FooBar') ), - array(true, base64_encode(' ') ), - array(true, base64_encode('FÒÔBÀŘ') ), - array(true, base64_encode('συγγραφέας') ), - array(false, 'Foobar'), - ); + return [ + [false, ' '], + [true, ''], + [true, base64_encode('FooBar') ], + [true, base64_encode(' ') ], + [true, base64_encode('FÒÔBÀŘ') ], + [true, base64_encode('συγγραφέας') ], + [false, 'Foobar'], + ]; } /** @@ -2301,16 +2301,16 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function isUpperCaseProvider() { - return array( - array(true, ''), - array(true, 'FOOBAR'), - array(false, 'FOO BAR'), - array(false, 'fOOBAR'), - array(true, 'FÒÔBÀŘ', 'UTF-8'), - array(false, 'FÒÔBÀŘ2', 'UTF-8'), - array(false, 'FÒÔ BÀŘ', 'UTF-8'), - array(false, 'FÒÔBàř', 'UTF-8'), - ); + return [ + [true, ''], + [true, 'FOOBAR'], + [false, 'FOO BAR'], + [false, 'fOOBAR'], + [true, 'FÒÔBÀŘ', 'UTF-8'], + [false, 'FÒÔBÀŘ2', 'UTF-8'], + [false, 'FÒÔ BÀŘ', 'UTF-8'], + [false, 'FÒÔBàř', 'UTF-8'], + ]; } /** @@ -2327,20 +2327,20 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function hasUpperCaseProvider() { - return array( - array(false, ''), - array(true, 'FOOBAR'), - array(false, 'foo bar'), - array(true, 'Foo bar'), - array(true, 'FOo bar'), - array(true, 'foo baR'), - array(true, 'fOOBAR'), - array(false, 'fòôbàř', 'UTF-8'), - array(true, 'FÒÔBÀŘ', 'UTF-8'), - array(true, 'FÒÔBÀŘ2', 'UTF-8'), - array(true, 'fÒÔ BÀŘ', 'UTF-8'), - array(true, 'FÒÔBàř', 'UTF-8'), - ); + return [ + [false, ''], + [true, 'FOOBAR'], + [false, 'foo bar'], + [true, 'Foo bar'], + [true, 'FOo bar'], + [true, 'foo baR'], + [true, 'fOOBAR'], + [false, 'fòôbàř', 'UTF-8'], + [true, 'FÒÔBÀŘ', 'UTF-8'], + [true, 'FÒÔBÀŘ2', 'UTF-8'], + [true, 'fÒÔ BÀŘ', 'UTF-8'], + [true, 'FÒÔBàř', 'UTF-8'], + ]; } /** @@ -2357,21 +2357,21 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function isHexadecimalProvider() { - return array( - array(true, ''), - array(true, 'abcdef'), - array(true, 'ABCDEF'), - array(true, '0123456789'), - array(true, '0123456789AbCdEf'), - array(false, '0123456789x'), - array(false, 'ABCDEFx'), - array(true, 'abcdef', 'UTF-8'), - array(true, 'ABCDEF', 'UTF-8'), - array(true, '0123456789', 'UTF-8'), - array(true, '0123456789AbCdEf', 'UTF-8'), - array(false, '0123456789x', 'UTF-8'), - array(false, 'ABCDEFx', 'UTF-8'), - ); + return [ + [true, ''], + [true, 'abcdef'], + [true, 'ABCDEF'], + [true, '0123456789'], + [true, '0123456789AbCdEf'], + [false, '0123456789x'], + [false, 'ABCDEFx'], + [true, 'abcdef', 'UTF-8'], + [true, 'ABCDEF', 'UTF-8'], + [true, '0123456789', 'UTF-8'], + [true, '0123456789AbCdEf', 'UTF-8'], + [false, '0123456789x', 'UTF-8'], + [false, 'ABCDEFx', 'UTF-8'], + ]; } /** @@ -2389,23 +2389,23 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function countSubstrProvider() { - return array( - array(0, '', 'foo'), - array(0, 'foo', 'bar'), - array(1, 'foo bar', 'foo'), - array(2, 'foo bar', 'o'), - array(0, '', 'fòô', 'UTF-8'), - array(0, 'fòô', 'bàř', 'UTF-8'), - array(1, 'fòô bàř', 'fòô', 'UTF-8'), - array(2, 'fôòô bàř', 'ô', 'UTF-8'), - array(0, 'fÔÒÔ bàř', 'ô', 'UTF-8'), - array(0, 'foo', 'BAR', false), - array(1, 'foo bar', 'FOo', false), - array(2, 'foo bar', 'O', false), - array(1, 'fòô bàř', 'fÒÔ', false, 'UTF-8'), - array(2, 'fôòô bàř', 'Ô', false, 'UTF-8'), - array(2, 'συγγραφέας', 'Σ', false, 'UTF-8') - ); + return [ + [0, '', 'foo'], + [0, 'foo', 'bar'], + [1, 'foo bar', 'foo'], + [2, 'foo bar', 'o'], + [0, '', 'fòô', 'UTF-8'], + [0, 'fòô', 'bàř', 'UTF-8'], + [1, 'fòô bàř', 'fòô', 'UTF-8'], + [2, 'fôòô bàř', 'ô', 'UTF-8'], + [0, 'fÔÒÔ bàř', 'ô', 'UTF-8'], + [0, 'foo', 'BAR', false], + [1, 'foo bar', 'FOo', false], + [2, 'foo bar', 'O', false], + [1, 'fòô bàř', 'fÒÔ', false, 'UTF-8'], + [2, 'fôòô bàř', 'Ô', false, 'UTF-8'], + [2, 'συγγραφέας', 'Σ', false, 'UTF-8'] + ]; } /** @@ -2423,24 +2423,24 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function replaceProvider() { - return array( - array('', '', '', ''), - array('foo', '', '', 'foo'), - array('foo', '\s', '\s', 'foo'), - array('foo bar', 'foo bar', '', ''), - array('foo bar', 'foo bar', 'f(o)o', '\1'), - array('\1 bar', 'foo bar', 'foo', '\1'), - array('bar', 'foo bar', 'foo ', ''), - array('far bar', 'foo bar', 'foo', 'far'), - array('bar bar', 'foo bar foo bar', 'foo ', ''), - array('', '', '', '', 'UTF-8'), - array('fòô', '', '', 'fòô', 'UTF-8'), - array('fòô', '\s', '\s', 'fòô', 'UTF-8'), - array('fòô bàř', 'fòô bàř', '', '', 'UTF-8'), - array('bàř', 'fòô bàř', 'fòô ', '', 'UTF-8'), - array('far bàř', 'fòô bàř', 'fòô', 'far', 'UTF-8'), - array('bàř bàř', 'fòô bàř fòô bàř', 'fòô ', '', 'UTF-8'), - ); + return [ + ['', '', '', ''], + ['foo', '', '', 'foo'], + ['foo', '\s', '\s', 'foo'], + ['foo bar', 'foo bar', '', ''], + ['foo bar', 'foo bar', 'f(o)o', '\1'], + ['\1 bar', 'foo bar', 'foo', '\1'], + ['bar', 'foo bar', 'foo ', ''], + ['far bar', 'foo bar', 'foo', 'far'], + ['bar bar', 'foo bar foo bar', 'foo ', ''], + ['', '', '', '', 'UTF-8'], + ['fòô', '', '', 'fòô', 'UTF-8'], + ['fòô', '\s', '\s', 'fòô', 'UTF-8'], + ['fòô bàř', 'fòô bàř', '', '', 'UTF-8'], + ['bàř', 'fòô bàř', 'fòô ', '', 'UTF-8'], + ['far bàř', 'fòô bàř', 'fòô', 'far', 'UTF-8'], + ['bàř bàř', 'fòô bàř fòô bàř', 'fòô ', '', 'UTF-8'], + ]; } /** @@ -2458,17 +2458,17 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function regexReplaceProvider() { - return array( - array('', '', '', ''), - array('bar', 'foo', 'f[o]+', 'bar'), - array('o bar', 'foo bar', 'f(o)o', '\1'), - array('bar', 'foo bar', 'f[O]+\s', '', 'i'), - array('foo', 'bar', '[[:alpha:]]{3}', 'foo'), - array('', '', '', '', 'msr', 'UTF-8'), - array('bàř', 'fòô ', 'f[òô]+\s', 'bàř', 'msr', 'UTF-8'), - array('fòô', 'fò', '(ò)', '\\1ô', 'msr', 'UTF-8'), - array('fòô', 'bàř', '[[:alpha:]]{3}', 'fòô', 'msr', 'UTF-8') - ); + return [ + ['', '', '', ''], + ['bar', 'foo', 'f[o]+', 'bar'], + ['o bar', 'foo bar', 'f(o)o', '\1'], + ['bar', 'foo bar', 'f[O]+\s', '', 'i'], + ['foo', 'bar', '[[:alpha:]]{3}', 'foo'], + ['', '', '', '', 'msr', 'UTF-8'], + ['bàř', 'fòô ', 'f[òô]+\s', 'bàř', 'msr', 'UTF-8'], + ['fòô', 'fò', '(ò)', '\\1ô', 'msr', 'UTF-8'], + ['fòô', 'bàř', '[[:alpha:]]{3}', 'fòô', 'msr', 'UTF-8'] + ]; } /** @@ -2485,13 +2485,13 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function htmlEncodeProvider() { - return array( - array('&', '&'), - array('"', '"'), - array(''', "'", ENT_QUOTES), - array('<', '<'), - array('>', '>'), - ); + return [ + ['&', '&'], + ['"', '"'], + [''', "'", ENT_QUOTES], + ['<', '<'], + ['>', '>'], + ]; } /** @@ -2508,12 +2508,12 @@ class StringyTestCase extends PHPUnit_Framework_TestCase public function htmlDecodeProvider() { - return array( - array('&', '&'), - array('"', '"'), - array("'", ''', ENT_QUOTES), - array('<', '<'), - array('>', '>'), - ); + return [ + ['&', '&'], + ['"', '"'], + ["'", ''', ENT_QUOTES], + ['<', '<'], + ['>', '>'], + ]; } } From 5303203a7237b97fd0d102e74d3089ff0a836efb Mon Sep 17 00:00:00 2001 From: Alexey Shockov Date: Mon, 13 Jun 2016 15:09:04 +0200 Subject: [PATCH 5/8] Return real strings from StaticStringy --- src/StaticStringy.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/StaticStringy.php b/src/StaticStringy.php index 83d552f..66f75aa 100644 --- a/src/StaticStringy.php +++ b/src/StaticStringy.php @@ -143,6 +143,12 @@ class StaticStringy $stringy = Stringy::create($str, $encoding); - return call_user_func_array([$stringy, $name], $args); + $result = call_user_func_array([$stringy, $name], $args); + + if (is_object($result) && $result instanceof Stringy) { + return (string) $result; + } + + return $result; } } From bf2a302aa1232836edca194727f190e74b47d437 Mon Sep 17 00:00:00 2001 From: "Daniel St. Jules" Date: Mon, 6 Mar 2017 15:11:14 -0500 Subject: [PATCH 6/8] Breaking change: Fix docs, force static methods to return strings rather than Stringy instances --- README.md | 50 ++++++++++++++++++------------------- src/StaticStringy.php | 23 +++++++++++------ src/Stringy.php | 15 +++++------ tests/StaticStringyTest.php | 21 +++++++++++++--- 4 files changed, 65 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 1a3bed7..00dfe6e 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ documentation. [endsWith](#endswithstring-substring--boolean-casesensitive--true-) - [endsWithAny](#endsWithAnystring-substrings--boolean-casesensitive--true-) + [endsWithAny](#endswithanystring-substrings--boolean-casesensitive--true-) [ensureLeft](#ensureleftstring-substring) [ensureRight](#ensurerightstring-substring) @@ -77,7 +77,7 @@ documentation. [isLowerCase](#islowercase) [isSerialized](#isserialized) [isUpperCase](#isuppercase) - [last](#last) + [last](#lastint-n) [length](#length) @@ -100,7 +100,7 @@ documentation. [removeLeft](#removeleftstring-substring) [removeRight](#removerightstring-substring) - [repeat](#repeatmultiplier) + [repeat](#repeatint-multiplier) [replace](#replacestring-search-string-replacement) @@ -110,10 +110,10 @@ documentation. [slugify](#slugify-string-replacement----) - [startsWith](#startswithstring-substring--boolean-casesensitive--true-) - [startsWithAny](#startswithanystring-substrings--boolean-casesensitive--true-) [slice](#sliceint-start--int-end-) [split](#splitstring-pattern--int-limit-) + [startsWith](#startswithstring-substring--boolean-casesensitive--true-) + [startsWithAny](#startswithanystring-substrings--boolean-casesensitive--true-) [stripWhitespace](#stripwhitespace) @@ -821,26 +821,6 @@ is also converted to lowercase. s('Using strings like fòô bàř')->slugify(); // 'using-strings-like-foo-bar' ``` -##### startsWith(string $substring [, boolean $caseSensitive = true ]) - -Returns true if the string begins with $substring, false otherwise. -By default, the comparison is case-sensitive, but can be made insensitive -by setting $caseSensitive to false. - -```php -s('FÒÔbàřbaz')->startsWith('fòôbàř', false); // true -``` - -##### startsWithAny(string[] $substrings [, boolean $caseSensitive = true ]) - -Returns true if the string begins with any of $substrings, false -otherwise. By default the comparison is case-sensitive, but can be made -insensitive by setting $caseSensitive to false. - -```php -s('FÒÔbàřbaz')->startsWith(['fòô', 'bàř'], false); // true -``` - ##### slice(int $start [, int $end ]) Returns the substring beginning at $start, and up to, but not including @@ -862,6 +842,26 @@ results. s('foo,bar,baz')->split(',', 2); // ['foo', 'bar'] ``` +##### startsWith(string $substring [, boolean $caseSensitive = true ]) + +Returns true if the string begins with $substring, false otherwise. +By default, the comparison is case-sensitive, but can be made insensitive +by setting $caseSensitive to false. + +```php +s('FÒÔbàřbaz')->startsWith('fòôbàř', false); // true +``` + +##### startsWithAny(string[] $substrings [, boolean $caseSensitive = true ]) + +Returns true if the string begins with any of $substrings, false +otherwise. By default the comparison is case-sensitive, but can be made +insensitive by setting $caseSensitive to false. + +```php +s('FÒÔbàřbaz')->startsWith(['fòô', 'bàř'], false); // true +``` + ##### stripWhitespace() Strip all whitespace characters. This includes tabs and newline diff --git a/src/StaticStringy.php b/src/StaticStringy.php index 66f75aa..648546b 100644 --- a/src/StaticStringy.php +++ b/src/StaticStringy.php @@ -16,13 +16,14 @@ use ReflectionMethod; * @method static string chars(string $str, string $encoding = null) * @method static string collapseWhitespace(string $str, string $encoding = null) * @method static bool contains(string $str, string $needle, bool $caseSensitive = true, string $encoding = null) - * @method static bool containsAll(string $str, string $needle, bool $caseSensitive = true, string $encoding = null) - * @method static bool containsAny(string $str, string $needle, bool $caseSensitive = true, string $encoding = null) + * @method static bool containsAll(string $str, string[] $needle, bool $caseSensitive = true, string $encoding = null) + * @method static bool containsAny(string $str, string[] $needle, bool $caseSensitive = true, string $encoding = null) * @method static int count(string $str, string $encoding = null) * @method static int countSubstr(string $str, string $substring, bool $caseSensitive = true, string $encoding = null) * @method static string dasherize(string $str, string $encoding = null) * @method static string delimit(string $str, string $delimiter, string $encoding = null) * @method static bool endsWith(string $str, string $substring, bool $caseSensitive = true, string $encoding = null) + * @method static bool endsWithAny(string $str, string[] $substrings, bool $caseSensitive = true, string $encoding = null) * @method static string ensureLeft(string $str, string $substring, string $encoding = null) * @method static string ensureRight(string $str, string $substring, string $encoding = null) * @method static string first(string $str, int $n, string $encoding = null) @@ -45,7 +46,7 @@ use ReflectionMethod; * @method static bool isUpperCase(string $str, string $encoding = null) * @method static string last(string $str, string $encoding = null) * @method static int length(string $str, string $encoding = null) - * @method static Stringy[] lines(string $str, string $encoding = null) + * @method static string[] lines(string $str, string $encoding = null) * @method static string longestCommonPrefix(string $str, string $otherStr, string $encoding = null) * @method static string longestCommonSuffix(string $str, string $otherStr, string $encoding = null) * @method static string longestCommonSubstring(string $str, string $otherStr, string $encoding = null) @@ -64,9 +65,11 @@ use ReflectionMethod; * @method static string safeTruncate(string $str, int $length, string $substring = '', string $encoding = null) * @method static string shuffle(string $str, string $encoding = null) * @method static string slugify(string $str, string $replacement = '-', string $encoding = null) - * @method static bool startsWith(string $str, string $substring, bool $caseSensitive = true, string $encoding = null) * @method static string slice(string $str, int $start, int $end = null, string $encoding = null) * @method static string split(string $str, string $pattern, int $limit = null, string $encoding = null) + * @method static bool startsWith(string $str, string $substring, bool $caseSensitive = true, string $encoding = null) + * @method static bool startsWithAny(string $str, string[] $substrings, bool $caseSensitive = true, string $encoding = null) + * @method static string stripWhitespace(string $str, string $encoding = null) * @method static string substr(string $str, int $start, int $length = null, string $encoding = null) * @method static string surround(string $str, string $substring, string $encoding = null) * @method static string swapCase(string $str, string $encoding = null) @@ -145,10 +148,14 @@ class StaticStringy $result = call_user_func_array([$stringy, $name], $args); - if (is_object($result) && $result instanceof Stringy) { - return (string) $result; - } + $cast = function($val) { + if (is_object($val) && $val instanceof Stringy) { + return (string) $val; + } else { + return $val; + } + }; - return $result; + return is_array($result) ? array_map($cast, $result) : $cast($result); } } diff --git a/src/Stringy.php b/src/Stringy.php index db34756..7a303cd 100644 --- a/src/Stringy.php +++ b/src/Stringy.php @@ -219,9 +219,9 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess * default the comparison is case-sensitive, but can be made insensitive by * setting $caseSensitive to false. * - * @param array $needles Substrings to look for - * @param bool $caseSensitive Whether or not to enforce case-sensitivity - * @return bool Whether or not $str contains $needle + * @param string[] $needles Substrings to look for + * @param bool $caseSensitive Whether or not to enforce case-sensitivity + * @return bool Whether or not $str contains $needle */ public function containsAll($needles, $caseSensitive = true) { @@ -243,9 +243,9 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess * default the comparison is case-sensitive, but can be made insensitive by * setting $caseSensitive to false. * - * @param array $needles Substrings to look for - * @param bool $caseSensitive Whether or not to enforce case-sensitivity - * @return bool Whether or not $str contains $needle + * @param string[] $needles Substrings to look for + * @param bool $caseSensitive Whether or not to enforce case-sensitivity + * @return bool Whether or not $str contains $needle */ public function containsAny($needles, $caseSensitive = true) { @@ -1180,7 +1180,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess * by setting $caseSensitive to false. * * @param string $substring The substring to look for - * @param bool $caseSensitive Whether or not to enforce case-sensitivity + * @param bool $caseSensitive Whether or not to enforce + * case-sensitivity * @return bool Whether or not $str starts with $substring */ public function startsWith($substring, $caseSensitive = true) diff --git a/tests/StaticStringyTest.php b/tests/StaticStringyTest.php index 653708b..67c3946 100644 --- a/tests/StaticStringyTest.php +++ b/tests/StaticStringyTest.php @@ -15,25 +15,38 @@ class StaticStringyTestCase extends PHPUnit_Framework_TestCase public function testEmptyArgsInvocation() { $result = S::toLowerCase(); - $this->assertEquals('', (string) $result); + $this->assertEquals('', $result); } public function testInvocation() { $result = S::toLowerCase('FOOBAR'); - $this->assertEquals('foobar', (string) $result); + $this->assertEquals('foobar', $result); + $this->assertInternalType('string', $result); } public function testPartialArgsInvocation() { $result = S::slice('foobar', 0, 3); - $this->assertEquals('foo', (string) $result); + $this->assertEquals('foo', $result); + $this->assertInternalType('string', $result); } public function testFullArgsInvocation() { $result = S::slice('fòôbàř', 0, 3, 'UTF-8'); - $this->assertEquals('fòô', (string) $result); + $this->assertEquals('fòô', $result); + $this->assertInternalType('string', $result); + } + + public function testArrayReturnValue() + { + $result = S::lines("a\nb"); + $this->assertEquals(['a', 'b'], $result); + $this->assertInternalType('array', $result); + foreach ($result as $val) { + $this->assertInternalType('string', $val); + } } /** From 72102ae911f1229e326d2024139b6c6006ed8098 Mon Sep 17 00:00:00 2001 From: "Daniel St. Jules" Date: Wed, 8 Mar 2017 19:14:42 -0500 Subject: [PATCH 7/8] toAscii changes: rename locale to language, correct some transliterations --- README.md | 7 ++-- src/StaticStringy.php | 2 +- src/Stringy.php | 91 ++++++++++++++++++++++--------------------- tests/StringyTest.php | 4 +- 4 files changed, 53 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 00dfe6e..1072d4d 100644 --- a/README.md +++ b/README.md @@ -923,9 +923,10 @@ s('i like to watch television')->titleize($ignore); Returns an ASCII version of the string. A set of non-ASCII characters are replaced with their closest ASCII counterparts, and the rest are removed -unless instructed otherwise. The locale of the source string can be supplied -for locale-specific transliteration. The locale can be supplied in any of the -following formats: en, en_GB, or en-GB. +by default. The language or locale of the source string can be supplied +for language-specific transliteration in any of the following formats: +en, en_GB, or en-GB. For example, passing "de" results in "äöü" mapping +to "aeoeue" rather than "aou" as in other languages. ```php s('fòôbàř')->toAscii(); // 'foobar' diff --git a/src/StaticStringy.php b/src/StaticStringy.php index 648546b..11f9a06 100644 --- a/src/StaticStringy.php +++ b/src/StaticStringy.php @@ -75,7 +75,7 @@ use ReflectionMethod; * @method static string swapCase(string $str, string $encoding = null) * @method static string tidy(string $str, string $encoding = null) * @method static string titleize(string $str, string $encoding = null) - * @method static string toAscii(string $str, string $locale = 'en', bool $removeUnsupported = true, string $encoding = null) + * @method static string toAscii(string $str, string $language = 'en', bool $removeUnsupported = true, string $encoding = null) * @method static bool toBoolean(string $str, string $encoding = null) * @method static string toLowerCase(string $str, string $encoding = null) * @method static string toSpaces(string $str, int $tabLength = 4, string $encoding = null) diff --git a/src/Stringy.php b/src/Stringy.php index 7a303cd..c5e06fd 100644 --- a/src/Stringy.php +++ b/src/Stringy.php @@ -1425,20 +1425,23 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess /** * Returns an ASCII version of the string. A set of non-ASCII characters are * replaced with their closest ASCII counterparts, and the rest are removed - * unless instructed otherwise. The locale can be supplied in any of the - * following formats: en, en_GB, or en-GB. + * by default. The language or locale of the source string can be supplied + * for language-specific transliteration in any of the following formats: + * en, en_GB, or en-GB. For example, passing "de" results in "äöü" mapping + * to "aeoeue" rather than "aou" as in other languages. * - * @param string $locale Locale of the source string + * @param string $language Language of the source string * @param bool $removeUnsupported Whether or not to remove the * unsupported characters * @return static Object whose $str contains only ASCII characters */ - public function toAscii($locale = 'en', $removeUnsupported = true) + public function toAscii($language = 'en', $removeUnsupported = true) { $str = $this->str; - foreach ($this->localeSpecificCharsArray($locale) as $key => $value) { - $str = str_replace($value, $key, $str); + $langSpecific = $this->langSpecificCharsArray($language); + if (!empty($langSpecific)) { + $str = str_replace($langSpecific[0], $langSpecific[1], $str); } foreach ($this->charsArray() as $key => $value) { @@ -1814,26 +1817,26 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess 'Ы', 'Й', 'Υ', 'Ϋ', 'Ŷ', 'Y'], 'Z' => ['Ź', 'Ž', 'Ż', 'З', 'Ζ', 'Z'], 'AE' => ['Æ', 'Ǽ'], - 'CH' => ['Ч'], - 'DJ' => ['Ђ'], - 'DZ' => ['Џ'], - 'GX' => ['Ĝ'], - 'HX' => ['Ĥ'], - 'IJ' => ['IJ'], - 'JX' => ['Ĵ'], - 'KH' => ['Х'], - 'LJ' => ['Љ'], - 'NJ' => ['Њ'], - 'OE' => ['Œ'], - 'PS' => ['Ψ'], - 'SH' => ['Ш'], - 'SHCH' => ['Щ'], - 'SS' => ['ẞ'], - 'TH' => ['Þ'], - 'TS' => ['Ц'], - 'YA' => ['Я'], - 'YU' => ['Ю'], - 'ZH' => ['Ж'], + 'Ch' => ['Ч'], + 'Dj' => ['Ђ'], + 'Dz' => ['Џ'], + 'Gx' => ['Ĝ'], + 'Hx' => ['Ĥ'], + 'Ij' => ['IJ'], + 'Jx' => ['Ĵ'], + 'Kh' => ['Х'], + 'Lj' => ['Љ'], + 'Nj' => ['Њ'], + 'Oe' => ['Œ'], + 'Ps' => ['Ψ'], + 'Sh' => ['Ш'], + 'Shch' => ['Щ'], + 'Ss' => ['ẞ'], + 'Th' => ['Þ'], + 'Ts' => ['Ц'], + 'Ya' => ['Я'], + 'Yu' => ['Ю'], + 'Zh' => ['Ж'], ' ' => ["\xC2\xA0", "\xE2\x80\x80", "\xE2\x80\x81", "\xE2\x80\x82", "\xE2\x80\x83", "\xE2\x80\x84", "\xE2\x80\x85", "\xE2\x80\x86", "\xE2\x80\x87", @@ -1844,39 +1847,37 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess } /** - * Returns the locale-specific replacements for the toAscii() method. + * Returns language-specific replacements for the toAscii() method. + * For example, German will map 'ä' to 'ae', while other languages + * will simply return 'a'. * - * @param string $locale Locale of the source string - * @return array An array of replacements. + * param string $language Language of the source string + * @return array An array of replacements. */ - protected function localeSpecificCharsArray($locale = 'en') + protected static function langSpecificCharsArray($language = 'en') { - $split = preg_split('/[-_]/', $locale); - $locale = strtolower($split[0]); + $split = preg_split('/[-_]/', $language); + $language = strtolower($split[0]); static $charsArray = []; - if (isset($charsArray[$locale])) { - return $charsArray[$locale]; + if (isset($charsArray[$language])) { + return $charsArray[$language]; } - $localeSpecific = [ + $languageSpecific = [ 'de' => [ - 'ae' => ['ä'], - 'oe' => ['ö'], - 'ue' => ['ü'], - 'AE' => ['Ä'], - 'OE' => ['Ö'], - 'UE' => ['Ü'] + ['ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü' ], + ['ae', 'oe', 'ue', 'AE', 'OE', 'UE'], ] ]; - if (isset($localeSpecific[$locale])) { - $charsArray[$locale] = $localeSpecific[$locale]; + if (isset($languageSpecific[$language])) { + $charsArray[$language] = $languageSpecific[$language]; } else { - $charsArray[$locale] = []; + $charsArray[$language] = []; } - return $charsArray[$locale]; + return $charsArray[$language]; } /** diff --git a/tests/StringyTest.php b/tests/StringyTest.php index 051afa8..570e6ab 100644 --- a/tests/StringyTest.php +++ b/tests/StringyTest.php @@ -653,11 +653,11 @@ class StringyTestCase extends PHPUnit_Framework_TestCase /** * @dataProvider toAsciiProvider() */ - public function testToAscii($expected, $str, $locale = 'en', + public function testToAscii($expected, $str, $language = 'en', $removeUnsupported = true) { $stringy = S::create($str); - $result = $stringy->toAscii($locale, $removeUnsupported); + $result = $stringy->toAscii($language, $removeUnsupported); $this->assertStringy($result); $this->assertEquals($expected, $result); $this->assertEquals($str, $stringy); From a2624d49698a2777b392c863baa27ff04f686be8 Mon Sep 17 00:00:00 2001 From: "Daniel St. Jules" Date: Wed, 8 Mar 2017 19:23:05 -0500 Subject: [PATCH 8/8] Docs fixes --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1072d4d..e4b15fa 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ documentation. [tidy](#tidy) [titleize](#titleize-array-ignore) - [toAscii](#toascii) + [toAscii](#toascii-string-locale--en--bool-removeunsupported--true-) [toBoolean](#toboolean) @@ -436,7 +436,7 @@ default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false. ```php -s('fòôbàř')->endsWith('bàř', true); // true +s('fòôbàř')->endsWith('bàř'); // true ``` ##### endsWithAny(string[] $substrings [, boolean $caseSensitive = true ]) @@ -446,7 +446,7 @@ By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false. ```php -s('fòôbàř')->endsWith(['bàř', 'baz'], true); // true +s('fòôbàř')->endsWithAny(['bàř', 'baz']); // true ``` ##### ensureLeft(string $substring) @@ -859,7 +859,7 @@ otherwise. By default the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false. ```php -s('FÒÔbàřbaz')->startsWith(['fòô', 'bàř'], false); // true +s('FÒÔbàřbaz')->startsWithAny(['fòô', 'bàř'], false); // true ``` ##### stripWhitespace()