Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #321 from tighten/v9.28.0-changes
Browse files Browse the repository at this point in the history
v9.28.0 changes
  • Loading branch information
jamisonvalenta authored Sep 30, 2022
2 parents 171e836 + bc8eb1a commit 413c3ac
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 17 deletions.
58 changes: 44 additions & 14 deletions tests/files/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,16 @@ public static function camel($value)
* Determine if a given string contains a given substring.
*
* @param string $haystack
* @param string|string[] $needles
* @param string|string[]|Enumerable<array-key, string> $needles
* @param bool $ignoreCase
* @return bool
*/
public static function contains($haystack, $needles, $ignoreCase = false)
{
if ($needles instanceof Enumerable) {
$needles = $needles->toArray();
}

if ($ignoreCase) {
$haystack = mb_strtolower($haystack);
$needles = array_map('mb_strtolower', (array) $needles);
Expand All @@ -242,12 +246,16 @@ public static function contains($haystack, $needles, $ignoreCase = false)
* Determine if a given string contains all array values.
*
* @param string $haystack
* @param string[] $needles
* @param string[]|Enumerable<array-key, string> $needles
* @param bool $ignoreCase
* @return bool
*/
public static function containsAll($haystack, array $needles, $ignoreCase = false)
public static function containsAll($haystack, $needles, $ignoreCase = false)
{
if ($needles instanceof Enumerable) {
$needles = $needles->toArray();
}

if ($ignoreCase) {
$haystack = mb_strtolower($haystack);
$needles = array_map('mb_strtolower', $needles);
Expand All @@ -266,7 +274,7 @@ public static function containsAll($haystack, array $needles, $ignoreCase = fals
* Determine if a given string ends with a given substring.
*
* @param string $haystack
* @param string|string[] $needles
* @param string|string[]|Enumerable<array-key, string> $needles
* @return bool
*/
public static function endsWith($haystack, $needles)
Expand Down Expand Up @@ -781,12 +789,16 @@ public static function repeat(string $string, int $times)
* Replace a given value in the string sequentially with an array.
*
* @param string $search
* @param array<int|string, string> $replace
* @param string[]|Enumerable<array-key, string> $replace
* @param string $subject
* @return string
*/
public static function replaceArray($search, array $replace, $subject)
public static function replaceArray($search, $replace, $subject)
{
if ($replace instanceof Enumerable) {
$replace = $replace->toArray();
}

$segments = explode($search, $subject);

$result = array_shift($segments);
Expand All @@ -801,13 +813,25 @@ public static function replaceArray($search, array $replace, $subject)
/**
* Replace the given value in the given string.
*
* @param string|string[] $search
* @param string|string[] $replace
* @param string|string[] $subject
* @param string|string[]|Enumerable<array-key, string> $search
* @param string|string[]|Enumerable<array-key, string> $replace
* @param string|string[]|Enumerable<array-key, string> $subject
* @return string
*/
public static function replace($search, $replace, $subject)
{
if ($search instanceof Enumerable) {
$search = $search->toArray();
}

if ($replace instanceof Enumerable) {
$replace = $replace->toArray();
}

if ($subject instanceof Enumerable) {
$subject = $subject->toArray();
}

return str_replace($search, $replace, $subject);
}

Expand Down Expand Up @@ -862,13 +886,17 @@ public static function replaceLast($search, $replace, $subject)
/**
* Remove any occurrence of the given string in the subject.
*
* @param string|array<string> $search
* @param string|string[]|Enumerable<array-key, string> $search
* @param string $subject
* @param bool $caseSensitive
* @return string
*/
public static function remove($search, $subject, $caseSensitive = true)
{
if ($search instanceof Enumerable) {
$search = $search->toArray();
}

$subject = $caseSensitive
? str_replace($search, '', $subject)
: str_ireplace($search, '', $subject);
Expand Down Expand Up @@ -1021,7 +1049,7 @@ public static function squish($value)
* Determine if a given string starts with a given substring.
*
* @param string $haystack
* @param string|string[] $needles
* @param string|string[]|Enumerable<array-key, string> $needles
* @return bool
*/
public static function startsWith($haystack, $needles)
Expand Down Expand Up @@ -1257,9 +1285,11 @@ public static function freezeUuids(Closure $callback = null)
Str::createUuidsUsing(fn () => $uuid);

if ($callback !== null) {
$callback($uuid);

Str::createUuidsNormally();
try {
$callback($uuid);
} finally {
Str::createUuidsNormally();
}
}

return $uuid;
Expand Down
12 changes: 10 additions & 2 deletions tests/files/Support/Stringable.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,20 @@ public function repeat(int $times)
/**
* Replace the given value in the given string.
*
* @param string|string[] $search
* @param string|string[] $replace
* @param string|string[]|Enumerable<array-key, string> $search
* @param string|string[]|Enumerable<array-key, string> $replace
* @return static
*/
public function replace($search, $replace)
{
if ($search instanceof Enumerable) {
$search = $search->toArray();
}

if ($replace instanceof Enumerable) {
$replace = $replace->toArray();
}

return new static(str_replace($search, $replace, $this->value));
}

Expand Down
2 changes: 1 addition & 1 deletion upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ function getCurrentVersionFromGitHub()
echo Getting current version from $repository...

if [ -z "$requestedVersion" ]; then
collectionVersion=$(git ls-remote $repository --tags v9.27\* | grep tags/ | grep -v {} | cut -d \/ -f 3 | cut -d v -f 2 | grep -v RC | grep -vi beta | sort -t. -k 1,1n -k 2,2n -k 3,3n| tail -1)
collectionVersion=$(git ls-remote $repository --tags v9.28\* | grep tags/ | grep -v {} | cut -d \/ -f 3 | cut -d v -f 2 | grep -v RC | grep -vi beta | sort -t. -k 1,1n -k 2,2n -k 3,3n| tail -1)
else
collectionVersion=$requestedVersion
fi
Expand Down

0 comments on commit 413c3ac

Please sign in to comment.