Skip to content

Commit f5f4fe6

Browse files
committed
change minimal php version to 8
1 parent 5e0fdcd commit f5f4fe6

18 files changed

+131
-92
lines changed

.github/workflows/php.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
name: PHP Laravel Package
22

3-
on: [push]
3+
on: [ push ]
44

55
jobs:
6-
phpcs:
7-
name: PHPCS
8-
runs-on: ubuntu-latest
9-
steps:
10-
- uses: actions/checkout@v2
11-
- name: PHPCS check
12-
uses: chekalsky/phpcs-action@v1
13-
with:
14-
enable_warnings: true
6+
# phpcs:
7+
# name: PHPCS
8+
# runs-on: ubuntu-latest
9+
# steps:
10+
# - uses: actions/checkout@v2
11+
# - name: PHPCS check
12+
# uses: chekalsky/phpcs-action@v1
13+
# with:
14+
# enable_warnings: true
1515

1616
lint-changelog:
1717
name: Lint changelog file
@@ -29,15 +29,15 @@ jobs:
2929
testing:
3030
name: Test on PHP ${{ matrix.php }} with ${{ matrix.setup }} dependencies
3131

32-
needs: [phpcs, lint-changelog]
32+
needs: [ lint-changelog ]
3333
runs-on: ubuntu-latest
3434
timeout-minutes: 10
3535

3636
strategy:
3737
fail-fast: false
3838
matrix:
39-
setup: ['basic', 'lowest']
40-
php: ['7.4', '8.0']
39+
setup: [ 'basic', 'lowest' ]
40+
php: [ '8.0' ]
4141

4242
services:
4343
postgres:
@@ -58,7 +58,7 @@ jobs:
5858
- uses: actions/checkout@v2
5959

6060
- name: Use PHP ${{ matrix.php }}
61-
uses: shivammathur/setup-php@v1 # Action page: <https://github.com/shivammathur/setup-php>
61+
uses: shivammathur/setup-php@v2 # Action page: <https://github.com/shivammathur/setup-php>
6262
with:
6363
php-version: ${{ matrix.php }}
6464
extensions: mbstring
@@ -102,7 +102,7 @@ jobs:
102102

103103
release:
104104
name: Create Release
105-
needs: [testing]
105+
needs: [ testing ]
106106
runs-on: ubuntu-latest
107107
if: ${{ startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '.0') }}
108108
steps:

CHANGELOG.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ Check MD [online][check-online].
99

1010
## [unreleased]
1111

12+
## [1.0.0] - 2021-04-28
13+
14+
### Changed
15+
16+
- Create a new stage of the package with minimal PHP version: `8.0`
17+
1218
## [0.11.0] - 2021-01-27
1319

1420
### Removed
@@ -158,27 +164,50 @@ Check MD [online][check-online].
158164
- The trait `CasterAttribute`: for custom class casts
159165
- The trait for DB/Migration `UUID`
160166

161-
[unreleased]: https://github.com/efureev/laravel-support/compare/v0.11.0...HEAD
167+
[unreleased]: https://github.com/efureev/laravel-support/compare/v1.0.0...HEAD
168+
169+
[1.0.0]: https://github.com/efureev/laravel-support/compare/v0.11.0...v1.0.0
170+
162171
[0.11.0]: https://github.com/efureev/laravel-support/compare/v0.10.1...v0.11.0
172+
163173
[0.10.1]: https://github.com/efureev/laravel-support/compare/v0.10.0...v0.10.1
174+
164175
[0.10.0]: https://github.com/efureev/laravel-support/compare/v0.9.4...v0.10.0
176+
165177
[0.9.4]: https://github.com/efureev/laravel-support/compare/v0.9.3...v0.9.4
178+
166179
[0.9.3]: https://github.com/efureev/laravel-support/compare/v0.9.2...v0.9.3
180+
167181
[0.9.2]: https://github.com/efureev/laravel-support/compare/v0.9.0...v0.9.2
182+
168183
[0.8.0]: https://github.com/efureev/laravel-support/compare/v0.8.0...v0.9.0
184+
169185
[0.8.0]: https://github.com/efureev/laravel-support/compare/v0.7.0...v0.8.0
186+
170187
[0.7.0]: https://github.com/efureev/laravel-support/compare/v0.6.0...v0.7.0
188+
171189
[0.6.0]: https://github.com/efureev/laravel-support/compare/v0.5.3...v0.6.0
190+
172191
[0.5.3]: https://github.com/efureev/laravel-support/compare/v0.5.2...v0.5.3
192+
173193
[0.5.2]: https://github.com/efureev/laravel-support/compare/v0.3.0...v0.5.2
194+
174195
[0.3.0]: https://github.com/efureev/laravel-support/compare/v0.2.1...v0.3.0
196+
175197
[0.2.1]: https://github.com/efureev/laravel-support/compare/v0.2.0...v0.2.1
198+
176199
[0.2.0]: https://github.com/efureev/laravel-support/compare/v0.1.0...v0.2.0
200+
177201
[0.1.0]: https://github.com/efureev/laravel-support/compare/v0.0.3...v0.1.0
202+
178203
[0.0.3]: https://github.com/efureev/laravel-support/compare/v0.0.2...v0.0.3
204+
179205
[0.0.2]: https://github.com/efureev/laravel-support/compare/v0.0.1...v0.0.2
206+
180207
[0.0.1]: https://github.com/efureev/laravel-support/releases/tag/v0.0.1
181208

182209
[keepachangelog]:https://keepachangelog.com/en/1.1.0/
210+
183211
[semver]:https://semver.org/spec/v2.0.0.html
212+
184213
[check-online]:https://dlaa.me/markdownlint

composer.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^7.4|^8.0",
20-
"ext-json": "*",
21-
"efureev/support": "^3.0",
22-
"illuminate/database": "^7.30.3|^8.22.1"
19+
"php": "^8.0",
20+
"efureev/support": "^4.1",
21+
"illuminate/database": "^8.38"
2322
},
2423
"require-dev": {
2524
"phpunit/phpunit": "^9.5",
26-
"orchestra/testbench": "^5.14",
27-
"squizlabs/php_codesniffer": "^3.5",
28-
"fakerphp/faker": "^1.13"
25+
"orchestra/testbench": "^6.17",
26+
"squizlabs/php_codesniffer": "^3.6",
27+
"fakerphp/faker": "^1.14"
2928
},
3029
"autoload": {
3130
"files": [
@@ -37,11 +36,10 @@
3736
},
3837
"autoload-dev": {
3938
"psr-4": {
39+
"Php\\Support\\Laravel\\Tests\\Database\\Factories\\": "tests/database/factories",
40+
"Php\\Support\\Laravel\\Tests\\Database\\Seeders\\": "tests/database/seeders",
4041
"Php\\Support\\Laravel\\Tests\\": "tests/"
41-
},
42-
"classmap": [
43-
"tests/database/seeds"
44-
]
42+
}
4543
},
4644
"extra": {
4745
"laravel": {

src/Caster/HasCasts.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ public function castValue($type, $value)
7070
switch ($simpleType = strtolower(trim($type))) {
7171
case 'int':
7272
case 'integer':
73-
return (int)$value;
73+
return (int) $value;
7474
case 'real':
7575
case 'float':
7676
case 'double':
7777
return $this->fromFloat($value);
7878
case 'decimal':
7979
return $this->asDecimal($value, explode(':', $simpleType, 2)[1]);
8080
case 'string':
81-
return (string)$value;
81+
return (string) $value;
8282
case 'bool':
8383
case 'boolean':
84-
return (bool)$value;
84+
return (bool) $value;
8585
case 'object':
8686
return $this->fromJson($value, true);
8787
case 'array':

tests/Functional/CasterCollectionTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,5 @@ protected function setUp(): void
216216
parent::setUp();
217217

218218
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
219-
$this->withFactories(__DIR__ . '/../database/factories');
220219
}
221220
}

tests/Functional/CasterTraitTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Php\Support\Laravel\Tests\Functional;
66

77
use Illuminate\Database\Eloquent\Collection;
8+
use Php\Support\Laravel\Tests\Database\Factories\TestModelFactory;
89
use Php\Support\Laravel\Tests\TestClasses\Entity\EmptyParams;
910
use Php\Support\Laravel\Tests\TestClasses\Entity\Params;
1011
use Php\Support\Laravel\Tests\TestClasses\Models\PgArrayModel;
@@ -16,7 +17,7 @@ class CasterTraitTest extends AbstractFunctionalTestCase
1617
public function testCreateAndGetWithNullParams(): void
1718
{
1819
/** @var Collection $list */
19-
$list = factory(TestModel::class, 5)->create();
20+
$list = TestModelFactory::times(5)->create();
2021

2122
static::assertCount(5, $list);
2223

@@ -42,7 +43,7 @@ public function testCreateAndGetWithNullParams(): void
4243
public function testCreateAndGetWithEmptyArrayParams(): void
4344
{
4445
/** @var Collection $list */
45-
$list = factory(TestModel::class, 5)->create(
46+
$list = TestModelFactory::times(5)->create(
4647
[
4748
'params' => [],
4849
'config' => [],
@@ -90,7 +91,7 @@ public function testCreateAndGetWithEmptyArrayParams(): void
9091
public function testCreateAndGetWithFillArrayParams(): void
9192
{
9293
/** @var Collection $list */
93-
$list = factory(TestModel::class, 5)->create(
94+
$list = TestModelFactory::times(5)->create(
9495
[
9596
'str' => 'string',
9697
'str_empty' => 'string empty',
@@ -143,7 +144,7 @@ public function testCreateAndGetWithFillArrayParams(): void
143144
public function testCreateAndGetWithClassParams(): void
144145
{
145146
/** @var Collection $list */
146-
$list = factory(TestModel::class, 5)->create(
147+
$list = TestModelFactory::times(5)->create(
147148
[
148149
'str_empty' => null,
149150
'config' => [
@@ -293,7 +294,6 @@ protected function setUp(): void
293294
{
294295
parent::setUp();
295296

296-
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
297-
$this->withFactories(__DIR__ . '/../database/factories');
297+
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
298298
}
299299
}

tests/Functional/ModelableTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Database\Eloquent\Collection;
99
use Illuminate\Database\Eloquent\ModelNotFoundException;
1010
use Php\Support\Exceptions\UnknownMethodException;
11+
use Php\Support\Laravel\Tests\Database\Seeders\BaseTableSeeder;
1112
use Php\Support\Laravel\Tests\TestClasses\HasCustomModel;
1213
use Php\Support\Laravel\Tests\TestClasses\HasModel;
1314
use Php\Support\Laravel\Tests\TestClasses\Models\BaseModel;
@@ -86,8 +87,8 @@ protected function setUp(): void
8687
{
8788
parent::setUp();
8889

89-
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations/2020_08_12_075141_create_base_table.php');
90+
$this->loadMigrationsFrom(__DIR__.'/../database/migrations/2020_08_12_075141_create_base_table.php');
9091

91-
$this->seed(\BaseTableSeeder::class);
92+
$this->seed(BaseTableSeeder::class);
9293
}
9394
}

tests/Rules/AuthorizedTest.php

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
namespace Php\Support\Laravel\Tests\Rules;
66

7-
use Illuminate\Foundation\Auth\User;
87
use Illuminate\Support\Facades\Gate;
98
use Illuminate\Support\Facades\Lang;
109
use Php\Support\Laravel\Rules\Authorized;
1110
use Php\Support\Laravel\Tests\AbstractTestCase;
11+
use Php\Support\Laravel\Tests\Database\Factories\TestModelFactory;
12+
use Php\Support\Laravel\Tests\Database\Factories\UserFactory;
1213
use Php\Support\Laravel\Tests\TestClasses\Models\TestModel;
1314
use Php\Support\Laravel\Tests\TestClasses\Policies\TestModelPolicy;
1415

@@ -18,71 +19,69 @@ protected function setUp(): void
1819
{
1920
parent::setUp();
2021

21-
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
22-
$this->withFactories(__DIR__ . '/../database/factories');
22+
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
2323

2424
Gate::policy(TestModel::class, TestModelPolicy::class);
2525
}
2626

2727
/** @test */
2828
public function it_will_return_true_if_the_gate_returns_true_for_the_given_ability_name()
2929
{
30-
3130
$rule = new Authorized('edit', TestModel::class);
3231

33-
$user = factory(User::class)->create();
34-
$model = factory(TestModel::class)->create(
32+
$user = UserFactory::new()->create();
33+
$model = TestModelFactory::new()->create(
3534
[
3635
'user_id' => $user->getKey(),
3736
]
3837
);
3938

4039
$this->actingAs($user);
4140

42-
$this->assertTrue($rule->passes('attribute', $model->getKey()));
41+
self::assertTrue($rule->passes('attribute', $model->getKey()));
4342
}
4443

4544
/** @test */
4645
public function it_will_return_false_if_noone_is_logged_in()
4746
{
4847
$rule = new Authorized('edit', TestModel::class);
4948

50-
$user = factory(User::class)->create();
51-
$model = factory(TestModel::class)->create(
49+
$user = UserFactory::new()->create();
50+
$model = TestModelFactory::new()->create(
5251
[
5352
'user_id' => $user->getKey(),
5453
]
5554
);
5655

57-
$this->assertFalse($rule->passes('attribute', $model->getKey()));
56+
self::assertFalse($rule->passes('attribute', $model->getKey()));
5857
}
5958

6059
/** @test */
6160
public function it_will_return_false_if_the_model_is_not_found()
6261
{
6362
$rule = new Authorized('edit', TestModel::class);
6463

65-
$user = factory(User::class)->create();
66-
$model = factory(TestModel::class)->create(
64+
/*$user = UserFactory::new()->create();
65+
$model = TestModelFactory::new()->create(
6766
[
6867
'user_id' => $user->getKey(),
6968
]
70-
);
69+
);*/
7170

72-
$this->assertFalse($rule->passes('attribute', '2'));
71+
self::assertFalse($rule->passes('attribute', '2'));
7372
}
7473

7574
/** @test */
7675
public function it_will_return_false_if_the_gate_returns_false()
7776
{
7877
$rule = new Authorized('edit', TestModel::class);
7978

80-
$user = factory(User::class)->create();
81-
$model = factory(TestModel::class)->create(
82-
['user_id' => 2]
83-
);
79+
/* $user = UserFactory::new()->create();
80+
$model = TestModelFactory::new()->create(
81+
['user_id' => 2]
82+
);*/
8483

85-
$this->assertFalse($rule->passes('attribute', '1'));
84+
self::assertFalse($rule->passes('attribute', '1'));
8685
}
8786

8887
/** @test */
@@ -98,6 +97,6 @@ public function it_passes_attribute_ability_and_class_name_to_the_validation_mes
9897

9998
$rule->passes('name_field', 'John Doe');
10099

101-
$this->assertEquals('name_field edit and TestModel', $rule->message());
100+
self::assertEquals('name_field edit and TestModel', $rule->message());
102101
}
103102
}

tests/TestClasses/Models/CasterCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CasterCollection extends Model
2121
use HasCasts;
2222

2323
public $timestamps = false;
24-
protected $keyType = 'uuid';
24+
protected $keyType = 'string';
2525
protected $table = 'test_table_caster';
2626

2727
protected $casts = [

tests/TestClasses/Models/CasterDirtyCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CasterDirtyCollection extends Model
2121
use HasCasts;
2222

2323
public $timestamps = false;
24-
protected $keyType = 'uuid';
24+
protected $keyType = 'string';
2525
protected $table = 'test_table_caster';
2626

2727
protected $casts = [

0 commit comments

Comments
 (0)