[PHP8] Add initial compatibility (#1106)

* gha: run on PHP8 too

The composer.json constraint is unbound, so it's already "allowed" at least.

* gha: remove php-cs-fixer when running unit tests

- not necessary anyway
- not compatible with PHP8 currently

* gha: lumen 6 and 7 don't support PHP8

* composer.json: allow spatie/phpunit-snapshot-assertions 4.* for PHP8 compatibility

* php8-compat: Method ReflectionParameter::getClass() is deprecated

* php8-compat: adapt expected error message depending on PHP version

* composer.json: bump mockery to 1.3.3 minimum

This is the minimum version also supporting PHP8

* gha: disable prefer-lowest for PHP8

Some lower version requirements like doctrone/dbal won't work and
would require at least dbal 2.12.0, which in turn doesn't support PHP 7.2
anymore.

So instead of bumping dbal and excluding PHP 7.2 users, we ignore the
lowest version for PHP 8 for the time being.

* Update CHANGELOG.md
This commit is contained in:
Markus Podar
2020-12-04 07:28:07 +01:00
committed by GitHub
parent c4d1f780b0
commit b4138e5122
8 changed files with 36 additions and 10 deletions
+5 -1
View File
@@ -18,9 +18,13 @@ jobs:
COMPOSER_NO_INTERACTION: 1
strategy:
matrix:
php: [7.4, 7.3, 7.2]
php: [8.0, 7.4, 7.3, 7.2]
lumen: [8.*, 7.*, 6.*]
exclude:
- lumen: 6.*
php: 8.0
- lumen: 7.*
php: 8.0
- lumen: 8.*
php: 7.2
name: P${{ matrix.php }} - Lumen${{ matrix.lumen }}
+4 -1
View File
@@ -19,12 +19,14 @@ jobs:
strategy:
matrix:
php: [7.4, 7.3, 7.2]
php: [8.0, 7.4, 7.3, 7.2]
laravel: [8.*, 7.*, 6.*]
dependency-version: [prefer-lowest, prefer-stable]
exclude:
- laravel: 8.*
php: 7.2
- php: 8.0
dependency-version: prefer-lowest
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
@@ -42,6 +44,7 @@ jobs:
- name: Install dependencies
run: |
composer remove vimeo/psalm --no-update --dev
composer remove friendsofphp/php-cs-fixer --no-update --dev
composer require "laravel/framework:${{ matrix.laravel }}" --no-update --no-progress
composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress
+1
View File
@@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
- Fix phpdoc generate for custom cast with parameter [\#986 / artelkr](https://github.com/barryvdh/laravel-ide-helper/pull/986)
- Created a possibility to add custom relation type [\#987 / efinder2](https://github.com/barryvdh/laravel-ide-helper/pull/987)
- Added `@see` with macro/mixin definition location to PhpDoc [\#1054 / riesjart](https://github.com/barryvdh/laravel-ide-helper/pull/1054)
- Initial compatibility for PHP8 [\#1106 / mfn](https://github.com/barryvdh/laravel-ide-helper/pull/1106)
### Changed
- Implement DeferrableProvider [\#914 / kon-shou](https://github.com/barryvdh/laravel-ide-helper/pull/914)
+2 -2
View File
@@ -35,10 +35,10 @@
"friendsofphp/php-cs-fixer": "^2",
"illuminate/config": "^6 || ^7 || ^8",
"illuminate/view": "^6 || ^7 || ^8",
"mockery/mockery": "^1.3",
"mockery/mockery": "^1.3.3",
"orchestra/testbench": "^4 || ^5 || ^6",
"phpunit/phpunit": "^8.5 || ^9",
"spatie/phpunit-snapshot-assertions": "^1.4 || ^2.2 || ^3",
"spatie/phpunit-snapshot-assertions": "^1.4 || ^2.2 || ^3 || ^4",
"vimeo/psalm": "^3.12"
},
"config": {
+13 -3
View File
@@ -424,7 +424,7 @@ class ModelsCommand extends Command
$database = null;
if (strpos($table, '.')) {
list($database, $table) = explode('.', $table);
[$database, $table] = explode('.', $table);
}
$columns = $schema->listTableColumns($table, $database);
@@ -895,8 +895,18 @@ class ModelsCommand extends Command
$paramsWithDefault = [];
/** @var \ReflectionParameter $param */
foreach ($method->getParameters() as $param) {
$paramClass = $param->getClass();
$paramStr = (!is_null($paramClass) ? '\\' . $paramClass->getName() . ' ' : '') . '$' . $param->getName();
$paramType = $param->getType();
$paramStr = '$' . $param->getName();
if ($paramType) {
$paramTypeStr = $paramType->getName();
if (!$paramType->isBuiltin()) {
$paramTypeStr = '\\' . $paramTypeStr;
}
$paramStr = $paramTypeStr . ' ' . $paramStr;
}
if ($param->isOptional() && $param->isDefaultValueAvailable()) {
$default = $param->getDefaultValue();
if (is_bool($default)) {
@@ -17,11 +17,19 @@ class Test extends AbstractModelsCommand
'--write' => true,
]);
if (PHP_VERSION_ID >= 80000) {
$errors = <<<TXT
Error resolving relation model of Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DynamicRelations\Models\Dynamic:dynamicBelongsTo() : Attempt to read property "created_at" on null
Error resolving relation model of Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DynamicRelations\Models\Dynamic:dynamicHasMany() : Attempt to read property "created_at" on null
Error resolving relation model of Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DynamicRelations\Models\Dynamic:dynamicHasOne() : Attempt to read property "created_at" on null
TXT;
} else {
$errors = <<<TXT
Error resolving relation model of Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DynamicRelations\Models\Dynamic:dynamicBelongsTo() : Trying to get property 'created_at' of non-object
Error resolving relation model of Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DynamicRelations\Models\Dynamic:dynamicHasMany() : Trying to get property 'created_at' of non-object
Error resolving relation model of Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DynamicRelations\Models\Dynamic:dynamicHasOne() : Trying to get property 'created_at' of non-object
TXT;
}
$this->assertSame(0, $tester->getStatusCode());
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
@@ -88,7 +88,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property-read int|null $posts_count
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post null($unusedParam)
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post null(string $unusedParam)
* @method static \Illuminate\Database\Query\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post query()
* @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post whereBigIntegerNotNullable($value)
@@ -94,7 +94,7 @@ use Illuminate\Support\Carbon;
* @property-read int|null $posts_count
* @method static EloquentBuilder|Post newModelQuery()
* @method static EloquentBuilder|Post newQuery()
* @method static EloquentBuilder|Post null($unusedParam)
* @method static EloquentBuilder|Post null(string $unusedParam)
* @method static QueryBuilder|Post onlyTrashed()
* @method static EloquentBuilder|Post query()
* @method static EloquentBuilder|Post whereBigIntegerNotNullable($value)