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 #328 from tighten/v9.35.1-changes
Browse files Browse the repository at this point in the history
v9.35.1 changes
  • Loading branch information
jamisonvalenta authored Jan 13, 2023
2 parents 306135c + 9fcb3f4 commit 8998fef
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Collect/Support/Traits/EnumeratesValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -980,12 +980,12 @@ protected function getArrayableItems($items)
return $items->all();
} elseif ($items instanceof Arrayable) {
return $items->toArray();
} elseif ($items instanceof Traversable) {
return iterator_to_array($items);
} elseif ($items instanceof Jsonable) {
return json_decode($items->toJson(), true);
} elseif ($items instanceof JsonSerializable) {
return (array) $items->jsonSerialize();
} elseif ($items instanceof Traversable) {
return iterator_to_array($items);
} elseif ($items instanceof UnitEnum) {
return [$items];
}
Expand Down
27 changes: 27 additions & 0 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
use Tightenco\Collect\Support\MultipleItemsFoundException;
use Illuminate\Support\Str;
use InvalidArgumentException;
use IteratorAggregate;
use JsonSerializable;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use stdClass;
use Symfony\Component\VarDumper\VarDumper;
use Traversable;
use UnexpectedValueException;

if (PHP_VERSION_ID >= 80100) {
Expand Down Expand Up @@ -622,6 +624,11 @@ public function testGetArrayableItems($collection)
$array = $method->invokeArgs($data, [$items]);
$this->assertSame(['foo'], $array);

$subject = [new stdClass, new stdClass];
$items = new TestTraversableAndJsonSerializableObject($subject);
$array = $method->invokeArgs($data, [$items]);
$this->assertSame($subject, $array);

$items = new $collection(['foo' => 'bar']);
$array = $method->invokeArgs($data, [$items]);
$this->assertSame(['foo' => 'bar'], $array);
Expand Down Expand Up @@ -5592,6 +5599,26 @@ public function jsonSerialize(): string
}
}

class TestTraversableAndJsonSerializableObject implements IteratorAggregate, JsonSerializable
{
public $items;

public function __construct($items)
{
$this->items = $items;
}

public function getIterator(): Traversable
{
return new ArrayIterator($this->items);
}

public function jsonSerialize(): array
{
return json_decode(json_encode($this->items), true);
}
}

class TestCollectionMapIntoObject
{
public $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.33\* | 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.35\* | 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 8998fef

Please sign in to comment.