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

Commit

Permalink
Merge pull request #301 from tighten/v9.10.1-changes
Browse files Browse the repository at this point in the history
v9.10.1 changes
  • Loading branch information
jamisonvalenta authored May 12, 2022
2 parents c1458c8 + aa3bd19 commit 8f1c661
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Collect/Support/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public static function forget(&$array, $keys)
while (count($parts) > 1) {
$part = array_shift($parts);

if (isset($array[$part]) && is_array($array[$part])) {
if (isset($array[$part]) && static::accessible($array[$part])) {
$array = &$array[$part];
} else {
continue 2;
Expand Down
4 changes: 2 additions & 2 deletions src/Collect/Support/Enumerable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1200,9 +1200,9 @@ public function toArray();
/**
* Convert the object into something JSON serializable.
*
* @return array<TKey, mixed>
* @return mixed
*/
public function jsonSerialize(): array;
public function jsonSerialize(): mixed;

/**
* Get the collection of items as JSON.
Expand Down
37 changes: 37 additions & 0 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3506,6 +3506,33 @@ public function testPullRemovesItemFromCollection()
$this->assertEquals([1 => 'bar'], $c->all());
}

public function testPullRemovesItemFromNestedCollection()
{
$nestedCollection = new Collection([
new Collection([
'value',
new Collection([
'bar' => 'baz',
'test' => 'value',
]),
]),
'bar',
]);

$nestedCollection->pull('0.1.test');

$actualArray = $nestedCollection->toArray();
$expectedArray = [
[
'value',
['bar' => 'baz'],
],
'bar',
];

$this->assertEquals($expectedArray, $actualArray);
}

public function testPullReturnsDefault()
{
$c = new Collection([]);
Expand Down Expand Up @@ -3868,13 +3895,15 @@ public function testJsonSerialize($collection)
new TestArrayableObject,
new TestJsonableObject,
new TestJsonSerializeObject,
new TestJsonSerializeToStringObject,
'baz',
]);

$this->assertSame([
['foo' => 'bar'],
['foo' => 'bar'],
['foo' => 'bar'],
'foobar',
'baz',
], $c->jsonSerialize());
}
Expand Down Expand Up @@ -5169,6 +5198,14 @@ public function jsonSerialize(): array
}
}

class TestJsonSerializeToStringObject implements JsonSerializable
{
public function jsonSerialize(): string
{
return 'foobar';
}
}

class TestJsonSerializeWithScalarValueObject implements JsonSerializable
{
public function jsonSerialize(): string
Expand Down
9 changes: 2 additions & 7 deletions tests/files/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,7 @@ public static function containsAll($haystack, array $needles, $ignoreCase = fals
public static function endsWith($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if (
$needle !== '' && $needle !== null
&& str_ends_with($haystack, $needle)
) {
if ((string) $needle !== '' && str_ends_with($haystack, $needle)) {
return true;
}
}
Expand Down Expand Up @@ -926,9 +923,7 @@ public static function studly($value)

$words = explode(' ', static::replace(['-', '_'], ' ', $value));

$studlyWords = array_map(function ($word) {
return static::ucfirst($word);
}, $words);
$studlyWords = array_map(fn ($word) => static::ucfirst($word), $words);

return static::$studlyCache[$key] = implode($studlyWords);
}
Expand Down
2 changes: 1 addition & 1 deletion upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ function getCurrentVersionFromGitHub()
echo Getting current version from $repository...

if [ -z "$requestedVersion" ]; then
collectionVersion=$(git ls-remote $repository --tags v9.9\* | 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.10\* | 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 8f1c661

Please sign in to comment.