Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 53b0f63

Browse filesBrowse files
[String] leverage Stringable from PHP 8
1 parent 5428fef commit 53b0f63
Copy full SHA for 53b0f63

4 files changed

+11-6Lines changed: 11 additions & 6 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎composer.json‎

Copy file name to clipboardExpand all lines: composer.json
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"symfony/polyfill-intl-normalizer": "~1.0",
3535
"symfony/polyfill-mbstring": "~1.0",
3636
"symfony/polyfill-php73": "^1.11",
37+
"symfony/polyfill-php80": "^1.15",
3738
"symfony/polyfill-uuid": "^1.15"
3839
},
3940
"replace": {
Collapse file

‎src/Symfony/Component/String/AbstractString.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/String/AbstractString.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* @throws ExceptionInterface
2929
*/
30-
abstract class AbstractString implements \JsonSerializable
30+
abstract class AbstractString implements \Stringable, \JsonSerializable
3131
{
3232
public const PREG_PATTERN_ORDER = PREG_PATTERN_ORDER;
3333
public const PREG_SET_ORDER = PREG_SET_ORDER;
Collapse file

‎src/Symfony/Component/String/LazyString.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/String/LazyString.php
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @author Nicolas Grekas <p@tchwork.com>
1818
*/
19-
class LazyString implements \JsonSerializable
19+
class LazyString implements \Stringable, \JsonSerializable
2020
{
2121
private $value;
2222

@@ -50,14 +50,14 @@ public static function fromCallable($callback, ...$arguments): self
5050
}
5151

5252
/**
53-
* @param object|string|int|float|bool $value A scalar or an object that implements the __toString() magic method
53+
* @param string|int|float|bool|\Stringable $value
5454
*
5555
* @return static
5656
*/
5757
public static function fromStringable($value): self
5858
{
5959
if (!self::isStringable($value)) {
60-
throw new \TypeError(sprintf('Argument 1 passed to %s() must be a scalar or an object that implements the __toString() magic method, %s given.', __METHOD__, \is_object($value) ? \get_class($value) : \gettype($value)));
60+
throw new \TypeError(sprintf('Argument 1 passed to %s() must be a scalar or a stringable object, %s given.', __METHOD__, \is_object($value) ? \get_class($value) : \gettype($value)));
6161
}
6262

6363
if (\is_object($value)) {
@@ -75,7 +75,7 @@ public static function fromStringable($value): self
7575
*/
7676
final public static function isStringable($value): bool
7777
{
78-
return \is_string($value) || $value instanceof self || (\is_object($value) ? \is_callable([$value, '__toString']) : is_scalar($value));
78+
return \is_string($value) || $value instanceof self || (\is_object($value) ? method_exists($value, '__toString') : is_scalar($value));
7979
}
8080

8181
/**
@@ -90,6 +90,9 @@ final public static function resolve($value): string
9090
return $value;
9191
}
9292

93+
/**
94+
* @return string
95+
*/
9396
public function __toString()
9497
{
9598
if (\is_string($this->value)) {
Collapse file

‎src/Symfony/Component/String/composer.json‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/String/composer.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"php": "^7.2.5",
2020
"symfony/polyfill-intl-grapheme": "~1.0",
2121
"symfony/polyfill-intl-normalizer": "~1.0",
22-
"symfony/polyfill-mbstring": "~1.0"
22+
"symfony/polyfill-mbstring": "~1.0",
23+
"symfony/polyfill-php80": "~1.15"
2324
},
2425
"require-dev": {
2526
"symfony/error-handler": "^4.4|^5.0",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.