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

Commit

Permalink
Merge pull request #3 from michael-rubel/support/php82
Browse files Browse the repository at this point in the history
Drop support of Laravel 8 and ensure support of PHP `8.2`
  • Loading branch information
michael-rubel authored Dec 10, 2022
2 parents 8e5c596 + d7b0eab commit 6b3b6e9
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 36 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.0, 8.1]
laravel: [^8.71, 9.*]
php: [8.0, 8.1, 8.2]
laravel: [9.*]
stability: [prefer-lowest, prefer-stable]
include:
- testbench: 7.*
laravel: 9.*
- testbench: ^6.6
laravel: ^8.71

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand All @@ -42,7 +37,7 @@ jobs:
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" "nesbot/carbon:^2.62.1" --dev --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

The package provides the collection of methods to loop over your data.

The package requires PHP `^8.x` and Laravel `^8.71` or `^9.0`.
The package requires PHP `^8.x` and Laravel `^9.0`.

## #StandWithUkraine
[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/LoopFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function propertiesFrom(Model|\ArrayAccess|array|null $data = null, mixed
if ($data) {
match (true) {
$data instanceof Model => $this->attributesToProperties($data, $rescue),
default => $this->arrayToProperties($data, $rescue),
default => $this->arrayToProperties($data, $rescue),
};
}
}
Expand Down
10 changes: 5 additions & 5 deletions tests/ArrayMappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public function setUp(): void
public function testCanMapAnArrayToProperties()
{
$array = [
'test' => true,
'name' => 'Michael Rubel',
'test' => true,
'name' => 'Michael Rubel',
'password' => 'p@$$w0rd',
];

Expand All @@ -56,8 +56,8 @@ public function testCanMapAnArrayToProperties()
public function testCanMapAnArray()
{
$array = [
'test' => true,
'name' => 'Michael Rubel',
'test' => true,
'name' => 'Michael Rubel',
'password' => 'p@$$w0rd',
'additional_data' => [
'next' => 'test',
Expand Down Expand Up @@ -124,7 +124,7 @@ public function testCollectionAssignmentIsOk()
public function testCanMapUsingPropertiesFrom()
{
$array = [
'test' => true,
'test' => true,
'additional_data' => [
'next' => [
'test' => true,
Expand Down
24 changes: 12 additions & 12 deletions tests/AttributeMappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class AttributeMappingTest extends TestCase
public function testMapsAttributesToClassPropertiesCorrectly()
{
$model = new TestModel([
'id' => 1,
'test' => true,
'name' => 'mapped',
'id' => 1,
'test' => true,
'name' => 'mapped',
'files' => collect('/img/src/screen.png'),
]);

Expand All @@ -48,10 +48,10 @@ public function testMapsAttributesToClassPropertiesCorrectly()
public function testMappingIgnoresDifferentTypes()
{
$model = new TestModel([
'id' => 1,
'test' => true,
'name' => 100.1,
'files' => null,
'id' => 1,
'test' => true,
'name' => 100.1,
'files' => null,
'default' => fn () => true,
]);

Expand All @@ -68,7 +68,7 @@ public function testMappingIgnoresDifferentTypes()
public function testMappingWorksWithCollections()
{
$model = new TestModel([
'id' => 1,
'id' => 1,
'collection' => new Collection(),
]);

Expand Down Expand Up @@ -98,9 +98,9 @@ public function testMappingWithCasts()
public function testIdAndPasswordIsIgnored()
{
$model = new TestModel([
'id' => 1,
'id' => 1,
'password' => 'hash',
'test' => true,
'test' => true,
]);

$this->attributesToProperties($model);
Expand All @@ -116,9 +116,9 @@ public function testSetsDefaultValueWithWrongConfig()
config(['loop-functions.ignore_attributes' => 123]);

$model = new TestModel([
'id' => 1,
'id' => 1,
'password' => 'hash',
'test' => true,
'test' => true,
]);

$this->attributesToProperties($model);
Expand Down
2 changes: 1 addition & 1 deletion tests/Boilerplate/TestModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TestModel extends Model
* @var string[]
*/
protected $casts = [
'collection' => AsCollection::class,
'collection' => AsCollection::class,
'intAsString' => 'string',
];
}
16 changes: 8 additions & 8 deletions tests/RecursiveArrayMappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ public function testCanMapRecursively()
$data = [
'collection' => collect([
'first_name' => 'Michael',
'last_name' => 'Rubel',
'last_name' => 'Rubel',
]),
'last_name' => 'Rubel',
'array' => [
'test' => true,
'full_name' => 'Michael Rubel',
'last_name' => 'Rubel',
'array' => [
'test' => true,
'full_name' => 'Michael Rubel',
'first_name' => 'Tester',
'last_name' => 'Field',
'nice' => 'yes',
'last_name' => 'Field',
'nice' => 'yes',
],
'nice' => 'yes',
'nice' => 'yes',
];

$this->propertiesFrom($data);
Expand Down

0 comments on commit 6b3b6e9

Please sign in to comment.