Skip to content

Commit 878e2d6

Browse files
authored
Add PHP8 support (#23)
* Add PHP8 support * Remove PHP CS-Fixer
1 parent c2ed0c9 commit 878e2d6

File tree

8 files changed

+46
-106
lines changed

8 files changed

+46
-106
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
/tests export-ignore
44
/.gitattributes export-ignore
55
/.gitignore export-ignore
6-
/.php_cs export-ignore
76
/.styleci.yml export-ignore
87
/.travis.yml export-ignore
98
/CODE_OF_CONDUCT.md export-ignore

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
vendor/
2-
.php_cs.cache
32
.phpunit.result.cache
43
composer.lock
54
composer.phar

.php_cs

Lines changed: 0 additions & 64 deletions
This file was deleted.

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
language: php
22

33
php:
4-
- 7.0
54
- 7.1
65
- 7.2
76
- 7.3
7+
- 7.4
8+
- 8.0
89

910
env:
1011
global:
@@ -15,6 +16,9 @@ before_script:
1516
- if [[ $setup = 'basic' ]]; then travis_retry composer install --prefer-dist --no-interaction; fi
1617
- if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-stable; fi
1718
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable; fi
19+
- if [ $(phpenv version-name) = '7.3' ]; then composer require laravel/legacy-factories --dev; fi
20+
- if [ $(phpenv version-name) = '7.4' ]; then composer require laravel/legacy-factories --dev; fi
21+
- if [ $(phpenv version-name) = '8.0' ]; then composer require laravel/legacy-factories --dev; fi
1822

1923
script:
2024
- ./vendor/bin/phpunit -c phpunit.xml.dist --verbose

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ All notable changes to `cybercog/laravel-ownership` will be documented in this f
44

55
## [Unreleased]
66

7+
## [5.3.0] - 2020-12-31
8+
9+
### Added
10+
11+
- ([#22]) Added Laravel 6.x support
12+
- ([#22]) Added Laravel 7.x support
13+
- ([#22]) Added Laravel 8.x support
14+
- ([#23]) Added PHP 8.x support
15+
16+
### Removed
17+
18+
- ([#23]) Dropped PHP 5.6 support
19+
- ([#23]) Dropped PHP 7.0 support
20+
721
## [5.2.0] - 2018-09-09
822

923
### Added
@@ -101,4 +115,6 @@ All notable changes to `cybercog/laravel-ownership` will be documented in this f
101115
[2.0.0]: https://github.com/cybercog/laravel-ownership/compare/1.0.0...2.0.0
102116
[Upgrade instructions]: UPGRADING.md
103117

118+
[#23]: https://github.com/cybercog/laravel-ownership/pull/23
119+
[#22]: https://github.com/cybercog/laravel-ownership/pull/22
104120
[#19]: https://github.com/cybercog/laravel-ownership/pull/19

CONTRIBUTING.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ Due to time constraints, we are not always able to respond as quickly as we woul
1919

2020
## Coding Guidelines
2121

22-
This project comes with a configuration file for php-cs-fixer (.php_cs) that you can use to (re)format your sourcecode for compliance with this project's coding guidelines:
23-
24-
```shell script
25-
$ vendor/bin/php-cs-fixer fix
26-
```
22+
This project follows [PSR-12 coding style guide](https://www.php-fig.org/psr/psr-12/).
2723

2824
## PHPUnit tests
2925

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@
4040
"docs": "https://github.com/cybercog/laravel-ownership/wiki"
4141
},
4242
"require": {
43-
"php": "^5.6|^7.0",
43+
"php": "^7.1.3|^8.0",
4444
"illuminate/database": "^5.2|^6.0|^7.0|^8.0",
4545
"illuminate/support": "^5.2|^6.0|^7.0|^8.0"
4646
},
4747
"require-dev": {
48-
"friendsofphp/php-cs-fixer": "^2.10",
4948
"mockery/mockery": "^1.0",
50-
"orchestra/database": "~3.5.0|~3.6.0|~3.7.0",
51-
"orchestra/testbench": "~3.5.0|~3.6.0|~3.7.0",
52-
"phpunit/phpunit": "^6.0|^7.0"
49+
"orchestra/database": "^3.5|^4.0|^5.0|^6.0",
50+
"orchestra/testbench": "^3.5|^4.0|^5.0|^6.0",
51+
"phpunit/phpunit": "^6.0|^7.0|^8.0|^9.0"
5352
},
5453
"autoload": {
5554
"psr-4": {

tests/TestCase.php

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111

1212
namespace Cog\Tests\Laravel\Ownership;
1313

14+
use Cog\Laravel\Ownership\Providers\OwnershipServiceProvider;
1415
use Cog\Tests\Laravel\Ownership\Stubs\Models\Character;
1516
use Cog\Tests\Laravel\Ownership\Stubs\Models\User;
1617
use Illuminate\Database\Eloquent\Relations\Relation;
18+
use Illuminate\Foundation\Application;
19+
use Orchestra\Database\ConsoleServiceProvider;
1720
use Orchestra\Testbench\TestCase as Orchestra;
1821

1922
/**
@@ -26,38 +29,28 @@ abstract class TestCase extends Orchestra
2629
/**
2730
* Actions to be performed on PHPUnit start.
2831
*/
29-
protected function setUp()
32+
protected function setUp(): void
3033
{
3134
parent::setUp();
3235

3336
$this->registerMigrations();
3437
$this->migrateUnitTestTables();
3538
$this->registerPackageFactories();
3639
$this->registerTestMorphMaps();
37-
}
38-
39-
/**
40-
* Define environment setup.
41-
*
42-
* @param \Illuminate\Foundation\Application $app
43-
* @return void
44-
*/
45-
protected function getEnvironmentSetUp($app)
46-
{
47-
$this->setDefaultUserModel($app);
40+
$this->setDefaultUserModel();
4841
}
4942

5043
/**
5144
* Load package service provider.
5245
*
53-
* @param \Illuminate\Foundation\Application $app
46+
* @param Application $app
5447
* @return array
5548
*/
56-
protected function getPackageProviders($app)
49+
protected function getPackageProviders($app): array
5750
{
5851
return [
59-
\Cog\Laravel\Ownership\Providers\OwnershipServiceProvider::class,
60-
\Orchestra\Database\ConsoleServiceProvider::class,
52+
OwnershipServiceProvider::class,
53+
ConsoleServiceProvider::class,
6154
];
6255
}
6356

@@ -66,51 +59,49 @@ protected function getPackageProviders($app)
6659
*
6760
* @return void
6861
*/
69-
protected function registerMigrations()
62+
protected function registerMigrations(): void
7063
{
71-
$this->loadMigrationsFrom([
72-
'--realpath' => realpath(__DIR__ . '/database/migrations'),
73-
]);
64+
$this->loadMigrationsFrom(__DIR__ . '/database/migrations');
7465
}
7566

7667
/**
7768
* Perform unit test database migrations.
7869
*
7970
* @return void
8071
*/
81-
protected function migrateUnitTestTables()
72+
protected function migrateUnitTestTables(): void
8273
{
83-
$this->artisan('migrate');
74+
$this->artisan('migrate', ['--database' => 'sqlite'])->run();
8475
}
8576

8677
/**
8778
* Register package related model factories.
8879
*
8980
* @return void
9081
*/
91-
private function registerPackageFactories()
82+
private function registerPackageFactories(): void
9283
{
93-
$pathToFactories = realpath(__DIR__ . '/database/factories');
94-
$this->withFactories($pathToFactories);
84+
$this->withFactories(__DIR__ . '/database/factories');
9585
}
9686

9787
/**
9888
* Set default user model used by tests.
9989
*
100-
* @param $app
10190
* @return void
10291
*/
103-
private function setDefaultUserModel($app)
92+
private function setDefaultUserModel(): void
10493
{
105-
$app['config']->set('auth.providers.users.model', User::class);
94+
$this->app
95+
->make('config')
96+
->set('auth.providers.users.model', User::class);
10697
}
10798

10899
/**
109100
* Register morph map for test cases.
110101
*
111102
* @return void
112103
*/
113-
protected function registerTestMorphMaps()
104+
protected function registerTestMorphMaps(): void
114105
{
115106
Relation::morphMap([
116107
'character' => Character::class,

0 commit comments

Comments
 (0)