mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-17 17:47:13 +00:00
Removed support for Laravel 8 and therefore for PHP < 8.0 (#1504)
* Removed support for Laravel 8 and therefore for PHP < 8.0 * Update php-cs-fixer to v3 * composer fix-style
This commit is contained in:
@@ -19,25 +19,13 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
php: [8.3, 8.2, 8.1, 8.0, 7.4, 7.3]
|
php: [8.3, 8.2, 8.1, 8.0]
|
||||||
laravel: [10.*, 9.*, 8.*]
|
laravel: [10.*, 9.*]
|
||||||
exclude:
|
exclude:
|
||||||
- php: 8.0
|
- php: 8.0
|
||||||
laravel: 10.*
|
laravel: 10.*
|
||||||
- php: 7.4
|
|
||||||
laravel: 10.*
|
|
||||||
- php: 7.3
|
|
||||||
laravel: 10.*
|
|
||||||
- php: 8.3
|
- php: 8.3
|
||||||
laravel: 9.*
|
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 }}
|
name: P${{ matrix.php }} - Laravel${{ matrix.laravel }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
|
|||||||
@@ -20,26 +20,14 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-20.04, windows-2019]
|
os: [ubuntu-20.04, windows-2019]
|
||||||
php: [8.3, 8.2, 8.1, 8.0, 7.4, 7.3]
|
php: [8.3, 8.2, 8.1, 8.0]
|
||||||
laravel: [8.*, 9.*, 10.*]
|
laravel: [9.*, 10.*]
|
||||||
dependency-version: [prefer-lowest, prefer-stable]
|
dependency-version: [prefer-lowest, prefer-stable]
|
||||||
exclude:
|
exclude:
|
||||||
- php: 8.0
|
- php: 8.0
|
||||||
laravel: 10.*
|
laravel: 10.*
|
||||||
- php: 7.4
|
|
||||||
laravel: 10.*
|
|
||||||
- php: 7.3
|
|
||||||
laravel: 10.*
|
|
||||||
- php: 8.0
|
- php: 8.0
|
||||||
dependency-version: prefer-lowest
|
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:
|
steps:
|
||||||
- name: Set git to use LF
|
- name: Set git to use LF
|
||||||
if: ${{ matrix.os == 'windows-2019' }}
|
if: ${{ matrix.os == 'windows-2019' }}
|
||||||
|
|||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
|
|
||||||
/.idea
|
/.idea
|
||||||
/.php_cs
|
/.php-cs-fixer.cache
|
||||||
/.php_cs.cache
|
/.php-cs-fixer.php
|
||||||
/.php_cs.tests.cache
|
/.php-cs-fixer.tests.cache
|
||||||
/composer.lock
|
/composer.lock
|
||||||
/vendor
|
/vendor
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ return [
|
|||||||
],
|
],
|
||||||
'return_type_declaration' => true,
|
'return_type_declaration' => true,
|
||||||
'short_scalar_cast' => true,
|
'short_scalar_cast' => true,
|
||||||
'single_blank_line_before_namespace' => true,
|
|
||||||
'single_trait_insert_per_statement' => true,
|
'single_trait_insert_per_statement' => true,
|
||||||
'ternary_operator_spaces' => true,
|
'ternary_operator_spaces' => true,
|
||||||
'visibility_required' => [
|
'visibility_required' => [
|
||||||
@@ -56,7 +55,7 @@ return [
|
|||||||
'no_unused_imports' => true,
|
'no_unused_imports' => true,
|
||||||
'single_quote' => true,
|
'single_quote' => true,
|
||||||
'space_after_semicolon' => true,
|
'space_after_semicolon' => true,
|
||||||
'trailing_comma_in_multiline_array' => true,
|
'trailing_comma_in_multiline' => true,
|
||||||
'trim_array_spaces' => true,
|
'trim_array_spaces' => true,
|
||||||
'unary_operator_spaces' => true,
|
'unary_operator_spaces' => true,
|
||||||
'whitespace_after_comma_in_array' => true,
|
'whitespace_after_comma_in_array' => true,
|
||||||
@@ -5,10 +5,10 @@ $finder = PhpCsFixer\Finder::create()
|
|||||||
->in(__DIR__)
|
->in(__DIR__)
|
||||||
->exclude('tests');
|
->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)
|
->setFinder($finder)
|
||||||
->setRules($config)
|
->setRules($config)
|
||||||
->setRiskyAllowed(true)
|
->setRiskyAllowed(true)
|
||||||
->setCacheFile(__DIR__ . '/.php_cs.cache');
|
->setCacheFile(__DIR__ . '/.php-cs-fixer.cache');
|
||||||
@@ -5,7 +5,7 @@ $finder = PhpCsFixer\Finder::create()
|
|||||||
->in(__DIR__ . '/tests')
|
->in(__DIR__ . '/tests')
|
||||||
->exclude('__snapshots__');
|
->exclude('__snapshots__');
|
||||||
|
|
||||||
$config = require __DIR__ . '/.php_cs.common.php';
|
$config = require __DIR__ . '/.php-cs-fixer.common.php';
|
||||||
|
|
||||||
// Additional rules for tests
|
// Additional rules for tests
|
||||||
$config = array_merge(
|
$config = array_merge(
|
||||||
@@ -15,8 +15,8 @@ $config = array_merge(
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return PhpCsFixer\Config::create()
|
return (new PhpCsFixer\Config())
|
||||||
->setFinder($finder)
|
->setFinder($finder)
|
||||||
->setRules($config)
|
->setRules($config)
|
||||||
->setRiskyAllowed(true)
|
->setRiskyAllowed(true)
|
||||||
->setCacheFile(__DIR__ . '/.php_cs.tests.cache');
|
->setCacheFile(__DIR__ . '/.php-cs-fixer.tests.cache');
|
||||||
@@ -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)
|
[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
|
2024-02-05, 2.14.0
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
This package generates helper files that enable your IDE to provide accurate autocompletion.
|
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.
|
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)
|
- [Installation](#installation)
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
|
|||||||
+9
-9
@@ -20,24 +20,24 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3 || ^8.0",
|
"php": "^8.0",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"barryvdh/reflection-docblock": "^2.0.6",
|
"barryvdh/reflection-docblock": "^2.0.6",
|
||||||
"composer/class-map-generator": "^1.0",
|
"composer/class-map-generator": "^1.0",
|
||||||
"doctrine/dbal": "^2.6 || ^3",
|
"doctrine/dbal": "^2.6 || ^3",
|
||||||
"illuminate/console": "^8 || ^9 || ^10",
|
"illuminate/console": "^9 || ^10",
|
||||||
"illuminate/filesystem": "^8 || ^9 || ^10",
|
"illuminate/filesystem": "^9 || ^10",
|
||||||
"illuminate/support": "^8 || ^9 || ^10",
|
"illuminate/support": "^9 || ^10",
|
||||||
"nikic/php-parser": "^4.18 || ^5",
|
"nikic/php-parser": "^4.18 || ^5",
|
||||||
"phpdocumentor/type-resolver": "^1.1.0"
|
"phpdocumentor/type-resolver": "^1.1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-pdo_sqlite": "*",
|
"ext-pdo_sqlite": "*",
|
||||||
"friendsofphp/php-cs-fixer": "^2",
|
"friendsofphp/php-cs-fixer": "^3",
|
||||||
"illuminate/config": "^8 || ^9 || ^10",
|
"illuminate/config": "^9 || ^10",
|
||||||
"illuminate/view": "^8 || ^9 || ^10",
|
"illuminate/view": "^9 || ^10",
|
||||||
"mockery/mockery": "^1.4",
|
"mockery/mockery": "^1.4",
|
||||||
"orchestra/testbench": "^6 || ^7 || ^8",
|
"orchestra/testbench": "^7 || ^8",
|
||||||
"phpunit/phpunit": "^8.5 || ^9",
|
"phpunit/phpunit": "^8.5 || ^9",
|
||||||
"spatie/phpunit-snapshot-assertions": "^3 || ^4",
|
"spatie/phpunit-snapshot-assertions": "^3 || ^4",
|
||||||
"vimeo/psalm": "^5.4"
|
"vimeo/psalm": "^5.4"
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
],
|
],
|
||||||
"fix-style": [
|
"fix-style": [
|
||||||
"php-cs-fixer fix",
|
"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",
|
"psalm-set-baseline": "psalm --set-baseline=psalm-baseline.xml",
|
||||||
"test": "phpunit",
|
"test": "phpunit",
|
||||||
|
|||||||
+2
-2
@@ -329,7 +329,7 @@ class Alias
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$method = new \ReflectionMethod($className, $name);
|
$method = new \ReflectionMethod($className, $name);
|
||||||
$class = new \ReflectionClass($className);
|
$class = new ReflectionClass($className);
|
||||||
|
|
||||||
if (!in_array($magic, $this->usedMethods)) {
|
if (!in_array($magic, $this->usedMethods)) {
|
||||||
if ($class !== $this->root) {
|
if ($class !== $this->root) {
|
||||||
@@ -348,7 +348,7 @@ class Alias
|
|||||||
protected function detectMethods()
|
protected function detectMethods()
|
||||||
{
|
{
|
||||||
foreach ($this->classes as $class) {
|
foreach ($this->classes as $class) {
|
||||||
$reflection = new \ReflectionClass($class);
|
$reflection = new ReflectionClass($class);
|
||||||
|
|
||||||
$methods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
|
$methods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
|
||||||
if ($methods) {
|
if ($methods) {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class GeneratorCommand extends Command
|
|||||||
/** @var \Illuminate\Config\Repository */
|
/** @var \Illuminate\Config\Repository */
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
/** @var \Illuminate\Filesystem\Filesystem */
|
/** @var Filesystem */
|
||||||
protected $files;
|
protected $files;
|
||||||
|
|
||||||
/** @var \Illuminate\View\Factory */
|
/** @var \Illuminate\View\Factory */
|
||||||
@@ -54,7 +54,7 @@ class GeneratorCommand extends Command
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Config\Repository $config
|
* @param \Illuminate\Config\Repository $config
|
||||||
* @param \Illuminate\Filesystem\Filesystem $files
|
* @param Filesystem $files
|
||||||
* @param \Illuminate\View\Factory $view
|
* @param \Illuminate\View\Factory $view
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ class ModelsCommand extends Command
|
|||||||
/**
|
/**
|
||||||
* cast the properties's type from $casts.
|
* cast the properties's type from $casts.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Database\Eloquent\Model $model
|
* @param Model $model
|
||||||
*/
|
*/
|
||||||
public function castPropertiesType($model)
|
public function castPropertiesType($model)
|
||||||
{
|
{
|
||||||
@@ -498,7 +498,7 @@ class ModelsCommand extends Command
|
|||||||
/**
|
/**
|
||||||
* Load the properties from the database table.
|
* Load the properties from the database table.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Database\Eloquent\Model $model
|
* @param Model $model
|
||||||
*
|
*
|
||||||
* @throws DBALException If custom field failed to register
|
* @throws DBALException If custom field failed to register
|
||||||
*/
|
*/
|
||||||
@@ -602,7 +602,7 @@ class ModelsCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Illuminate\Database\Eloquent\Model $model
|
* @param Model $model
|
||||||
*/
|
*/
|
||||||
public function getPropertiesFromMethods($model)
|
public function getPropertiesFromMethods($model)
|
||||||
{
|
{
|
||||||
@@ -777,7 +777,7 @@ class ModelsCommand extends Command
|
|||||||
'int|null',
|
'int|null',
|
||||||
true,
|
true,
|
||||||
false
|
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 (
|
} elseif (
|
||||||
@@ -1126,7 +1126,7 @@ class ModelsCommand extends Command
|
|||||||
return '\Illuminate\Database\Eloquent\Collection';
|
return '\Illuminate\Database\Eloquent\Collection';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var \Illuminate\Database\Eloquent\Model $model */
|
/** @var Model $model */
|
||||||
$model = new $className();
|
$model = new $className();
|
||||||
return '\\' . get_class($model->newCollection());
|
return '\\' . get_class($model->newCollection());
|
||||||
}
|
}
|
||||||
@@ -1285,7 +1285,7 @@ class ModelsCommand extends Command
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates methods provided by the SoftDeletes trait
|
* Generates methods provided by the SoftDeletes trait
|
||||||
* @param \Illuminate\Database\Eloquent\Model $model
|
* @param Model $model
|
||||||
*/
|
*/
|
||||||
protected function getSoftDeleteMethods($model)
|
protected function getSoftDeleteMethods($model)
|
||||||
{
|
{
|
||||||
@@ -1302,7 +1302,7 @@ class ModelsCommand extends Command
|
|||||||
/**
|
/**
|
||||||
* Generate factory method from "HasFactory" trait.
|
* Generate factory method from "HasFactory" trait.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Database\Eloquent\Model $model
|
* @param Model $model
|
||||||
*/
|
*/
|
||||||
protected function getFactoryMethods($model)
|
protected function getFactoryMethods($model)
|
||||||
{
|
{
|
||||||
@@ -1330,16 +1330,12 @@ class ModelsCommand extends Command
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version_compare($this->laravel->version(), '9', '>=')) {
|
$this->setMethod('factory', $factory, ['$count = null, $state = []']);
|
||||||
$this->setMethod('factory', $factory, ['$count = null, $state = []']);
|
|
||||||
} else {
|
|
||||||
$this->setMethod('factory', $factory, ['...$parameters']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates methods that return collections
|
* Generates methods that return collections
|
||||||
* @param \Illuminate\Database\Eloquent\Model $model
|
* @param Model $model
|
||||||
*/
|
*/
|
||||||
protected function getCollectionMethods($model)
|
protected function getCollectionMethods($model)
|
||||||
{
|
{
|
||||||
@@ -1382,7 +1378,7 @@ class ModelsCommand extends Command
|
|||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
$reflection = new \ReflectionClass($type);
|
$reflection = new ReflectionClass($type);
|
||||||
|
|
||||||
if (!$reflection->implementsInterface(Castable::class)) {
|
if (!$reflection->implementsInterface(Castable::class)) {
|
||||||
return $type;
|
return $type;
|
||||||
@@ -1414,7 +1410,7 @@ class ModelsCommand extends Command
|
|||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
$reflection = new \ReflectionClass($type);
|
$reflection = new ReflectionClass($type);
|
||||||
|
|
||||||
if (!$reflection->implementsInterface(CastsAttributes::class)) {
|
if (!$reflection->implementsInterface(CastsAttributes::class)) {
|
||||||
return $type;
|
return $type;
|
||||||
@@ -1620,7 +1616,7 @@ class ModelsCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Illuminate\Database\Eloquent\Model $model
|
* @param Model $model
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
|
|||||||
+2
-2
@@ -26,7 +26,7 @@ class Generator
|
|||||||
/** @var \Illuminate\View\Factory */
|
/** @var \Illuminate\View\Factory */
|
||||||
protected $view;
|
protected $view;
|
||||||
|
|
||||||
/** @var \Symfony\Component\Console\Output\OutputInterface */
|
/** @var OutputInterface */
|
||||||
protected $output;
|
protected $output;
|
||||||
|
|
||||||
protected $extra = [];
|
protected $extra = [];
|
||||||
@@ -37,7 +37,7 @@ class Generator
|
|||||||
/**
|
/**
|
||||||
* @param \Illuminate\Config\Repository $config
|
* @param \Illuminate\Config\Repository $config
|
||||||
* @param \Illuminate\View\Factory $view
|
* @param \Illuminate\View\Factory $view
|
||||||
* @param \Symfony\Component\Console\Output\OutputInterface $output
|
* @param OutputInterface $output
|
||||||
* @param string $helpers
|
* @param string $helpers
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
|||||||
@@ -16,15 +16,15 @@ class GenerateModelHelper
|
|||||||
*/
|
*/
|
||||||
public static $shouldRun = false;
|
public static $shouldRun = false;
|
||||||
|
|
||||||
/** @var \Illuminate\Contracts\Console\Kernel */
|
/** @var Artisan */
|
||||||
protected $artisan;
|
protected $artisan;
|
||||||
|
|
||||||
/** @var \Illuminate\Contracts\Config\Repository */
|
/** @var Config */
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Illuminate\Contracts\Console\Kernel $artisan
|
* @param Artisan $artisan
|
||||||
* @param \Illuminate\Contracts\Config\Repository $config
|
* @param Config $config
|
||||||
*/
|
*/
|
||||||
public function __construct(Artisan $artisan, Config $config)
|
public function __construct(Artisan $artisan, Config $config)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ use Illuminate\Support\Str;
|
|||||||
|
|
||||||
class Method
|
class Method
|
||||||
{
|
{
|
||||||
/** @var \Barryvdh\Reflection\DocBlock */
|
/** @var DocBlock */
|
||||||
protected $phpdoc;
|
protected $phpdoc;
|
||||||
|
|
||||||
/** @var \ReflectionMethod */
|
/** @var \ReflectionMethod */
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class Simple extends Model
|
|||||||
* phpdoc is ignored here deliberately due to performance reasons and also
|
* phpdoc is ignored here deliberately due to performance reasons and also
|
||||||
* isn't supported by Laravel itself.
|
* isn't supported by Laravel itself.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Casts\Attribute
|
* @return Attribute
|
||||||
*/
|
*/
|
||||||
protected function notAnAttribute()
|
protected function notAnAttribute()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,15 +9,6 @@ use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
|||||||
|
|
||||||
class Test extends AbstractModelsCommand
|
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
|
public function test(): void
|
||||||
{
|
{
|
||||||
$command = $this->app->make(ModelsCommand::class);
|
$command = $this->app->make(ModelsCommand::class);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class Simple extends Model
|
|||||||
* phpdoc is ignored here deliberately due to performance reasons and also
|
* phpdoc is ignored here deliberately due to performance reasons and also
|
||||||
* isn't supported by Laravel itself.
|
* isn't supported by Laravel itself.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Casts\Attribute
|
* @return Attribute
|
||||||
*/
|
*/
|
||||||
protected function notAnAttribute()
|
protected function notAnAttribute()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,19 +17,11 @@ class Test extends AbstractModelsCommand
|
|||||||
'--write' => true,
|
'--write' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 80000) {
|
$errors = [
|
||||||
$errors = [
|
'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: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: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',
|
||||||
'Error resolving relation model of Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DynamicRelations\Models\Dynamic:dynamicHasOne() : Attempt to read property "created_at" on null',
|
];
|
||||||
];
|
|
||||||
} else {
|
|
||||||
$errors = [
|
|
||||||
"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",
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertSame(0, $tester->getStatusCode());
|
$this->assertSame(0, $tester->getStatusCode());
|
||||||
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
|
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
|
||||||
|
|||||||
@@ -8,41 +8,12 @@ use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
|
|||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Foundation\Application;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Test extends AbstractModelsCommand
|
class Test extends AbstractModelsCommand
|
||||||
{
|
{
|
||||||
public function test_8(): void
|
public function testFactory(): void
|
||||||
{
|
{
|
||||||
if (!version_compare(Application::VERSION, '8.2', '>=') || !version_compare(Application::VERSION, '9', '<')) {
|
|
||||||
$this->markTestSkipped(
|
|
||||||
'This test only works in Laravel >= 8.2 and < 9'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Factory::guessFactoryNamesUsing(static::getFactoryNameResolver());
|
|
||||||
|
|
||||||
$command = $this->app->make(ModelsCommand::class);
|
|
||||||
|
|
||||||
$tester = $this->runCommand($command, [
|
|
||||||
'--write' => true,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->assertSame(0, $tester->getStatusCode());
|
|
||||||
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
|
|
||||||
$this->assertStringNotContainsString('not found', $tester->getDisplay());
|
|
||||||
$this->assertMatchesMockedSnapshot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_9(): void
|
|
||||||
{
|
|
||||||
if (!version_compare(Application::VERSION, '9', '>=')) {
|
|
||||||
$this->markTestSkipped(
|
|
||||||
'This test only works in Laravel >= 9'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Factory::guessFactoryNamesUsing(static::getFactoryNameResolver());
|
Factory::guessFactoryNamesUsing(static::getFactoryNameResolver());
|
||||||
|
|
||||||
$command = $this->app->make(ModelsCommand::class);
|
$command = $this->app->make(ModelsCommand::class);
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models;
|
|
||||||
|
|
||||||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\CustomSpace\ModelWithCustomNamespaceFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models\ModelWithCustomNamespace
|
|
||||||
*
|
|
||||||
* @method static \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\CustomSpace\ModelWithCustomNamespaceFactory factory(...$parameters)
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithCustomNamespace newModelQuery()
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithCustomNamespace newQuery()
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithCustomNamespace query()
|
|
||||||
* @mixin \Eloquent
|
|
||||||
*/
|
|
||||||
class ModelWithCustomNamespace extends Model
|
|
||||||
{
|
|
||||||
use HasFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new factory instance for the model.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
|
||||||
*/
|
|
||||||
protected static function newFactory()
|
|
||||||
{
|
|
||||||
return ModelWithCustomNamespaceFactory::new();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models\ModelWithFactory
|
|
||||||
*
|
|
||||||
* @method static \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Factories\ModelWithFactoryFactory factory(...$parameters)
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithFactory newModelQuery()
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithFactory newQuery()
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithFactory query()
|
|
||||||
* @mixin \Eloquent
|
|
||||||
*/
|
|
||||||
class ModelWithFactory extends Model
|
|
||||||
{
|
|
||||||
use HasFactory;
|
|
||||||
}
|
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models\ModelWithNestedFactory
|
|
||||||
*
|
|
||||||
* @method static \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Factories\ModelWithNestedFactoryFactory factory(...$parameters)
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithNestedFactory newModelQuery()
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithNestedFactory newQuery()
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithNestedFactory query()
|
|
||||||
* @mixin \Eloquent
|
|
||||||
*/
|
|
||||||
class ModelWithNestedFactory extends ModelWithFactory
|
|
||||||
{
|
|
||||||
}
|
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models\ModelWithoutFactory
|
|
||||||
*
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithoutFactory newModelQuery()
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithoutFactory newQuery()
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithoutFactory query()
|
|
||||||
* @mixin \Eloquent
|
|
||||||
*/
|
|
||||||
class ModelWithoutFactory extends Model
|
|
||||||
{
|
|
||||||
use HasFactory;
|
|
||||||
}
|
|
||||||
+1
-1
@@ -11,7 +11,7 @@ class CastableReturnsAnonymousCaster implements Castable
|
|||||||
{
|
{
|
||||||
public static function castUsing(array $arguments)
|
public static function castUsing(array $arguments)
|
||||||
{
|
{
|
||||||
return new class() implements CastsAttributes {
|
return new class () implements CastsAttributes {
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
* @return CastedProperty
|
* @return CastedProperty
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class CastableWithoutReturnType implements Castable
|
|||||||
{
|
{
|
||||||
public static function castUsing(array $arguments)
|
public static function castUsing(array $arguments)
|
||||||
{
|
{
|
||||||
return new class() implements CastsAttributes {
|
return new class () implements CastsAttributes {
|
||||||
public function get($model, string $key, $value, array $attributes)
|
public function get($model, string $key, $value, array $attributes)
|
||||||
{
|
{
|
||||||
return new CastedProperty();
|
return new CastedProperty();
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ class CustomCasterWithDocblockReturnFqn implements CastsAttributes
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
* @return \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty
|
* @return CastedProperty
|
||||||
*/
|
*/
|
||||||
public function get($model, string $key, $value, array $attributes)
|
public function get($model, string $key, $value, array $attributes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,15 +9,6 @@ use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
|||||||
|
|
||||||
class Test extends AbstractModelsCommand
|
class Test extends AbstractModelsCommand
|
||||||
{
|
{
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
if (PHP_VERSION_ID < 80000) {
|
|
||||||
$this->markTestSkipped('This test requires PHP 8.0 or higher');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test(): void
|
public function test(): void
|
||||||
{
|
{
|
||||||
$command = $this->app->make(ModelsCommand::class);
|
$command = $this->app->make(ModelsCommand::class);
|
||||||
|
|||||||
+2
-6
@@ -190,10 +190,6 @@ class MacroTest extends TestCase
|
|||||||
|
|
||||||
public function testInitPhpDocParamsWithUnionTypes(): void
|
public function testInitPhpDocParamsWithUnionTypes(): void
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 80000) {
|
|
||||||
$this->markTestSkipped('This test requires PHP 8.0 or higher');
|
|
||||||
}
|
|
||||||
|
|
||||||
$phpdoc = (new MacroMock())->getPhpDoc(eval(<<<'PHP'
|
$phpdoc = (new MacroMock())->getPhpDoc(eval(<<<'PHP'
|
||||||
return new ReflectionFunction(
|
return new ReflectionFunction(
|
||||||
/**
|
/**
|
||||||
@@ -231,7 +227,7 @@ class MacroTest extends TestCase
|
|||||||
{
|
{
|
||||||
$reflectionMethod = new \ReflectionMethod(UrlGeneratorMacroClass::class, '__invoke');
|
$reflectionMethod = new \ReflectionMethod(UrlGeneratorMacroClass::class, '__invoke');
|
||||||
|
|
||||||
$macro = new Macro($reflectionMethod, UrlGenerator::class, new \ReflectionClass(UrlGenerator::class), 'macroName');
|
$macro = new Macro($reflectionMethod, UrlGenerator::class, new ReflectionClass(UrlGenerator::class), 'macroName');
|
||||||
|
|
||||||
$this->assertInstanceOf(Macro::class, $macro);
|
$this->assertInstanceOf(Macro::class, $macro);
|
||||||
}
|
}
|
||||||
@@ -243,7 +239,7 @@ class MacroTest extends TestCase
|
|||||||
{
|
{
|
||||||
$reflectionMethod = new \ReflectionMethod(UrlGeneratorMacroClass::class, '__invoke');
|
$reflectionMethod = new \ReflectionMethod(UrlGeneratorMacroClass::class, '__invoke');
|
||||||
|
|
||||||
$macro = new Macro($reflectionMethod, 'URL', new \ReflectionClass(UrlGenerator::class), 'macroName');
|
$macro = new Macro($reflectionMethod, 'URL', new ReflectionClass(UrlGenerator::class), 'macroName');
|
||||||
$output = <<<'DOC'
|
$output = <<<'DOC'
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user