Skip to content

Removed support for Laravel 8 and therefore for PHP < 8.0 #1504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions .github/workflows/run-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,13 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.3, 8.2, 8.1, 8.0, 7.4, 7.3]
laravel: [10.*, 9.*, 8.*]
php: [8.3, 8.2, 8.1, 8.0]
laravel: [10.*, 9.*]
exclude:
- php: 8.0
laravel: 10.*
- php: 7.4
laravel: 10.*
- php: 7.3
laravel: 10.*
- php: 8.3
laravel: 9.*
- php: 7.4
laravel: 9.*
- php: 7.3
laravel: 9.*
- php: 8.3
laravel: 8.*
- php: 8.2
laravel: 8.*
name: P${{ matrix.php }} - Laravel${{ matrix.laravel }}
steps:
- name: Checkout code
Expand Down
16 changes: 2 additions & 14 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,14 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04, windows-2019]
php: [8.3, 8.2, 8.1, 8.0, 7.4, 7.3]
laravel: [8.*, 9.*, 10.*]
php: [8.3, 8.2, 8.1, 8.0]
laravel: [9.*, 10.*]
dependency-version: [prefer-lowest, prefer-stable]
exclude:
- php: 8.0
laravel: 10.*
- php: 7.4
laravel: 10.*
- php: 7.3
laravel: 10.*
- php: 8.0
dependency-version: prefer-lowest
- php: 7.4
laravel: 9.*
- php: 7.3
laravel: 9.*
- os: windows-2019
php: 7.4
- os: windows-2019
php: 7.3
steps:
- name: Set git to use LF
if: ${{ matrix.os == 'windows-2019' }}
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.phpunit.result.cache

/.idea
/.php_cs
/.php_cs.cache
/.php_cs.tests.cache
/.php-cs-fixer.cache
/.php-cs-fixer.php
/.php-cs-fixer.tests.cache
Comment on lines -4 to +6
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the upgrade to php-cs-fixer v3, the default file names changed (and was required to be renamed), I therefore adapted all of them

/composer.lock
/vendor
3 changes: 1 addition & 2 deletions .php_cs.common.php → .php-cs-fixer.common.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
],
'return_type_declaration' => true,
'short_scalar_cast' => true,
'single_blank_line_before_namespace' => true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'single_trait_insert_per_statement' => true,
'ternary_operator_spaces' => true,
'visibility_required' => [
Expand All @@ -56,7 +55,7 @@
'no_unused_imports' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'trailing_comma_in_multiline_array' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
Expand Down
6 changes: 3 additions & 3 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
->in(__DIR__)
->exclude('tests');

$config = require __DIR__ . '/.php_cs.common.php';
$config = require __DIR__ . '/.php-cs-fixer.common.php';

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setFinder($finder)
->setRules($config)
->setRiskyAllowed(true)
->setCacheFile(__DIR__ . '/.php_cs.cache');
->setCacheFile(__DIR__ . '/.php-cs-fixer.cache');
6 changes: 3 additions & 3 deletions .php_cs.tests.php → .php-cs-fixer.tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
->in(__DIR__ . '/tests')
->exclude('__snapshots__');

$config = require __DIR__ . '/.php_cs.common.php';
$config = require __DIR__ . '/.php-cs-fixer.common.php';

// Additional rules for tests
$config = array_merge(
Expand All @@ -15,8 +15,8 @@
]
);

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setFinder($finder)
->setRules($config)
->setRiskyAllowed(true)
->setCacheFile(__DIR__ . '/.php_cs.tests.cache');
->setCacheFile(__DIR__ . '/.php-cs-fixer.tests.cache');
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
[Next release](https://github.com/barryvdh/laravel-ide-helper/compare/v2.14.0...master)
--------------

### Changed
- Removed support for Laravel 8 and therefore for PHP < 8.0 [#1504 / mfn](https://github.com/barryvdh/laravel-ide-helper/pull/1504)

2024-02-05, 2.14.0
------------------

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
This package generates helper files that enable your IDE to provide accurate autocompletion.
Generation is done based on the files in your project, so they are always up-to-date.

It supports Laravel 8+ and PHP 7.3+
It supports Laravel 9+ and PHP 8.0+

- [Installation](#installation)
- [Usage](#usage)
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"php": "^8.0",
"ext-json": "*",
"barryvdh/reflection-docblock": "^2.0.6",
"composer/class-map-generator": "^1.0",
"doctrine/dbal": "^2.6 || ^3",
"illuminate/console": "^8 || ^9 || ^10",
"illuminate/filesystem": "^8 || ^9 || ^10",
"illuminate/support": "^8 || ^9 || ^10",
"illuminate/console": "^9 || ^10",
"illuminate/filesystem": "^9 || ^10",
"illuminate/support": "^9 || ^10",
"nikic/php-parser": "^4.18 || ^5",
"phpdocumentor/type-resolver": "^1.1.0"
},
"require-dev": {
"ext-pdo_sqlite": "*",
"friendsofphp/php-cs-fixer": "^2",
"illuminate/config": "^8 || ^9 || ^10",
"illuminate/view": "^8 || ^9 || ^10",
"friendsofphp/php-cs-fixer": "^3",
"illuminate/config": "^9 || ^10",
"illuminate/view": "^9 || ^10",
"mockery/mockery": "^1.4",
"orchestra/testbench": "^6 || ^7 || ^8",
"orchestra/testbench": "^7 || ^8",
"phpunit/phpunit": "^8.5 || ^9",
"spatie/phpunit-snapshot-assertions": "^3 || ^4",
"vimeo/psalm": "^5.4"
Expand Down Expand Up @@ -81,7 +81,7 @@
],
"fix-style": [
"php-cs-fixer fix",
"php-cs-fixer fix --config=.php_cs.tests.php"
"php-cs-fixer fix --config=.php-cs-fixer.tests.php"
],
"psalm-set-baseline": "psalm --set-baseline=psalm-baseline.xml",
"test": "phpunit",
Expand Down
4 changes: 2 additions & 2 deletions src/Alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ protected function addMagicMethods()
continue;
}
$method = new \ReflectionMethod($className, $name);
$class = new \ReflectionClass($className);
$class = new ReflectionClass($className);

if (!in_array($magic, $this->usedMethods)) {
if ($class !== $this->root) {
Expand All @@ -348,7 +348,7 @@ protected function addMagicMethods()
protected function detectMethods()
{
foreach ($this->classes as $class) {
$reflection = new \ReflectionClass($class);
$reflection = new ReflectionClass($class);

$methods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
if ($methods) {
Expand Down
4 changes: 2 additions & 2 deletions src/Console/GeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class GeneratorCommand extends Command
/** @var \Illuminate\Config\Repository */
protected $config;

/** @var \Illuminate\Filesystem\Filesystem */
/** @var Filesystem */
protected $files;

/** @var \Illuminate\View\Factory */
Expand All @@ -54,7 +54,7 @@ class GeneratorCommand extends Command
/**
*
* @param \Illuminate\Config\Repository $config
* @param \Illuminate\Filesystem\Filesystem $files
* @param Filesystem $files
* @param \Illuminate\View\Factory $view
*/
public function __construct(
Expand Down
28 changes: 12 additions & 16 deletions src/Console/ModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ protected function loadModels()
/**
* cast the properties's type from $casts.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param Model $model
*/
public function castPropertiesType($model)
{
Expand Down Expand Up @@ -498,7 +498,7 @@ protected function getTypeOverride($type)
/**
* Load the properties from the database table.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param Model $model
*
* @throws DBALException If custom field failed to register
*/
Expand Down Expand Up @@ -602,7 +602,7 @@ public function getPropertiesFromTable($model)
}

/**
* @param \Illuminate\Database\Eloquent\Model $model
* @param Model $model
*/
public function getPropertiesFromMethods($model)
{
Expand Down Expand Up @@ -777,7 +777,7 @@ public function getPropertiesFromMethods($model)
'int|null',
true,
false
// What kind of comments should be added to the relation count here?
// What kind of comments should be added to the relation count here?
);
}
} elseif (
Expand Down Expand Up @@ -1126,7 +1126,7 @@ protected function getCollectionClass($className)
return '\Illuminate\Database\Eloquent\Collection';
}

/** @var \Illuminate\Database\Eloquent\Model $model */
/** @var Model $model */
$model = new $className();
return '\\' . get_class($model->newCollection());
}
Expand Down Expand Up @@ -1285,7 +1285,7 @@ protected function getReturnTypeFromReflection(\ReflectionMethod $reflection): ?

/**
* Generates methods provided by the SoftDeletes trait
* @param \Illuminate\Database\Eloquent\Model $model
* @param Model $model
*/
protected function getSoftDeleteMethods($model)
{
Expand All @@ -1302,7 +1302,7 @@ protected function getSoftDeleteMethods($model)
/**
* Generate factory method from "HasFactory" trait.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param Model $model
*/
protected function getFactoryMethods($model)
{
Expand Down Expand Up @@ -1330,16 +1330,12 @@ protected function getFactoryMethods($model)
return;
}

if (version_compare($this->laravel->version(), '9', '>=')) {
$this->setMethod('factory', $factory, ['$count = null, $state = []']);
} else {
$this->setMethod('factory', $factory, ['...$parameters']);
}
$this->setMethod('factory', $factory, ['$count = null, $state = []']);
}

/**
* Generates methods that return collections
* @param \Illuminate\Database\Eloquent\Model $model
* @param Model $model
*/
protected function getCollectionMethods($model)
{
Expand Down Expand Up @@ -1382,7 +1378,7 @@ protected function checkForCastableCasts(string $type, array $params = []): stri
return $type;
}

$reflection = new \ReflectionClass($type);
$reflection = new ReflectionClass($type);

if (!$reflection->implementsInterface(Castable::class)) {
return $type;
Expand Down Expand Up @@ -1414,7 +1410,7 @@ protected function checkForCustomLaravelCasts(string $type): ?string
return $type;
}

$reflection = new \ReflectionClass($type);
$reflection = new ReflectionClass($type);

if (!$reflection->implementsInterface(CastsAttributes::class)) {
return $type;
Expand Down Expand Up @@ -1620,7 +1616,7 @@ protected function getReflectionNamedType(ReflectionNamedType $paramType): strin
}

/**
* @param \Illuminate\Database\Eloquent\Model $model
* @param Model $model
* @throws \Illuminate\Contracts\Container\BindingResolutionException
* @throws \RuntimeException
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Generator
/** @var \Illuminate\View\Factory */
protected $view;

/** @var \Symfony\Component\Console\Output\OutputInterface */
/** @var OutputInterface */
protected $output;

protected $extra = [];
Expand All @@ -37,7 +37,7 @@ class Generator
/**
* @param \Illuminate\Config\Repository $config
* @param \Illuminate\View\Factory $view
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param OutputInterface $output
* @param string $helpers
*/
public function __construct(
Expand Down
8 changes: 4 additions & 4 deletions src/Listeners/GenerateModelHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ class GenerateModelHelper
*/
public static $shouldRun = false;

/** @var \Illuminate\Contracts\Console\Kernel */
/** @var Artisan */
protected $artisan;

/** @var \Illuminate\Contracts\Config\Repository */
/** @var Config */
protected $config;

/**
* @param \Illuminate\Contracts\Console\Kernel $artisan
* @param \Illuminate\Contracts\Config\Repository $config
* @param Artisan $artisan
* @param Config $config
*/
public function __construct(Artisan $artisan, Config $config)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

class Method
{
/** @var \Barryvdh\Reflection\DocBlock */
/** @var DocBlock */
protected $phpdoc;

/** @var \ReflectionMethod */
Expand Down
2 changes: 1 addition & 1 deletion tests/Console/ModelsCommand/Attributes/Models/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function (?string $name): ?string {
* phpdoc is ignored here deliberately due to performance reasons and also
* isn't supported by Laravel itself.
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
* @return Attribute
*/
protected function notAnAttribute()
{
Expand Down
9 changes: 0 additions & 9 deletions tests/Console/ModelsCommand/Attributes/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@

class Test extends AbstractModelsCommand
{
protected function setUp(): void
{
parent::setUp();

if (!class_exists('\Illuminate\Database\Eloquent\Casts\Attribute')) {
$this->markTestSkipped('This test requires Laravel 8.77 or newer');
}
}

public function test(): void
{
$command = $this->app->make(ModelsCommand::class);
Expand Down
Loading