Skip to content

Commit

Permalink
Merge branch 'master' into feat-docblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh committed Feb 19, 2024
2 parents 391872b + 02af2a2 commit 12222b1
Show file tree
Hide file tree
Showing 45 changed files with 27 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/composer-normalize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
normalize:
timeout-minutes: 15
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Git checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fix-code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
fix-style:
name: Fix Code Style
timeout-minutes: 15
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
COMPOSER_NO_INTERACTION: 1

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

jobs:
php-laravel-integration-tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes: 15
env:
COMPOSER_NO_INTERACTION: 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build:
timeout-minutes: 15
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019]
os: [ubuntu-22.04, windows-2019]
php: [8.3, 8.2, 8.1]
laravel: [10.*, 11.*]
stability: [prefer-lowest, prefer-stable]
dependency-version: [prefer-lowest, prefer-stable]
exclude:
- php: 8.1
laravel: 11.*
Expand Down
17 changes: 11 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ All notable changes to this project will be documented in this file.

### Fixed

### Changed
- Use of doctrine/dbal [#1512 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1512)
With this functionality gone, a few changes have been made:
- support for custom datatypes has been dropped (config `custom_db_types`) unknown data types default to `string` now and to fix the type, add a proper cast in Eloquent
- You _might_ have top-level dependency on doctrine/dbal. This may have been in the past due to ide-helper, we suggest to check if you still need it and remove it otherwise

### Added
- Support for Laravel 11 [#1520 / KentarouTakeda](https://github.com/barryvdh/laravel-ide-helper/pull/1520)

### Changed
- Merge --reset and --smart-reset, to always keep the text. Always skipp the classname [#1523 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1523)
- Use short types (`int` and `bool` instead of `integer` and `boolean`) [#1524 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1524)

### Removed
- Support for Laravel 9 and use of doctrine/dbal [#1512 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1512)
With this functionality gone, a few changes have been made:
- support for custom datatypes has been dropped (config `custom_db_types`) unknown data types default to `string` now and to fix the type, add a proper cast in Eloquent
- You _might_ have top-level dependency on doctrine/dbal. This may have been in the past due to ide-helper, we suggest to check if you still need it and remove it otherwise
- Minimum PHP version, due to Laravel 10, is now PHP 8.1

2024-02-15, 2.15.1
------------------

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-json": "*",
"barryvdh/reflection-docblock": "^2.1.1",
"composer/class-map-generator": "^1.0",
Expand All @@ -39,7 +39,7 @@
"illuminate/view": "^9 || ^10 || ^11",
"mockery/mockery": "^1.4",
"orchestra/testbench": "^8 || ^9",
"phpunit/phpunit": "^9 || ^10.5",
"phpunit/phpunit": "^10.5",
"spatie/phpunit-snapshot-assertions": "^4 || ^5",
"vimeo/psalm": "^5.4"
},
Expand Down
27 changes: 7 additions & 20 deletions src/Console/ModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ class ModelsCommand extends Command
protected $write_mixin = false;
protected $dirs = [];
protected $reset;
protected $keep_text;
protected $phpstorm_noinspections;
protected $write_model_external_builder_methods;
/**
Expand Down Expand Up @@ -152,11 +151,8 @@ public function handle()
);
$model = $this->argument('model');
$ignore = $this->option('ignore');
$this->reset = $this->option('reset');
$this->reset = $this->option('reset') || $this->option('smart-reset');
$this->phpstorm_noinspections = $this->option('phpstorm-noinspections');
if ($this->option('smart-reset')) {
$this->keep_text = $this->reset = true;
}
$this->write_model_magic_where = $this->laravel['config']->get('ide-helper.write_model_magic_where', true);
$this->write_model_external_builder_methods = $this->laravel['config']->get('ide-helper.write_model_external_builder_methods', true);
$this->write_model_relation_count_properties =
Expand Down Expand Up @@ -219,8 +215,8 @@ protected function getOptions()
"Write models to {$this->filename} and adds @mixin to each model, avoiding IDE duplicate declaration warnings",
],
['nowrite', 'N', InputOption::VALUE_NONE, 'Don\'t write to Model file'],
['reset', 'R', InputOption::VALUE_NONE, 'Remove the original phpdocs instead of appending'],
['smart-reset', 'r', InputOption::VALUE_NONE, 'Refresh the properties/methods list, but keep the text'],
['reset', 'R', InputOption::VALUE_NONE, 'Refresh the properties/methods list, but keep the text'],
['smart-reset', 'r', InputOption::VALUE_NONE, 'Deprecated: same as --reset'],
['phpstorm-noinspections', 'p', InputOption::VALUE_NONE,
'Add PhpFullyQualifiedNameUsageInspection and PhpUnnecessaryFullyQualifiedNameInspection PHPStorm ' .
'noinspection tags',
Expand Down Expand Up @@ -379,7 +375,7 @@ public function castPropertiesType($model)
break;
case 'boolean':
case 'bool':
$realType = 'boolean';
$realType = 'bool';
break;
case 'decimal':
case 'string':
Expand All @@ -395,7 +391,7 @@ public function castPropertiesType($model)
case 'int':
case 'integer':
case 'timestamp':
$realType = 'integer';
$realType = 'int';
break;
case 'real':
case 'double':
Expand Down Expand Up @@ -522,9 +518,9 @@ public function getPropertiesFromTable($model)
'integer', 'int', 'int4',
'smallint', 'int2',
'mediumint',
'bigint', 'int8' => 'integer',
'bigint', 'int8' => 'int',

'boolean', 'bool' => 'boolean',
'boolean', 'bool' => 'bool',

'float', 'real', 'float4',
'double', 'float8' => 'float',
Expand Down Expand Up @@ -892,15 +888,6 @@ protected function createPhpDocs($class)

if ($this->reset) {
$phpdoc->clearTags();
if (!$this->keep_text) {
$phpdoc->setSummary('');
$phpdoc->setDescription(null);
}
}

// Set default summary to classname
if (!$phpdoc->getSummary()) {
$phpdoc->setSummary($class);
}

$existingTags = $phpdoc->getTags();
Expand Down
7 changes: 0 additions & 7 deletions tests/Console/ModelsCommand/AdvancedCasts/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,11 @@

use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
use Illuminate\Foundation\Application;

class Test extends AbstractModelsCommand
{
public function test(): void
{
if (!version_compare(Application::VERSION, '8.28', '>=')) {
$this->markTestSkipped(
'This test only works in Laravel >= 8.28'
);
}

$command = $this->app->make(ModelsCommand::class);

$tester = $this->runCommand($command, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Models\AdvancedCast
*
* @property \Illuminate\Support\Carbon $cast_to_date_serialization
* @property \Illuminate\Support\Carbon $cast_to_datetime_serialization
* @property \Illuminate\Support\Carbon $cast_to_custom_datetime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AllowGlobDirectory\Services\Post\Models\Post
*
* @property int $id
* @property string|null $char_nullable
* @property string $char_not_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Attributes\Models\Simple
*
* @property int $id
* @property int $diverging_type_hinted_get_and_set
* @property string|null $name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use Illuminate\Database\Eloquent\Relations\MorphTo;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Comment\Models\Simple
*
* @property int $id
* @property string $both_same_name I'm a getter
* @property string $both_without_getter_comment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Models\Simple
*
* @property int $id
* @property-read SimpleCollection<int, Simple> $relationHasMany
* @property-read int|null $relation_has_many_count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomDate\Models\CustomDate
*
* @property \Carbon\CarbonImmutable|null $created_at
* @property \Carbon\CarbonImmutable|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder|CustomDate newModelQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DoesNotGeneratePhpdocWithExternalEloquentBuilder\Models{
/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DoesNotGeneratePhpdocWithExternalEloquentBuilder\Models\Post
*
* @property int $id
* @property string|null $char_nullable
* @property string $char_not_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use Illuminate\Database\Eloquent\Relations\HasOne;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DynamicRelations\Models\Dynamic
*
* @property-read \Illuminate\Database\Eloquent\Collection<int, Dynamic> $regularHasMany
* @property-read int|null $regular_has_many_count
* @method static \Illuminate\Database\Eloquent\Builder|Dynamic newModelQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models\ModelWithCustomNamespace
*
* @method static \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\CustomSpace\ModelWithCustomNamespaceFactory factory(mixed $count, mixed $state)
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithCustomNamespace newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithCustomNamespace newQuery()
Expand Down Expand Up @@ -41,8 +39,6 @@ protected static function newFactory()
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models\ModelWithFactory
*
* @method static \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Factories\ModelWithFactoryFactory factory(mixed $count, mixed $state)
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithFactory newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithFactory newQuery()
Expand All @@ -60,8 +56,6 @@ class ModelWithFactory extends Model
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(mixed $count, mixed $state)
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithNestedFactory newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithNestedFactory newQuery()
Expand All @@ -81,8 +75,6 @@ class ModelWithNestedFactory extends ModelWithFactory
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ class Test extends AbstractModelsCommand
{
public function test(): void
{
if (!version_compare(PHP_VERSION, '8.1', '>=')) {
$this->markTestSkipped(
'This test only works in PHP >= 8.1'
);
}

$command = $this->app->make(ModelsCommand::class);

$tester = $this->runCommand($command, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpDocWithEnumDefaults\Models\Post
*
* @property int $id
* @property string|null $char_nullable
* @property string $char_not_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdoc\Models\Post
*
* @property int $id
* @property string|null $char_nullable
* @property string $char_not_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post
*
* @property int $id
* @property string|null $charNullable
* @property string $charNotNullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocFinal\Models\Post
*
* @property int $id
* @property string|null $char_nullable
* @property string $char_not_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithExternalEloquentBuilder\Models{
/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithExternalEloquentBuilder\Models\Post
*
* @property int $id
* @property string|null $char_nullable
* @property string $char_not_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithExternalEloquentBuilderWithFqn\Models\Post
*
* @property int $id
* @property string|null $char_nullable
* @property string $char_not_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use Illuminate\Database\Eloquent\SoftDeletes;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post
*
* @property int $id
* @property string|null $char_nullable
* @property string $char_not_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
use Illuminate\Support\Carbon;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithFqn\Models\Post
*
* @property int $id
* @property string|null $char_nullable
* @property CastType $char_not_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithFqnInExternalFile\Models{
/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithFqnInExternalFile\Models\Post
*
* @property int $id
* @property string|null $char_nullable
* @property string $char_not_nullable
Expand Down
Loading

0 comments on commit 12222b1

Please sign in to comment.