mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81d5b223ff | ||
|
|
ce24d4b013 | ||
|
|
edfb05621c | ||
|
|
f0e4cf5e78 | ||
|
|
5d9925bab8 | ||
|
|
9e50460017 | ||
|
|
b55769213c |
@@ -3,6 +3,7 @@ name: normalize composer.json
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
|
- .github/workflows/composer-normalize.yml
|
||||||
- composer.json
|
- composer.json
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -18,6 +19,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Normalize composer.json
|
- name: Normalize composer.json
|
||||||
run: |
|
run: |
|
||||||
|
composer global config --no-plugins allow-plugins.ergebnis/composer-normalize true
|
||||||
composer global require ergebnis/composer-normalize
|
composer global require ergebnis/composer-normalize
|
||||||
composer normalize
|
composer normalize
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ jobs:
|
|||||||
COMPOSER_NO_INTERACTION: 1
|
COMPOSER_NO_INTERACTION: 1
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
php: [8.1, 8.0, 7.4, 7.3]
|
php: [8.2, 8.1, 8.0, 7.4, 7.3]
|
||||||
lumen: [8.*]
|
lumen: [8.*]
|
||||||
name: P${{ matrix.php }} - Lumen${{ matrix.lumen }}
|
name: P${{ matrix.php }} - Lumen${{ matrix.lumen }}
|
||||||
steps:
|
steps:
|
||||||
@@ -37,6 +37,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
composer create-project --prefer-dist laravel/lumen:${{ matrix.lumen }} --no-progress sample
|
composer create-project --prefer-dist laravel/lumen:${{ matrix.lumen }} --no-progress sample
|
||||||
cd sample
|
cd sample
|
||||||
|
composer config minimum-stability dev
|
||||||
composer require "league/flysystem:^1" --no-update --no-progress
|
composer require "league/flysystem:^1" --no-update --no-progress
|
||||||
composer update --prefer-stable --prefer-dist --no-progress
|
composer update --prefer-stable --prefer-dist --no-progress
|
||||||
|
|
||||||
@@ -81,9 +82,17 @@ jobs:
|
|||||||
COMPOSER_NO_INTERACTION: 1
|
COMPOSER_NO_INTERACTION: 1
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
php: [8.1, 8.0, 7.4, 7.3]
|
php: [8.2, 8.1, 8.0, 7.4, 7.3]
|
||||||
laravel: [9.*, 8.*]
|
laravel: [10.*, 9.*, 8.*]
|
||||||
exclude:
|
exclude:
|
||||||
|
- php: 8.0
|
||||||
|
laravel: 10.*
|
||||||
|
- php: 7.4
|
||||||
|
laravel: 10.*
|
||||||
|
- php: 7.4
|
||||||
|
laravel: 10.*
|
||||||
|
- php: 7.3
|
||||||
|
laravel: 10.*
|
||||||
- php: 7.4
|
- php: 7.4
|
||||||
laravel: 9.*
|
laravel: 9.*
|
||||||
- php: 7.3
|
- php: 7.3
|
||||||
@@ -103,8 +112,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
composer create-project --prefer-dist laravel/laravel:${{ matrix.laravel }} --no-progress sample
|
composer create-project --prefer-dist laravel/laravel:${{ matrix.laravel }} --stability=dev --no-progress sample
|
||||||
cd sample
|
cd sample
|
||||||
|
composer config minimum-stability dev
|
||||||
composer update --prefer-stable --prefer-dist --no-progress
|
composer update --prefer-stable --prefer-dist --no-progress
|
||||||
|
|
||||||
- name: Add package from source
|
- name: Add package from source
|
||||||
|
|||||||
@@ -21,9 +21,15 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-20.04, windows-2019]
|
os: [ubuntu-20.04, windows-2019]
|
||||||
php: [8.1, 8.0, 7.4, 7.3]
|
php: [8.1, 8.0, 7.4, 7.3]
|
||||||
laravel: [8.*, 9.*]
|
laravel: [8.*, 9.*, 10.*]
|
||||||
dependency-version: [prefer-lowest, prefer-stable]
|
dependency-version: [prefer-lowest, prefer-stable]
|
||||||
exclude:
|
exclude:
|
||||||
|
- php: 8.0
|
||||||
|
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
|
- php: 7.4
|
||||||
|
|||||||
@@ -11,9 +11,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Fix issue where \Eloquent is not included when using write_mixin [#1352 / Jefemy](https://github.com/barryvdh/laravel-ide-helper/pull/1352)
|
- Fix issue where \Eloquent is not included when using write_mixin [#1352 / Jefemy](https://github.com/barryvdh/laravel-ide-helper/pull/1352)
|
||||||
- Fix model factory method arguments for Laravel >= 9 [#1361 / wimski](https://github.com/barryvdh/laravel-ide-helper/pull/1361)
|
- Fix model factory method arguments for Laravel >= 9 [#1361 / wimski](https://github.com/barryvdh/laravel-ide-helper/pull/1361)
|
||||||
- Improve return type of mock helper methods in tests [#1405 / bentleyo](https://github.com/barryvdh/laravel-ide-helper/pull/1405)
|
- Improve return type of mock helper methods in tests [#1405 / bentleyo](https://github.com/barryvdh/laravel-ide-helper/pull/1405)
|
||||||
|
- Fix Castable class if failed to detect it from return types [#1388 / kwarcu](https://github.com/barryvdh/laravel-ide-helper/pull/1388)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
- Added Laravel 10 support [#1407 / lptn](https://github.com/barryvdh/laravel-ide-helper/pull/1407)
|
||||||
- Add support for custom casts that implement `CastsInboundAttributes` [#1329 / sforward](https://github.com/barryvdh/laravel-ide-helper/pull/1329)
|
- Add support for custom casts that implement `CastsInboundAttributes` [#1329 / sforward](https://github.com/barryvdh/laravel-ide-helper/pull/1329)
|
||||||
|
- Add option `use_generics_annotations` for collection type hints [#1298 / tanerkay](https://github.com/barryvdh/laravel-ide-helper/pull/1298)
|
||||||
|
|
||||||
2022-03-06, 2.12.3
|
2022-03-06, 2.12.3
|
||||||
------------------
|
------------------
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Laravel IDE Helper Generator
|
# IDE Helper Generator for Laravel
|
||||||
|
|
||||||
[](https://github.com/barryvdh/laravel-ide-helper/actions)
|
[](https://github.com/barryvdh/laravel-ide-helper/actions)
|
||||||
[](http://choosealicense.com/licenses/mit/)
|
[](http://choosealicense.com/licenses/mit/)
|
||||||
@@ -227,6 +227,12 @@ You may use the [`::withCount`](https://laravel.com/docs/master/eloquent-relatio
|
|||||||
|
|
||||||
By default, these attributes are generated in the phpdoc. You can turn them off by setting the config `write_model_relation_count_properties` to `false`.
|
By default, these attributes are generated in the phpdoc. You can turn them off by setting the config `write_model_relation_count_properties` to `false`.
|
||||||
|
|
||||||
|
#### Generics annotations
|
||||||
|
|
||||||
|
Laravel 9 introduced generics annotations in DocBlocks for collections. PhpStorm 2022.3 and above support the use of generics annotations within `@property` and `@property-read` declarations in DocBlocks, e.g. `Collection<User>` instead of `Collection|User[]`.
|
||||||
|
|
||||||
|
These can be disabled by setting the config `use_generics_annotations` to `false`.
|
||||||
|
|
||||||
#### Support `@comment` based on DocBlock
|
#### Support `@comment` based on DocBlock
|
||||||
|
|
||||||
In order to better support IDEs, relations and getters/setters can also add a comment to a property like table columns. Therefore a custom docblock `@comment` is used:
|
In order to better support IDEs, relations and getters/setters can also add a comment to a property like table columns. Therefore a custom docblock `@comment` is used:
|
||||||
|
|||||||
+7
-7
@@ -25,25 +25,25 @@
|
|||||||
"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",
|
"illuminate/console": "^8 || ^9 || ^10",
|
||||||
"illuminate/filesystem": "^8 || ^9",
|
"illuminate/filesystem": "^8 || ^9 || ^10",
|
||||||
"illuminate/support": "^8 || ^9",
|
"illuminate/support": "^8 || ^9 || ^10",
|
||||||
"nikic/php-parser": "^4.7",
|
"nikic/php-parser": "^4.7",
|
||||||
"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": "^2",
|
||||||
"illuminate/config": "^8 || ^9",
|
"illuminate/config": "^8 || ^9 || ^10",
|
||||||
"illuminate/view": "^8 || ^9",
|
"illuminate/view": "^8 || ^9 || ^10",
|
||||||
"mockery/mockery": "^1.4",
|
"mockery/mockery": "^1.4",
|
||||||
"orchestra/testbench": "^6 || ^7",
|
"orchestra/testbench": "^6 || ^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": "^3.12"
|
"vimeo/psalm": "^3.12"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"illuminate/events": "Required for automatic helper generation (^6|^7|^8|^9)."
|
"illuminate/events": "Required for automatic helper generation (^6|^7|^8|^9|^10)."
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
|
|||||||
@@ -292,6 +292,17 @@ return [
|
|||||||
*/
|
*/
|
||||||
'force_fqn' => false,
|
'force_fqn' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Use generics syntax
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Use generics syntax within DocBlocks,
|
||||||
|
| e.g. `Collection<User>` instead of `Collection|User[]`.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'use_generics_annotations' => true,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Additional relation types
|
| Additional relation types
|
||||||
|
|||||||
@@ -713,9 +713,10 @@ class ModelsCommand extends Command
|
|||||||
$model,
|
$model,
|
||||||
$collectionClass
|
$collectionClass
|
||||||
);
|
);
|
||||||
|
$collectionTypeHint = $this->getCollectionTypeHint($collectionClassNameInModel, $relatedModel);
|
||||||
$this->setProperty(
|
$this->setProperty(
|
||||||
$method,
|
$method,
|
||||||
$collectionClassNameInModel . '|' . $relatedModel . '[]',
|
$collectionTypeHint,
|
||||||
true,
|
true,
|
||||||
null,
|
null,
|
||||||
$comment
|
$comment
|
||||||
@@ -1080,6 +1081,23 @@ class ModelsCommand extends Command
|
|||||||
return '\\' . get_class($model->newCollection());
|
return '\\' . get_class($model->newCollection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine a model classes' collection type hint.
|
||||||
|
*
|
||||||
|
* @param string $collectionClassNameInModel
|
||||||
|
* @param string $relatedModel
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getCollectionTypeHint(string $collectionClassNameInModel, string $relatedModel): string
|
||||||
|
{
|
||||||
|
$useGenericsSyntax = $this->laravel['config']->get('ide-helper.use_generics_annotations', true);
|
||||||
|
if ($useGenericsSyntax) {
|
||||||
|
return $collectionClassNameInModel . '<int, ' . $relatedModel . '>';
|
||||||
|
} else {
|
||||||
|
return $collectionClassNameInModel . '|' . $relatedModel . '[]';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the available relation types
|
* Returns the available relation types
|
||||||
*/
|
*/
|
||||||
@@ -1277,8 +1295,9 @@ class ModelsCommand extends Command
|
|||||||
if ($collectionClass !== '\\' . \Illuminate\Database\Eloquent\Collection::class) {
|
if ($collectionClass !== '\\' . \Illuminate\Database\Eloquent\Collection::class) {
|
||||||
$collectionClassInModel = $this->getClassNameInDestinationFile($model, $collectionClass);
|
$collectionClassInModel = $this->getClassNameInDestinationFile($model, $collectionClass);
|
||||||
|
|
||||||
$this->setMethod('get', $collectionClassInModel . '|static[]', ['$columns = [\'*\']']);
|
$collectionTypeHint = $this->getCollectionTypeHint($collectionClassInModel, 'static');
|
||||||
$this->setMethod('all', $collectionClassInModel . '|static[]', ['$columns = [\'*\']']);
|
$this->setMethod('get', $collectionTypeHint, ['$columns = [\'*\']']);
|
||||||
|
$this->setMethod('all', $collectionTypeHint, ['$columns = [\'*\']']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1328,7 +1347,7 @@ class ModelsCommand extends Command
|
|||||||
|
|
||||||
return $this->getReturnTypeFromReflection($methodReflection) ??
|
return $this->getReturnTypeFromReflection($methodReflection) ??
|
||||||
$this->getReturnTypeFromDocBlock($methodReflection, $reflection) ??
|
$this->getReturnTypeFromDocBlock($methodReflection, $reflection) ??
|
||||||
'mixed';
|
$type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|||||||
* This is second line, success too.
|
* This is second line, success too.
|
||||||
* @property-read string $many_format_comment There is format comment, success.
|
* @property-read string $many_format_comment There is format comment, success.
|
||||||
* @property-read string $not_comment
|
* @property-read string $not_comment
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|Simple[] $relationHasMany HasMany relations.
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Simple> $relationHasMany HasMany relations.
|
||||||
* @property-read int|null $relation_has_many_count
|
* @property-read int|null $relation_has_many_count
|
||||||
* @property-read Simple|null $relationHasOne Others relations.
|
* @property-read Simple|null $relationHasOne Others relations.
|
||||||
* @property-read Model|\Eloquent $relationMorphTo MorphTo relations.
|
* @property-read Model|\Eloquent $relationMorphTo MorphTo relations.
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Models\Simple
|
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Models\Simple
|
||||||
*
|
*
|
||||||
* @property integer $id
|
* @property integer $id
|
||||||
* @property-read SimpleCollection|Simple[] $relationHasMany
|
* @property-read SimpleCollection<int, Simple> $relationHasMany
|
||||||
* @property-read int|null $relation_has_many_count
|
* @property-read int|null $relation_has_many_count
|
||||||
* @method static SimpleCollection|static[] all($columns = ['*'])
|
* @method static SimpleCollection<int, static> all($columns = ['*'])
|
||||||
* @method static SimpleCollection|static[] get($columns = ['*'])
|
* @method static SimpleCollection<int, static> get($columns = ['*'])
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Simple newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|Simple newQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Simple query()
|
* @method static \Illuminate\Database\Eloquent\Builder|Simple query()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Relations\HasOne;
|
|||||||
/**
|
/**
|
||||||
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DynamicRelations\Models\Dynamic
|
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DynamicRelations\Models\Dynamic
|
||||||
*
|
*
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|Dynamic[] $regularHasMany
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Dynamic> $regularHasMany
|
||||||
* @property-read int|null $regular_has_many_count
|
* @property-read int|null $regular_has_many_count
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Dynamic newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|Dynamic newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Dynamic newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|Dynamic newQuery()
|
||||||
|
|||||||
+1
-1
@@ -84,7 +84,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* @property string $macaddress_not_nullable
|
* @property string $macaddress_not_nullable
|
||||||
* @property \Illuminate\Support\Carbon|null $created_at
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post[] $posts
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post> $posts
|
||||||
* @property-read int|null $posts_count
|
* @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 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 newQuery()
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ use Illuminate\Support\Carbon;
|
|||||||
* @property string $macaddress_not_nullable
|
* @property string $macaddress_not_nullable
|
||||||
* @property Carbon|null $created_at
|
* @property Carbon|null $created_at
|
||||||
* @property Carbon|null $updated_at
|
* @property Carbon|null $updated_at
|
||||||
* @property-read Collection|Post[] $posts
|
* @property-read Collection<int, Post> $posts
|
||||||
* @property-read int|null $posts_count
|
* @property-read int|null $posts_count
|
||||||
* @method static EloquentBuilder|Post newModelQuery()
|
* @method static EloquentBuilder|Post newModelQuery()
|
||||||
* @method static EloquentBuilder|Post newQuery()
|
* @method static EloquentBuilder|Post newQuery()
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenericsSyntaxDisabled\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class Simple extends Model
|
||||||
|
{
|
||||||
|
// Regular relations
|
||||||
|
public function regularHasMany(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Simple::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function regularBelongsToMany(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Simple::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenericsSyntaxDisabled;
|
||||||
|
|
||||||
|
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
|
||||||
|
|
||||||
|
class Test extends AbstractModelsCommand
|
||||||
|
{
|
||||||
|
protected function getEnvironmentSetUp($app)
|
||||||
|
{
|
||||||
|
parent::getEnvironmentSetUp($app);
|
||||||
|
|
||||||
|
$app['config']->set('ide-helper.use_generics_annotations', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test(): void
|
||||||
|
{
|
||||||
|
$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->assertMatchesMockedSnapshot();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenericsSyntaxDisabled\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenericsSyntaxDisabled\Models\Simple
|
||||||
|
*
|
||||||
|
* @property integer $id
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|Simple[] $regularBelongsToMany
|
||||||
|
* @property-read int|null $regular_belongs_to_many_count
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|Simple[] $regularHasMany
|
||||||
|
* @property-read int|null $regular_has_many_count
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|Simple newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|Simple query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|Simple whereId($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class Simple extends Model
|
||||||
|
{
|
||||||
|
// Regular relations
|
||||||
|
public function regularHasMany(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Simple::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function regularBelongsToMany(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Simple::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,7 +40,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
* @property SelfCastingCasterWithStaticDocblockReturn $casted_property_with_static_return_docblock_and_param
|
* @property SelfCastingCasterWithStaticDocblockReturn $casted_property_with_static_return_docblock_and_param
|
||||||
* @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $casted_property_with_castable
|
* @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $casted_property_with_castable
|
||||||
* @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $casted_property_with_anonymous_cast
|
* @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $casted_property_with_anonymous_cast
|
||||||
* @property mixed $casted_property_without_return_type
|
* @property CastableWithoutReturnType $casted_property_without_return_type
|
||||||
* @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $cast_without_property
|
* @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $cast_without_property
|
||||||
* @property mixed $cast_inbound_attribute
|
* @property mixed $cast_inbound_attribute
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|CustomCast newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|CustomCast newModelQuery()
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
* @property string $macaddress_not_nullable
|
* @property string $macaddress_not_nullable
|
||||||
* @property \Illuminate\Support\Carbon|null $created_at
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|Post[] $relationHasMany
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Post> $relationHasMany
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Post newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|Post newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Post newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|Post newQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Post query()
|
* @method static \Illuminate\Database\Eloquent\Builder|Post query()
|
||||||
|
|||||||
@@ -75,27 +75,27 @@ use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
|||||||
* @property integer $id
|
* @property integer $id
|
||||||
* @property-read Simple|null $relationBelongsTo
|
* @property-read Simple|null $relationBelongsTo
|
||||||
* @property-read AnotherModel|null $relationBelongsToInAnotherNamespace
|
* @property-read AnotherModel|null $relationBelongsToInAnotherNamespace
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|Simple[] $relationBelongsToMany
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Simple> $relationBelongsToMany
|
||||||
* @property-read int|null $relation_belongs_to_many_count
|
* @property-read int|null $relation_belongs_to_many_count
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|Simple[] $relationBelongsToManyWithSub
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Simple> $relationBelongsToManyWithSub
|
||||||
* @property-read int|null $relation_belongs_to_many_with_sub_count
|
* @property-read int|null $relation_belongs_to_many_with_sub_count
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|Simple[] $relationBelongsToManyWithSubAnother
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Simple> $relationBelongsToManyWithSubAnother
|
||||||
* @property-read int|null $relation_belongs_to_many_with_sub_another_count
|
* @property-read int|null $relation_belongs_to_many_with_sub_another_count
|
||||||
* @property-read AnotherModel|null $relationBelongsToSameNameAsColumn
|
* @property-read AnotherModel|null $relationBelongsToSameNameAsColumn
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|Simple[] $relationHasMany
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Simple> $relationHasMany
|
||||||
* @property-read int|null $relation_has_many_count
|
* @property-read int|null $relation_has_many_count
|
||||||
* @property-read Simple|null $relationHasOne
|
* @property-read Simple|null $relationHasOne
|
||||||
* @property-read Simple $relationHasOneWithDefault
|
* @property-read Simple $relationHasOneWithDefault
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|Simple[] $relationMorphMany
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Simple> $relationMorphMany
|
||||||
* @property-read int|null $relation_morph_many_count
|
* @property-read int|null $relation_morph_many_count
|
||||||
* @property-read Simple|null $relationMorphOne
|
* @property-read Simple|null $relationMorphOne
|
||||||
* @property-read Model|\Eloquent $relationMorphTo
|
* @property-read Model|\Eloquent $relationMorphTo
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|Simple[] $relationMorphedByMany
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Simple> $relationMorphedByMany
|
||||||
* @property-read int|null $relation_morphed_by_many_count
|
* @property-read int|null $relation_morphed_by_many_count
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|Simple[] $relationSampleRelationType
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Simple> $relationSampleRelationType
|
||||||
* @property-read int|null $relation_sample_relation_type_count
|
* @property-read int|null $relation_sample_relation_type_count
|
||||||
* @property-read Model|\Eloquent $relationSampleToAnyMorphedRelationType
|
* @property-read Model|\Eloquent $relationSampleToAnyMorphedRelationType
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|Simple[] $relationSampleToAnyRelationType
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Simple> $relationSampleToAnyRelationType
|
||||||
* @property-read int|null $relation_sample_to_any_relation_type_count
|
* @property-read int|null $relation_sample_to_any_relation_type_count
|
||||||
* @property-read Simple $relationSampleToManyRelationType
|
* @property-read Simple $relationSampleToManyRelationType
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery()
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use Illuminate\Database\Query\Builder;
|
|||||||
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\UnionTypes\Models\UnionTypeModel
|
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\UnionTypes\Models\UnionTypeModel
|
||||||
*
|
*
|
||||||
* @property-read string|int|null $foo
|
* @property-read string|int|null $foo
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|UnionTypeModel[] $withUnionTypeReturn
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, UnionTypeModel> $withUnionTypeReturn
|
||||||
* @property-read int|null $with_union_type_return_count
|
* @property-read int|null $with_union_type_return_count
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|UnionTypeModel newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|UnionTypeModel newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|UnionTypeModel newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|UnionTypeModel newQuery()
|
||||||
|
|||||||
Reference in New Issue
Block a user