Created
August 28, 2025 10:11
-
-
Save ollyollyollyltd/c77f19c94cee90a9ae814805855aa06c to your computer and use it in GitHub Desktop.
Patch for `voku/stringy` PHP 8.4 compatibility issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From b9f33d8fe48e7f46c9c7c5d815a82e49f415e907 Mon Sep 17 00:00:00 2001 | |
| From: Tom Arbesser-Rastburg <github@arbesser.org> | |
| Date: Sat, 7 Dec 2024 22:55:49 +1100 | |
| Subject: [PATCH] Fix PHP 8.4 deprecation warnings | |
| --- | |
| composer.json | 2 +- | |
| src/Create.php | 2 +- | |
| src/StaticStringy.php | 170 +++++++++++++++++++++--------------------- | |
| src/Stringy.php | 38 +++++----- | |
| 4 files changed, 106 insertions(+), 106 deletions(-) | |
| diff --git a/composer.json b/composer.json | |
| index 85475cc..e82abff 100644 | |
| --- a/composer.json | |
| +++ b/composer.json | |
| @@ -33,7 +33,7 @@ | |
| "source": "https://github.com/voku/Stringy" | |
| }, | |
| "require": { | |
| - "php": ">=7.0.0", | |
| + "php": ">=8.1.0", | |
| "ext-json": "*", | |
| "defuse/php-encryption": "~2.0", | |
| "voku/arrayy": "~7.8", | |
| diff --git a/src/Create.php b/src/Create.php | |
| index 7399cc4..ebd9d88 100644 | |
| --- a/src/Create.php | |
| +++ b/src/Create.php | |
| @@ -14,7 +14,7 @@ if (!\function_exists('Stringy\create')) { | |
| * | |
| * @return Stringy A Stringy object | |
| */ | |
| - function create($str, string $encoding = null) | |
| + function create($str, ?string $encoding = null) | |
| { | |
| return new Stringy($str, $encoding); | |
| } | |
| diff --git a/src/StaticStringy.php b/src/StaticStringy.php | |
| index 424413d..969d8cd 100644 | |
| --- a/src/StaticStringy.php | |
| +++ b/src/StaticStringy.php | |
| @@ -8,102 +8,102 @@ namespace Stringy; | |
| * INFO: "Method Parameter Information" via PhpStorm | | |
| * https://www.jetbrains.com/phpstorm/help/viewing-method-parameter-information.html | |
| * | |
| - * @method static Stringy append(string $stringInput, string $stringAppend, string $encoding = null) | |
| + * @method static Stringy append(string $stringInput, string $stringAppend, ?string $encoding = null) | |
| * @method static Stringy appendPassword(string $stringInput, int $length) | |
| * @method static Stringy appendUniqueIdentifier(string $stringInput, string $extraPrefix = '') | |
| * @method static Stringy appendRandomString(string $stringInput, int $length, string $possibleChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') | |
| - * @method static Stringy at(string $stringInput, int $index, string $encoding = null) | |
| - * @method static Stringy between(string $stringInput, string $start, string $end, int $offset = 0, string $encoding = null) | |
| - * @method static Stringy camelize(string $stringInput, string $encoding = null) | |
| - * @method static string[] chars(string $stringInput, string $encoding = null) | |
| - * @method static Stringy collapseWhitespace(string $stringInput, string $encoding = null) | |
| - * @method static bool contains(string $stringInput, string $needle, bool $caseSensitive = true, string $encoding = null) | |
| - * @method static bool containsAll(string $stringInput, array $needle, bool $caseSensitive = true, string $encoding = null) | |
| - * @method static bool containsAny(string $stringInput, string $needle, bool $caseSensitive = true, string $encoding = null) | |
| - * @method static int count(string $stringInput, string $encoding = null) | |
| - * @method static int countSubstr(string $stringInput, string $substring, bool $caseSensitive = true, string $encoding = null) | |
| - * @method static Stringy dasherize(string $stringInput, string $encoding = null) | |
| - * @method static Stringy delimit(string $stringInput, string $delimiter, string $encoding = null) | |
| - * @method static bool endsWith(string $stringInput, string $substring, bool $caseSensitive = true, string $encoding = null) | |
| - * @method static Stringy ensureLeft(string $stringInput, string $substring, string $encoding = null) | |
| - * @method static Stringy ensureRight(string $stringInput, string $substring, string $encoding = null) | |
| - * @method static Stringy escape(string $stringInput, string $encoding = null) | |
| - * @method static Stringy extractText(string $stringInput, string $search = '', int $length = null, string $ellipsis = '...') | |
| - * @method static Stringy first(string $stringInput, int $n, string $encoding = null) | |
| - * @method static bool hasLowerCase(string $stringInput, string $encoding = null) | |
| - * @method static bool hasUpperCase(string $stringInput, string $encoding = null) | |
| - * @method static Stringy htmlDecode(string $stringInput, int $flags = ENT_COMPAT, string $encoding = null) | |
| - * @method static Stringy htmlEncode(string $stringInput, int $flags = ENT_COMPAT, string $encoding = null) | |
| - * @method static Stringy humanize(string $stringInput, string $encoding = null) | |
| - * @method static int|bool indexOf(string $stringInput, string $needle, int $offset = 0, string $encoding = null) | |
| - * @method static int|bool indexOfLast(string $stringInput, string $needle, int $offset = 0, string $encoding = null) | |
| - * @method static Stringy insert(string $stringInput, string $substring, int $index = 0, string $encoding = null) | |
| - * @method static bool is(string $stringInput, string $pattern, string $encoding = null) | |
| - * @method static bool isAlpha(string $stringInput, string $encoding = null) | |
| - * @method static bool isAlphanumeric(string $stringInput, string $encoding = null) | |
| - * @method static bool isBase64(string $stringInput, string $encoding = null) | |
| - * @method static bool isBlank(string $stringInput, string $encoding = null) | |
| - * @method static bool isHexadecimal(string $stringInput, string $encoding = null) | |
| - * @method static bool isHtml(string $stringInput, string $encoding = null) | |
| - * @method static bool isJson(string $stringInput, string $encoding = null) | |
| - * @method static bool isLowerCase(string $stringInput, string $encoding = null) | |
| - * @method static bool isSerialized(string $stringInput, string $encoding = null) | |
| - * @method static bool isUpperCase(string $stringInput, string $encoding = null) | |
| - * @method static Stringy last(string $stringInput, string $encoding = null) | |
| - * @method static int length(string $stringInput, string $encoding = null) | |
| + * @method static Stringy at(string $stringInput, int $index, ?string $encoding = null) | |
| + * @method static Stringy between(string $stringInput, string $start, string $end, int $offset = 0, ?string $encoding = null) | |
| + * @method static Stringy camelize(string $stringInput, ?string $encoding = null) | |
| + * @method static string[] chars(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy collapseWhitespace(string $stringInput, ?string $encoding = null) | |
| + * @method static bool contains(string $stringInput, string $needle, bool $caseSensitive = true, ?string $encoding = null) | |
| + * @method static bool containsAll(string $stringInput, array $needle, bool $caseSensitive = true, ?string $encoding = null) | |
| + * @method static bool containsAny(string $stringInput, string $needle, bool $caseSensitive = true, ?string $encoding = null) | |
| + * @method static int count(string $stringInput, ?string $encoding = null) | |
| + * @method static int countSubstr(string $stringInput, string $substring, bool $caseSensitive = true, ?string $encoding = null) | |
| + * @method static Stringy dasherize(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy delimit(string $stringInput, string $delimiter, ?string $encoding = null) | |
| + * @method static bool endsWith(string $stringInput, string $substring, bool $caseSensitive = true, ?string $encoding = null) | |
| + * @method static Stringy ensureLeft(string $stringInput, string $substring, ?string $encoding = null) | |
| + * @method static Stringy ensureRight(string $stringInput, string $substring, ?string $encoding = null) | |
| + * @method static Stringy escape(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy extractText(string $stringInput, string $search = '', ?int $length = null, string $ellipsis = '...') | |
| + * @method static Stringy first(string $stringInput, int $n, ?string $encoding = null) | |
| + * @method static bool hasLowerCase(string $stringInput, ?string $encoding = null) | |
| + * @method static bool hasUpperCase(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy htmlDecode(string $stringInput, int $flags = ENT_COMPAT, ?string $encoding = null) | |
| + * @method static Stringy htmlEncode(string $stringInput, int $flags = ENT_COMPAT, ?string $encoding = null) | |
| + * @method static Stringy humanize(string $stringInput, ?string $encoding = null) | |
| + * @method static int|bool indexOf(string $stringInput, string $needle, int $offset = 0, ?string $encoding = null) | |
| + * @method static int|bool indexOfLast(string $stringInput, string $needle, int $offset = 0, ?string $encoding = null) | |
| + * @method static Stringy insert(string $stringInput, string $substring, int $index = 0, ?string $encoding = null) | |
| + * @method static bool is(string $stringInput, string $pattern, ?string $encoding = null) | |
| + * @method static bool isAlpha(string $stringInput, ?string $encoding = null) | |
| + * @method static bool isAlphanumeric(string $stringInput, ?string $encoding = null) | |
| + * @method static bool isBase64(string $stringInput, ?string $encoding = null) | |
| + * @method static bool isBlank(string $stringInput, ?string $encoding = null) | |
| + * @method static bool isHexadecimal(string $stringInput, ?string $encoding = null) | |
| + * @method static bool isHtml(string $stringInput, ?string $encoding = null) | |
| + * @method static bool isJson(string $stringInput, ?string $encoding = null) | |
| + * @method static bool isLowerCase(string $stringInput, ?string $encoding = null) | |
| + * @method static bool isSerialized(string $stringInput, ?string $encoding = null) | |
| + * @method static bool isUpperCase(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy last(string $stringInput, ?string $encoding = null) | |
| + * @method static int length(string $stringInput, ?string $encoding = null) | |
| * @method static string lineWrapAfterWord(string $stringInput, int $limit) | |
| - * @method static Stringy[] lines(string $stringInput, string $encoding = null) | |
| - * @method static Stringy longestCommonPrefix(string $stringInput, string $otherStr, string $encoding = null) | |
| - * @method static Stringy longestCommonSuffix(string $stringInput, string $otherStr, string $encoding = null) | |
| - * @method static Stringy longestCommonSubstring(string $stringInput, string $otherStr, string $encoding = null) | |
| - * @method static Stringy lowerCaseFirst(string $stringInput, string $encoding = null) | |
| - * @method static bool offsetExists(string $stringInput, mixed $offset, string $encoding = null) | |
| - * @method static string offsetGet(string $stringInput, mixed $offset, string $encoding = null) | |
| - * @method static Stringy pad(string $stringInput, int $length, string $padStr = ' ', string $padType = 'right', string $encoding = null) | |
| - * @method static Stringy padBoth(string $stringInput, int $length, string $padStr = ' ', string $encoding = null) | |
| - * @method static Stringy padLeft(string $stringInput, int $length, string $padStr = ' ', string $encoding = null) | |
| - * @method static Stringy padRight(string $stringInput, int $length, string $padStr = ' ', string $encoding = null) | |
| - * @method static Stringy prepend(string $stringInput, string $string, string $encoding = null) | |
| + * @method static Stringy[] lines(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy longestCommonPrefix(string $stringInput, string $otherStr, ?string $encoding = null) | |
| + * @method static Stringy longestCommonSuffix(string $stringInput, string $otherStr, ?string $encoding = null) | |
| + * @method static Stringy longestCommonSubstring(string $stringInput, string $otherStr, ?string $encoding = null) | |
| + * @method static Stringy lowerCaseFirst(string $stringInput, ?string $encoding = null) | |
| + * @method static bool offsetExists(string $stringInput, mixed $offset, ?string $encoding = null) | |
| + * @method static string offsetGet(string $stringInput, mixed $offset, ?string $encoding = null) | |
| + * @method static Stringy pad(string $stringInput, int $length, string $padStr = ' ', string $padType = 'right', ?string $encoding = null) | |
| + * @method static Stringy padBoth(string $stringInput, int $length, string $padStr = ' ', ?string $encoding = null) | |
| + * @method static Stringy padLeft(string $stringInput, int $length, string $padStr = ' ', ?string $encoding = null) | |
| + * @method static Stringy padRight(string $stringInput, int $length, string $padStr = ' ', ?string $encoding = null) | |
| + * @method static Stringy prepend(string $stringInput, string $string, ?string $encoding = null) | |
| * @method static Stringy regexReplace(string $stringInput, string $pattern, string $replacement, string $delimiter = '/') | |
| - * @method static Stringy removeLeft(string $stringInput, string $substring, string $encoding = null) | |
| - * @method static Stringy removeRight(string $stringInput, string $substring, string $encoding = null) | |
| - * @method static Stringy removeHtml(string $stringInput, string $allowableTags = null, string $encoding = null) | |
| - * @method static Stringy removeXss(string $stringInput, string $encoding = null) | |
| - * @method static Stringy repeat(string $stringInput, int $multiplier, string $encoding = null) | |
| - * @method static Stringy replace(string $stringInput, string $search, string $replacement, bool $caseSensitive, string $encoding = null) | |
| - * @method static Stringy replaceAll(string $stringInput, array $search, string $replacement, bool $caseSensitive, string $encoding = null) | |
| - * @method static Stringy reverse(string $stringInput, string $encoding = null) | |
| - * @method static Stringy safeTruncate(string $stringInput, int $length, string $substring = '', string $encoding = null) | |
| - * @method static Stringy shuffle(string $stringInput, string $encoding = null) | |
| + * @method static Stringy removeLeft(string $stringInput, string $substring, ?string $encoding = null) | |
| + * @method static Stringy removeRight(string $stringInput, string $substring, ?string $encoding = null) | |
| + * @method static Stringy removeHtml(string $stringInput, ?string $allowableTags = null, ?string $encoding = null) | |
| + * @method static Stringy removeXss(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy repeat(string $stringInput, int $multiplier, ?string $encoding = null) | |
| + * @method static Stringy replace(string $stringInput, string $search, string $replacement, bool $caseSensitive, ?string $encoding = null) | |
| + * @method static Stringy replaceAll(string $stringInput, array $search, string $replacement, bool $caseSensitive, ?string $encoding = null) | |
| + * @method static Stringy reverse(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy safeTruncate(string $stringInput, int $length, string $substring = '', ?string $encoding = null) | |
| + * @method static Stringy shuffle(string $stringInput, ?string $encoding = null) | |
| * @method static Stringy shortenAfterWord(string $stringInput, int $length, string $strAddOn) | |
| - * @method static Stringy slugify(string $stringInput, string $separator = '-', string $language = 'en', array $replacements = [], string $encoding = null) | |
| + * @method static Stringy slugify(string $stringInput, string $separator = '-', string $language = 'en', array $replacements = [], ?string $encoding = null) | |
| * @method static Stringy stripeCssMediaQueries(string $stringInput) | |
| * @method static Stringy stripeEmptyHtmlTags(string $stringInput) | |
| * @method static Stringy utf8ify(string $stringInput) | |
| - * @method static Stringy snakeize(string $stringInput, string $encoding = null) | |
| - * @method static bool startsWith(string $stringInput, string $substring, bool $caseSensitive = true, string $encoding = null) | |
| - * @method static Stringy slice(string $stringInput, int $start, int $end = null, string $encoding = null) | |
| - * @method static Stringy[] split(string $stringInput, string $pattern, int $limit = null, string $encoding = null) | |
| - * @method static Stringy substr(string $stringInput, int $start, int $length = null, string $encoding = null) | |
| - * @method static Stringy surround(string $stringInput, string $substring, string $encoding = null) | |
| - * @method static Stringy swapCase(string $stringInput, string $encoding = null) | |
| - * @method static Stringy tidy(string $stringInput, string $encoding = null) | |
| - * @method static Stringy titleize(string $stringInput, string $encoding = null) | |
| + * @method static Stringy snakeize(string $stringInput, ?string $encoding = null) | |
| + * @method static bool startsWith(string $stringInput, string $substring, bool $caseSensitive = true, ?string $encoding = null) | |
| + * @method static Stringy slice(string $stringInput, int $start, ?int $end = null, ?string $encoding = null) | |
| + * @method static Stringy[] split(string $stringInput, string $pattern, ?int $limit = null, ?string $encoding = null) | |
| + * @method static Stringy substr(string $stringInput, int $start, ?int $length = null, ?string $encoding = null) | |
| + * @method static Stringy surround(string $stringInput, string $substring, ?string $encoding = null) | |
| + * @method static Stringy swapCase(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy tidy(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy titleize(string $stringInput, ?string $encoding = null) | |
| * @method static Stringy toAscii(string $stringInput) | |
| - * @method static Stringy toBoolean(string $stringInput, string $encoding = null) | |
| + * @method static Stringy toBoolean(string $stringInput, ?string $encoding = null) | |
| * @method static Stringy toString(string $stringInput) | |
| - * @method static Stringy toLowerCase(string $stringInput, string $encoding = null) | |
| - * @method static Stringy toSpaces(string $stringInput, int $tabLength = 4, string $encoding = null) | |
| - * @method static Stringy toTabs(string $stringInput, int $tabLength = 4, string $encoding = null) | |
| - * @method static Stringy toTitleCase(string $stringInput, string $encoding = null) | |
| - * @method static Stringy toUpperCase(string $stringInput, string $encoding = null) | |
| - * @method static Stringy trim(string $stringInput, string $chars = null, string $encoding = null) | |
| - * @method static Stringy trimLeft(string $stringInput, string $chars = null, string $encoding = null) | |
| - * @method static Stringy trimRight(string $stringInput, string $chars = null, string $encoding = null) | |
| - * @method static Stringy truncate(string $stringInput, int $length, string $substring = '', string $encoding = null) | |
| - * @method static Stringy underscored(string $stringInput, string $encoding = null) | |
| - * @method static Stringy upperCamelize(string $stringInput, string $encoding = null) | |
| - * @method static Stringy upperCaseFirst(string $stringInput, string $encoding = null) | |
| + * @method static Stringy toLowerCase(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy toSpaces(string $stringInput, int $tabLength = 4, ?string $encoding = null) | |
| + * @method static Stringy toTabs(string $stringInput, int $tabLength = 4, ?string $encoding = null) | |
| + * @method static Stringy toTitleCase(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy toUpperCase(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy trim(string $stringInput, ?string $chars = null, ?string $encoding = null) | |
| + * @method static Stringy trimLeft(string $stringInput, ?string $chars = null, ?string $encoding = null) | |
| + * @method static Stringy trimRight(string $stringInput, ?string $chars = null, ?string $encoding = null) | |
| + * @method static Stringy truncate(string $stringInput, int $length, string $substring = '', ?string $encoding = null) | |
| + * @method static Stringy underscored(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy upperCamelize(string $stringInput, ?string $encoding = null) | |
| + * @method static Stringy upperCaseFirst(string $stringInput, ?string $encoding = null) | |
| * | |
| * @deprecated <p>Please use e.g. (new Stringy('foo'))->upperCaseFirst() instead or write your own small wrapper, because I can't protect you from BC from new parameters, | |
| * if you use this class, thanks.</p> | |
| diff --git a/src/Stringy.php b/src/Stringy.php | |
| index df8eb5a..ba402d1 100644 | |
| --- a/src/Stringy.php | |
| +++ b/src/Stringy.php | |
| @@ -74,7 +74,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| * | |
| * @psalm-mutation-free | |
| */ | |
| - public function __construct($str = '', string $encoding = null) | |
| + public function __construct($str = '', ?string $encoding = null) | |
| { | |
| /* @phpstan-ignore-next-line | always false in theory */ | |
| if (\is_array($str)) { | |
| @@ -598,7 +598,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| * @return static | |
| * <p>Object whose $str is a substring between $start and $end.</p> | |
| */ | |
| - public function between(string $start, string $end, int $offset = null): self | |
| + public function between(string $start, string $end, ?int $offset = null): self | |
| { | |
| $str = $this->utf8::between( | |
| $this->str, | |
| @@ -954,7 +954,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| * <p>A Stringy object.</p> | |
| * @phpstan-pure | |
| */ | |
| - public static function create($str = '', string $encoding = null): self | |
| + public static function create($str = '', ?string $encoding = null): self | |
| { | |
| return new static($str, $encoding); | |
| } | |
| @@ -1321,7 +1321,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| * | |
| * @return static | |
| */ | |
| - public function extractText(string $search = '', int $length = null, string $replacerForSkippedText = '…'): self | |
| + public function extractText(string $search = '', ?int $length = null, string $replacerForSkippedText = '…'): self | |
| { | |
| return static::create( | |
| $this->utf8::extract_text( | |
| @@ -2653,7 +2653,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| int $limit, | |
| string $break = "\n", | |
| bool $add_final_break = true, | |
| - string $delimiter = null | |
| + ?string $delimiter = null | |
| ): self { | |
| return static::create( | |
| $this->utf8::wordwrap_per_line( | |
| @@ -2692,7 +2692,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| int $limit, | |
| string $break = "\n", | |
| bool $add_final_break = true, | |
| - string $delimiter = null | |
| + ?string $delimiter = null | |
| ): self { | |
| return static::create( | |
| $this->utf8::wordwrap_per_line( | |
| @@ -3822,7 +3822,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| * @return static | |
| * <p>Object with its $str being the extracted substring.</p> | |
| */ | |
| - public function slice(int $start, int $end = null): self | |
| + public function slice(int $start, ?int $end = null): self | |
| { | |
| return static::create( | |
| $this->utf8::str_slice($this->str, $start, $end, $this->encoding), | |
| @@ -3963,7 +3963,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| * | |
| * @phpstan-return array<int,static> | |
| */ | |
| - public function split(string $pattern, int $limit = null): array | |
| + public function split(string $pattern, ?int $limit = null): array | |
| { | |
| if ($this->str === '') { | |
| return []; | |
| @@ -4004,7 +4004,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| * | |
| * @phpstan-return CollectionStringy<int,static> | |
| */ | |
| - public function splitCollection(string $pattern, int $limit = null): CollectionStringy | |
| + public function splitCollection(string $pattern, ?int $limit = null): CollectionStringy | |
| { | |
| /** | |
| * @psalm-suppress ImpureMethodCall -> add more psalm stuff to the collection class | |
| @@ -4185,7 +4185,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| * @return static | |
| * <p>Object with its $str being the substring.</p> | |
| */ | |
| - public function substr(int $start, int $length = null): self | |
| + public function substr(int $start, ?int $length = null): self | |
| { | |
| return static::create( | |
| $this->utf8::substr( | |
| @@ -4213,7 +4213,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| * | |
| * @return static | |
| */ | |
| - public function substring(int $start, int $length = null): self | |
| + public function substring(int $start, ?int $length = null): self | |
| { | |
| if ($length === null) { | |
| return $this->substr($start); | |
| @@ -4362,9 +4362,9 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| * <p>Object with a titleized $str.</p> | |
| */ | |
| public function titleize( | |
| - array $ignore = null, | |
| - string $word_define_chars = null, | |
| - string $language = null | |
| + ?array $ignore = null, | |
| + ?string $word_define_chars = null, | |
| + ?string $language = null | |
| ): self { | |
| return static::create( | |
| $this->utf8::str_titleize( | |
| @@ -4667,7 +4667,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| * @return static | |
| * <p>Object with a trimmed $str.</p> | |
| */ | |
| - public function trim(string $chars = null): self | |
| + public function trim(?string $chars = null): self | |
| { | |
| return static::create( | |
| $this->utf8::trim($this->str, $chars), | |
| @@ -4691,7 +4691,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| * @return static | |
| * <p>Object with a trimmed $str.</p> | |
| */ | |
| - public function trimLeft(string $chars = null): self | |
| + public function trimLeft(?string $chars = null): self | |
| { | |
| return static::create( | |
| $this->utf8::ltrim($this->str, $chars), | |
| @@ -4715,7 +4715,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| * @return static | |
| * <p>Object with a trimmed $str.</p> | |
| */ | |
| - public function trimRight(string $chars = null): self | |
| + public function trimRight(?string $chars = null): self | |
| { | |
| return static::create( | |
| $this->utf8::rtrim($this->str, $chars), | |
| @@ -5013,7 +5013,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| public function words( | |
| string $char_list = '', | |
| bool $remove_empty_values = false, | |
| - int $remove_short_values = null | |
| + ?int $remove_short_values = null | |
| ): array { | |
| if ($remove_short_values === null) { | |
| $strings = $this->utf8::str_to_words( | |
| @@ -5063,7 +5063,7 @@ class Stringy implements \ArrayAccess, \Countable, \IteratorAggregate, \JsonSeri | |
| public function wordsCollection( | |
| string $char_list = '', | |
| bool $remove_empty_values = false, | |
| - int $remove_short_values = null | |
| + ?int $remove_short_values = null | |
| ): CollectionStringy { | |
| /** | |
| * @psalm-suppress ImpureMethodCall -> add more psalm stuff to the collection class | |
| -- | |
| 2.43.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment