Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 054e599

Browse files
[String] renamed core classes to Byte/CodePoint/UnicodeString
1 parent 1e4d873 commit 054e599

11 files changed

+51
-51
lines changed

src/Symfony/Component/String/AbstractString.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,9 @@ public function startsWith($prefix): bool
543543
*/
544544
abstract public function title(bool $allWords = false): self;
545545

546-
public function toBinary(string $toEncoding = null): BinaryString
546+
public function toBinary(string $toEncoding = null): ByteString
547547
{
548-
$b = new BinaryString();
548+
$b = new ByteString();
549549

550550
$toEncoding = \in_array($toEncoding, ['utf8', 'utf-8', 'UTF8'], true) ? 'UTF-8' : $toEncoding;
551551

@@ -574,14 +574,14 @@ public function toBinary(string $toEncoding = null): BinaryString
574574
return $b;
575575
}
576576

577-
public function toGrapheme(): GraphemeString
577+
public function toGrapheme(): UnicodeString
578578
{
579-
return new GraphemeString($this->string);
579+
return new UnicodeString($this->string);
580580
}
581581

582-
public function toUtf8(): Utf8String
582+
public function toUtf8(): CodePointString
583583
{
584-
return new Utf8String($this->string);
584+
return new CodePointString($this->string);
585585
}
586586

587587
/**

src/Symfony/Component/String/BinaryString.php renamed to src/Symfony/Component/String/ByteString.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
* @experimental in 5.0
2727
*/
28-
class BinaryString extends AbstractString
28+
class ByteString extends AbstractString
2929
{
3030
public function __construct(string $string = '')
3131
{
@@ -371,14 +371,14 @@ public function title(bool $allWords = false): parent
371371
return $str;
372372
}
373373

374-
public function toGrapheme(string $fromEncoding = null): GraphemeString
374+
public function toGrapheme(string $fromEncoding = null): UnicodeString
375375
{
376-
return new GraphemeString($this->toUtf8($fromEncoding)->string);
376+
return new UnicodeString($this->toUtf8($fromEncoding)->string);
377377
}
378378

379-
public function toUtf8(string $fromEncoding = null): Utf8String
379+
public function toUtf8(string $fromEncoding = null): CodePointString
380380
{
381-
$u = new Utf8String();
381+
$u = new CodePointString();
382382

383383
if (\in_array($fromEncoding, [null, 'utf8', 'utf-8', 'UTF8', 'UTF-8'], true) && preg_match('//u', $this->string)) {
384384
$u->string = $this->string;

src/Symfony/Component/String/Utf8String.php renamed to src/Symfony/Component/String/CodePointString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* @experimental in 5.0
2626
*/
27-
class Utf8String extends AbstractUnicodeString
27+
class CodePointString extends AbstractUnicodeString
2828
{
2929
public function __construct(string $string = '')
3030
{

src/Symfony/Component/String/Resources/functions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
/**
1515
* @experimental in 5.0
1616
*/
17-
function u(string $string = ''): GraphemeString
17+
function u(string $string = ''): UnicodeString
1818
{
19-
return new GraphemeString($string);
19+
return new UnicodeString($string);
2020
}
2121

2222
/**
2323
* @experimental in 5.0
2424
*/
25-
function b(string $string = ''): BinaryString
25+
function b(string $string = ''): ByteString
2626
{
27-
return new BinaryString($string);
27+
return new ByteString($string);
2828
}

src/Symfony/Component/String/Slugger/AsciiSlugger.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\String\Slugger;
1313

1414
use Symfony\Component\String\AbstractUnicodeString;
15-
use Symfony\Component\String\GraphemeString;
15+
use Symfony\Component\String\UnicodeString;
1616
use Symfony\Contracts\Translation\LocaleAwareInterface;
1717

1818
/**
@@ -91,13 +91,13 @@ public function slug(string $string, string $separator = '-', string $locale = n
9191

9292
$transliterator = [];
9393
if ('de' === $locale || 0 === strpos($locale, 'de_')) {
94-
// Use the shortcut for German in GraphemeString::ascii() if possible (faster and no requirement on intl)
94+
// Use the shortcut for German in UnicodeString::ascii() if possible (faster and no requirement on intl)
9595
$transliterator = ['de-ASCII'];
9696
} elseif (\function_exists('transliterator_transliterate') && $locale) {
9797
$transliterator = (array) $this->createTransliterator($locale);
9898
}
9999

100-
return (new GraphemeString($string))
100+
return (new UnicodeString($string))
101101
->ascii($transliterator)
102102
->replace('@', $separator.'at'.$separator)
103103
->replaceMatches('/[^A-Za-z0-9]++/', $separator)

src/Symfony/Component/String/Tests/AbstractAsciiTestCase.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
use PHPUnit\Framework\TestCase;
66
use Symfony\Component\String\AbstractString;
7-
use Symfony\Component\String\BinaryString;
7+
use Symfony\Component\String\ByteString;
8+
use Symfony\Component\String\CodePointString;
89
use Symfony\Component\String\Exception\InvalidArgumentException;
9-
use Symfony\Component\String\GraphemeString;
10-
use Symfony\Component\String\Utf8String;
10+
use Symfony\Component\String\UnicodeString;
1111

1212
abstract class AbstractAsciiTestCase extends TestCase
1313
{
@@ -875,9 +875,9 @@ public static function provideStartsWith()
875875
[false, "\nfoo", 'f'],
876876
[true, 'foo', 'f'],
877877
[true, 'foo', 'fo'],
878-
[true, 'foo', new BinaryString('f')],
879-
[true, 'foo', new Utf8String('f')],
880-
[true, 'foo', new GraphemeString('f')],
878+
[true, 'foo', new ByteString('f')],
879+
[true, 'foo', new CodePointString('f')],
880+
[true, 'foo', new UnicodeString('f')],
881881
[true, 'foo', ['e', 'f', 'g']],
882882
];
883883
}
@@ -900,9 +900,9 @@ public static function provideStartsWithIgnoreCase()
900900
[false, "\nfoo", 'f'],
901901
[true, 'foo', 'F'],
902902
[true, 'FoO', 'foo'],
903-
[true, 'foo', new BinaryString('F')],
904-
[true, 'foo', new Utf8String('F')],
905-
[true, 'foo', new GraphemeString('F')],
903+
[true, 'foo', new ByteString('F')],
904+
[true, 'foo', new CodePointString('F')],
905+
[true, 'foo', new UnicodeString('F')],
906906
[true, 'foo', ['E', 'F', 'G']],
907907
];
908908
}
@@ -926,9 +926,9 @@ public static function provideEndsWith()
926926
[false, "foo\n", 'o'],
927927
[true, 'foo', 'o'],
928928
[true, 'foo', 'foo'],
929-
[true, 'foo', new BinaryString('o')],
930-
[true, 'foo', new Utf8String('o')],
931-
[true, 'foo', new GraphemeString('o')],
929+
[true, 'foo', new ByteString('o')],
930+
[true, 'foo', new CodePointString('o')],
931+
[true, 'foo', new UnicodeString('o')],
932932
[true, 'foo', ['a', 'o', 'u']],
933933
];
934934
}
@@ -951,9 +951,9 @@ public static function provideEndsWithIgnoreCase()
951951
[false, "foo\n", 'o'],
952952
[true, 'foo', 'O'],
953953
[true, 'Foo', 'foo'],
954-
[true, 'foo', new BinaryString('O')],
955-
[true, 'foo', new Utf8String('O')],
956-
[true, 'foo', new GraphemeString('O')],
954+
[true, 'foo', new ByteString('O')],
955+
[true, 'foo', new CodePointString('O')],
956+
[true, 'foo', new UnicodeString('O')],
957957
[true, 'foo', ['A', 'O', 'U']],
958958
];
959959
}
@@ -1098,9 +1098,9 @@ public static function provideEqualsTo()
10981098
[false, 'foo', 'Foo'],
10991099
[false, "foo\n", 'foo'],
11001100
[true, 'Foo bar', 'Foo bar'],
1101-
[true, 'Foo bar', new BinaryString('Foo bar')],
1102-
[true, 'Foo bar', new Utf8String('Foo bar')],
1103-
[true, 'Foo bar', new GraphemeString('Foo bar')],
1101+
[true, 'Foo bar', new ByteString('Foo bar')],
1102+
[true, 'Foo bar', new CodePointString('Foo bar')],
1103+
[true, 'Foo bar', new UnicodeString('Foo bar')],
11041104
[false, '', []],
11051105
[false, 'foo', ['bar', 'baz']],
11061106
[true, 'foo', ['bar', 'foo', 'baz']],
@@ -1123,9 +1123,9 @@ public static function provideEqualsToIgnoreCase()
11231123
[false, 'foo', ''],
11241124
[false, "foo\n", 'foo'],
11251125
[true, 'foo Bar', 'FOO bar'],
1126-
[true, 'foo Bar', new BinaryString('FOO bar')],
1127-
[true, 'foo Bar', new Utf8String('FOO bar')],
1128-
[true, 'foo Bar', new GraphemeString('FOO bar')],
1126+
[true, 'foo Bar', new ByteString('FOO bar')],
1127+
[true, 'foo Bar', new CodePointString('FOO bar')],
1128+
[true, 'foo Bar', new UnicodeString('FOO bar')],
11291129
[false, '', []],
11301130
[false, 'Foo', ['bar', 'baz']],
11311131
[true, 'Foo', ['bar', 'foo', 'baz']],

src/Symfony/Component/String/Tests/AbstractUtf8TestCase.php renamed to src/Symfony/Component/String/Tests/AbstractUnicodeTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Symfony\Component\String\Exception\InvalidArgumentException;
66

7-
abstract class AbstractUtf8TestCase extends AbstractAsciiTestCase
7+
abstract class AbstractUnicodeTestCase extends AbstractAsciiTestCase
88
{
99
public function testCreateFromStringWithInvalidUtf8Input()
1010
{

src/Symfony/Component/String/Tests/BinaryStringTest.php renamed to src/Symfony/Component/String/Tests/ByteStringTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
namespace Symfony\Component\String\Tests;
1313

1414
use Symfony\Component\String\AbstractString;
15-
use Symfony\Component\String\BinaryString;
15+
use Symfony\Component\String\ByteString;
1616

17-
class BinaryStringTest extends AbstractAsciiTestCase
17+
class ByteStringTest extends AbstractAsciiTestCase
1818
{
1919
protected static function createFromString(string $string): AbstractString
2020
{
21-
return new BinaryString($string);
21+
return new ByteString($string);
2222
}
2323

2424
public static function provideLength(): array

src/Symfony/Component/String/Tests/Utf8StringTest.php renamed to src/Symfony/Component/String/Tests/CodePointStringTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
namespace Symfony\Component\String\Tests;
1313

1414
use Symfony\Component\String\AbstractString;
15-
use Symfony\Component\String\Utf8String;
15+
use Symfony\Component\String\CodePointString;
1616

17-
class Utf8StringTest extends AbstractUtf8TestCase
17+
class CodePointStringTest extends AbstractUnicodeTestCase
1818
{
1919
protected static function createFromString(string $string): AbstractString
2020
{
21-
return new Utf8String($string);
21+
return new CodePointString($string);
2222
}
2323

2424
public static function provideLength(): array

src/Symfony/Component/String/Tests/GraphemeStringTest.php renamed to src/Symfony/Component/String/Tests/UnicodeStringTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
namespace Symfony\Component\String\Tests;
1313

1414
use Symfony\Component\String\AbstractString;
15-
use Symfony\Component\String\GraphemeString;
15+
use Symfony\Component\String\UnicodeString;
1616

17-
class GraphemeStringTest extends AbstractUtf8TestCase
17+
class UnicodeStringTest extends AbstractUnicodeTestCase
1818
{
1919
protected static function createFromString(string $string): AbstractString
2020
{
21-
return new GraphemeString($string);
21+
return new UnicodeString($string);
2222
}
2323

2424
public static function provideLength(): array

src/Symfony/Component/String/GraphemeString.php renamed to src/Symfony/Component/String/UnicodeString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*
3333
* @experimental in 5.0
3434
*/
35-
class GraphemeString extends AbstractUnicodeString
35+
class UnicodeString extends AbstractUnicodeString
3636
{
3737
public function __construct(string $string = '')
3838
{

0 commit comments

Comments
 (0)