Add toString() method for String

This commit is contained in:
Simon Podlipsky 2019-10-17 13:49:05 +02:00 committed by Nicolas Grekas
parent 27a2d8a3d7
commit 5540bc7607
2 changed files with 12 additions and 0 deletions

View File

@ -589,6 +589,11 @@ abstract class AbstractString implements \JsonSerializable
return new CodePointString($this->string);
}
public function toString(): string
{
return $this->string;
}
public function toUnicodeString(): UnicodeString
{
return new UnicodeString($this->string);

View File

@ -1370,4 +1370,11 @@ abstract class AbstractAsciiTestCase extends TestCase
['fo...', 'foobar', 5, '...'],
];
}
public function testToString()
{
$instance = static::createFromString('foobar');
self::assertSame('foobar', $instance->toString());
}
}