diff --git a/src/Symfony/Component/String/AbstractString.php b/src/Symfony/Component/String/AbstractString.php index dea44bf5d5b60..5a55b5cd048d6 100644 --- a/src/Symfony/Component/String/AbstractString.php +++ b/src/Symfony/Component/String/AbstractString.php @@ -543,9 +543,9 @@ public function startsWith($prefix): bool */ abstract public function title(bool $allWords = false): self; - public function toBinary(string $toEncoding = null): BinaryString + public function toByteString(string $toEncoding = null): ByteString { - $b = new BinaryString(); + $b = new ByteString(); $toEncoding = \in_array($toEncoding, ['utf8', 'utf-8', 'UTF8'], true) ? 'UTF-8' : $toEncoding; @@ -574,14 +574,14 @@ public function toBinary(string $toEncoding = null): BinaryString return $b; } - public function toGrapheme(): GraphemeString + public function toCodePointString(): CodePointString { - return new GraphemeString($this->string); + return new CodePointString($this->string); } - public function toUtf8(): Utf8String + public function toUnicodeString(): UnicodeString { - return new Utf8String($this->string); + return new UnicodeString($this->string); } /** diff --git a/src/Symfony/Component/String/BinaryString.php b/src/Symfony/Component/String/ByteString.php similarity index 97% rename from src/Symfony/Component/String/BinaryString.php rename to src/Symfony/Component/String/ByteString.php index 7ec8b56aec387..ff89c51c655c8 100644 --- a/src/Symfony/Component/String/BinaryString.php +++ b/src/Symfony/Component/String/ByteString.php @@ -25,7 +25,7 @@ * * @experimental in 5.0 */ -class BinaryString extends AbstractString +class ByteString extends AbstractString { public function __construct(string $string = '') { @@ -371,14 +371,14 @@ public function title(bool $allWords = false): parent return $str; } - public function toGrapheme(string $fromEncoding = null): GraphemeString + public function toUnicodeString(string $fromEncoding = null): UnicodeString { - return new GraphemeString($this->toUtf8($fromEncoding)->string); + return new UnicodeString($this->toCodePointString($fromEncoding)->string); } - public function toUtf8(string $fromEncoding = null): Utf8String + public function toCodePointString(string $fromEncoding = null): CodePointString { - $u = new Utf8String(); + $u = new CodePointString(); if (\in_array($fromEncoding, [null, 'utf8', 'utf-8', 'UTF8', 'UTF-8'], true) && preg_match('//u', $this->string)) { $u->string = $this->string; diff --git a/src/Symfony/Component/String/Utf8String.php b/src/Symfony/Component/String/CodePointString.php similarity index 99% rename from src/Symfony/Component/String/Utf8String.php rename to src/Symfony/Component/String/CodePointString.php index bcd5e7250bc84..e0ef21e014bdb 100644 --- a/src/Symfony/Component/String/Utf8String.php +++ b/src/Symfony/Component/String/CodePointString.php @@ -24,7 +24,7 @@ * * @experimental in 5.0 */ -class Utf8String extends AbstractUnicodeString +class CodePointString extends AbstractUnicodeString { public function __construct(string $string = '') { diff --git a/src/Symfony/Component/String/Resources/functions.php b/src/Symfony/Component/String/Resources/functions.php index cd941192b8e06..739b216e4fd04 100644 --- a/src/Symfony/Component/String/Resources/functions.php +++ b/src/Symfony/Component/String/Resources/functions.php @@ -14,15 +14,15 @@ /** * @experimental in 5.0 */ -function u(string $string = ''): GraphemeString +function u(string $string = ''): UnicodeString { - return new GraphemeString($string); + return new UnicodeString($string); } /** * @experimental in 5.0 */ -function b(string $string = ''): BinaryString +function b(string $string = ''): ByteString { - return new BinaryString($string); + return new ByteString($string); } diff --git a/src/Symfony/Component/String/Slugger/AsciiSlugger.php b/src/Symfony/Component/String/Slugger/AsciiSlugger.php index e359f823a2031..c0d56455d0d8a 100644 --- a/src/Symfony/Component/String/Slugger/AsciiSlugger.php +++ b/src/Symfony/Component/String/Slugger/AsciiSlugger.php @@ -12,7 +12,7 @@ namespace Symfony\Component\String\Slugger; use Symfony\Component\String\AbstractUnicodeString; -use Symfony\Component\String\GraphemeString; +use Symfony\Component\String\UnicodeString; use Symfony\Contracts\Translation\LocaleAwareInterface; /** @@ -91,13 +91,13 @@ public function slug(string $string, string $separator = '-', string $locale = n $transliterator = []; if ('de' === $locale || 0 === strpos($locale, 'de_')) { - // Use the shortcut for German in GraphemeString::ascii() if possible (faster and no requirement on intl) + // Use the shortcut for German in UnicodeString::ascii() if possible (faster and no requirement on intl) $transliterator = ['de-ASCII']; } elseif (\function_exists('transliterator_transliterate') && $locale) { $transliterator = (array) $this->createTransliterator($locale); } - return (new GraphemeString($string)) + return (new UnicodeString($string)) ->ascii($transliterator) ->replace('@', $separator.'at'.$separator) ->replaceMatches('/[^A-Za-z0-9]++/', $separator) diff --git a/src/Symfony/Component/String/Tests/AbstractAsciiTestCase.php b/src/Symfony/Component/String/Tests/AbstractAsciiTestCase.php index 4d2498a09be5e..48e8813ca9784 100644 --- a/src/Symfony/Component/String/Tests/AbstractAsciiTestCase.php +++ b/src/Symfony/Component/String/Tests/AbstractAsciiTestCase.php @@ -4,10 +4,10 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\String\AbstractString; -use Symfony\Component\String\BinaryString; +use Symfony\Component\String\ByteString; +use Symfony\Component\String\CodePointString; use Symfony\Component\String\Exception\InvalidArgumentException; -use Symfony\Component\String\GraphemeString; -use Symfony\Component\String\Utf8String; +use Symfony\Component\String\UnicodeString; abstract class AbstractAsciiTestCase extends TestCase { @@ -875,9 +875,9 @@ public static function provideStartsWith() [false, "\nfoo", 'f'], [true, 'foo', 'f'], [true, 'foo', 'fo'], - [true, 'foo', new BinaryString('f')], - [true, 'foo', new Utf8String('f')], - [true, 'foo', new GraphemeString('f')], + [true, 'foo', new ByteString('f')], + [true, 'foo', new CodePointString('f')], + [true, 'foo', new UnicodeString('f')], [true, 'foo', ['e', 'f', 'g']], ]; } @@ -900,9 +900,9 @@ public static function provideStartsWithIgnoreCase() [false, "\nfoo", 'f'], [true, 'foo', 'F'], [true, 'FoO', 'foo'], - [true, 'foo', new BinaryString('F')], - [true, 'foo', new Utf8String('F')], - [true, 'foo', new GraphemeString('F')], + [true, 'foo', new ByteString('F')], + [true, 'foo', new CodePointString('F')], + [true, 'foo', new UnicodeString('F')], [true, 'foo', ['E', 'F', 'G']], ]; } @@ -926,9 +926,9 @@ public static function provideEndsWith() [false, "foo\n", 'o'], [true, 'foo', 'o'], [true, 'foo', 'foo'], - [true, 'foo', new BinaryString('o')], - [true, 'foo', new Utf8String('o')], - [true, 'foo', new GraphemeString('o')], + [true, 'foo', new ByteString('o')], + [true, 'foo', new CodePointString('o')], + [true, 'foo', new UnicodeString('o')], [true, 'foo', ['a', 'o', 'u']], ]; } @@ -951,9 +951,9 @@ public static function provideEndsWithIgnoreCase() [false, "foo\n", 'o'], [true, 'foo', 'O'], [true, 'Foo', 'foo'], - [true, 'foo', new BinaryString('O')], - [true, 'foo', new Utf8String('O')], - [true, 'foo', new GraphemeString('O')], + [true, 'foo', new ByteString('O')], + [true, 'foo', new CodePointString('O')], + [true, 'foo', new UnicodeString('O')], [true, 'foo', ['A', 'O', 'U']], ]; } @@ -1098,9 +1098,9 @@ public static function provideEqualsTo() [false, 'foo', 'Foo'], [false, "foo\n", 'foo'], [true, 'Foo bar', 'Foo bar'], - [true, 'Foo bar', new BinaryString('Foo bar')], - [true, 'Foo bar', new Utf8String('Foo bar')], - [true, 'Foo bar', new GraphemeString('Foo bar')], + [true, 'Foo bar', new ByteString('Foo bar')], + [true, 'Foo bar', new CodePointString('Foo bar')], + [true, 'Foo bar', new UnicodeString('Foo bar')], [false, '', []], [false, 'foo', ['bar', 'baz']], [true, 'foo', ['bar', 'foo', 'baz']], @@ -1123,9 +1123,9 @@ public static function provideEqualsToIgnoreCase() [false, 'foo', ''], [false, "foo\n", 'foo'], [true, 'foo Bar', 'FOO bar'], - [true, 'foo Bar', new BinaryString('FOO bar')], - [true, 'foo Bar', new Utf8String('FOO bar')], - [true, 'foo Bar', new GraphemeString('FOO bar')], + [true, 'foo Bar', new ByteString('FOO bar')], + [true, 'foo Bar', new CodePointString('FOO bar')], + [true, 'foo Bar', new UnicodeString('FOO bar')], [false, '', []], [false, 'Foo', ['bar', 'baz']], [true, 'Foo', ['bar', 'foo', 'baz']], diff --git a/src/Symfony/Component/String/Tests/AbstractUtf8TestCase.php b/src/Symfony/Component/String/Tests/AbstractUnicodeTestCase.php similarity index 99% rename from src/Symfony/Component/String/Tests/AbstractUtf8TestCase.php rename to src/Symfony/Component/String/Tests/AbstractUnicodeTestCase.php index 5eed9fc224ef5..45bda349d6d85 100644 --- a/src/Symfony/Component/String/Tests/AbstractUtf8TestCase.php +++ b/src/Symfony/Component/String/Tests/AbstractUnicodeTestCase.php @@ -4,7 +4,7 @@ use Symfony\Component\String\Exception\InvalidArgumentException; -abstract class AbstractUtf8TestCase extends AbstractAsciiTestCase +abstract class AbstractUnicodeTestCase extends AbstractAsciiTestCase { public function testCreateFromStringWithInvalidUtf8Input() { diff --git a/src/Symfony/Component/String/Tests/BinaryStringTest.php b/src/Symfony/Component/String/Tests/ByteStringTest.php similarity index 81% rename from src/Symfony/Component/String/Tests/BinaryStringTest.php rename to src/Symfony/Component/String/Tests/ByteStringTest.php index 9b92632484db1..25665f6a84f9f 100644 --- a/src/Symfony/Component/String/Tests/BinaryStringTest.php +++ b/src/Symfony/Component/String/Tests/ByteStringTest.php @@ -12,13 +12,13 @@ namespace Symfony\Component\String\Tests; use Symfony\Component\String\AbstractString; -use Symfony\Component\String\BinaryString; +use Symfony\Component\String\ByteString; -class BinaryStringTest extends AbstractAsciiTestCase +class ByteStringTest extends AbstractAsciiTestCase { protected static function createFromString(string $string): AbstractString { - return new BinaryString($string); + return new ByteString($string); } public static function provideLength(): array diff --git a/src/Symfony/Component/String/Tests/Utf8StringTest.php b/src/Symfony/Component/String/Tests/CodePointStringTest.php similarity index 82% rename from src/Symfony/Component/String/Tests/Utf8StringTest.php rename to src/Symfony/Component/String/Tests/CodePointStringTest.php index b5381b44cfab5..9c61785195d44 100644 --- a/src/Symfony/Component/String/Tests/Utf8StringTest.php +++ b/src/Symfony/Component/String/Tests/CodePointStringTest.php @@ -12,13 +12,13 @@ namespace Symfony\Component\String\Tests; use Symfony\Component\String\AbstractString; -use Symfony\Component\String\Utf8String; +use Symfony\Component\String\CodePointString; -class Utf8StringTest extends AbstractUtf8TestCase +class CodePointStringTest extends AbstractUnicodeTestCase { protected static function createFromString(string $string): AbstractString { - return new Utf8String($string); + return new CodePointString($string); } public static function provideLength(): array diff --git a/src/Symfony/Component/String/Tests/GraphemeStringTest.php b/src/Symfony/Component/String/Tests/UnicodeStringTest.php similarity index 97% rename from src/Symfony/Component/String/Tests/GraphemeStringTest.php rename to src/Symfony/Component/String/Tests/UnicodeStringTest.php index 7148d8b53f74b..7d9c877b44a8c 100644 --- a/src/Symfony/Component/String/Tests/GraphemeStringTest.php +++ b/src/Symfony/Component/String/Tests/UnicodeStringTest.php @@ -12,13 +12,13 @@ namespace Symfony\Component\String\Tests; use Symfony\Component\String\AbstractString; -use Symfony\Component\String\GraphemeString; +use Symfony\Component\String\UnicodeString; -class GraphemeStringTest extends AbstractUtf8TestCase +class UnicodeStringTest extends AbstractUnicodeTestCase { protected static function createFromString(string $string): AbstractString { - return new GraphemeString($string); + return new UnicodeString($string); } public static function provideLength(): array diff --git a/src/Symfony/Component/String/GraphemeString.php b/src/Symfony/Component/String/UnicodeString.php similarity index 99% rename from src/Symfony/Component/String/GraphemeString.php rename to src/Symfony/Component/String/UnicodeString.php index b1ecafacbf9b7..83d1e132125dd 100644 --- a/src/Symfony/Component/String/GraphemeString.php +++ b/src/Symfony/Component/String/UnicodeString.php @@ -17,7 +17,7 @@ /** * Represents a string of Unicode grapheme clusters encoded as UTF-8. * - * A letter followed by combining characters (accents typically) forms what Unicode defines + * A letter followed by combining characters (accents typically) form what Unicode defines * as a grapheme cluster: a character as humans mean it in written texts. This class knows * about the concept and won't split a letter apart from its combining accents. It also * ensures all string comparisons happen on their canonically-composed representation, @@ -32,7 +32,7 @@ * * @experimental in 5.0 */ -class GraphemeString extends AbstractUnicodeString +class UnicodeString extends AbstractUnicodeString { public function __construct(string $string = '') { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy