diff --git a/composer.json b/composer.json index cb2951a..613f565 100644 --- a/composer.json +++ b/composer.json @@ -18,10 +18,8 @@ }, "require-dev": { "barryvdh/laravel-ide-helper": "^3.0", - "larastan/larastan": "^2.9", "orchestra/testbench": "^9.0", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-phpunit": "^1.4", + "phpstan/phpstan": "^1.12", "phpunit/phpunit": "^11.0" }, "autoload": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index f3b5181..3e639cd 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,10 +1,4 @@ -includes: - - ./vendor/larastan/larastan/extension.neon - - ./vendor/phpstan/phpstan-mockery/extension.neon - - ./vendor/phpstan/phpstan-phpunit/extension.neon - - ./vendor/phpstan/phpstan-phpunit/rules.neon parameters: - level: max + level: 9 paths: - src - - tests diff --git a/src/IdeHelper/BelongsToThroughRelationsHook.php b/src/IdeHelper/BelongsToThroughRelationsHook.php index 56395da..1481d9d 100644 --- a/src/IdeHelper/BelongsToThroughRelationsHook.php +++ b/src/IdeHelper/BelongsToThroughRelationsHook.php @@ -43,7 +43,7 @@ public function run(ModelsCommand $command, Model $model): void } /** - * @param \Illuminate\Database\Eloquent\Relations\Relation<\Illuminate\Database\Eloquent\Model> $relationship + * @param \Illuminate\Database\Eloquent\Relations\Relation<*,*, *> $relationship */ protected function addRelationship(ModelsCommand $command, ReflectionMethod $method, Relation $relationship): void { diff --git a/src/IdeHelperServiceProvider.php b/src/IdeHelperServiceProvider.php index 64ee5b4..5db775b 100644 --- a/src/IdeHelperServiceProvider.php +++ b/src/IdeHelperServiceProvider.php @@ -11,7 +11,7 @@ class IdeHelperServiceProvider extends ServiceProvider implements DeferrableProv { public function register(): void { - /** @var \Illuminate\Contracts\Config\Repository $config */ + /** @var \Illuminate\Config\Repository $config */ $config = $this->app->get('config'); $config->set( @@ -24,7 +24,7 @@ public function register(): void } /** - * @return class-string<\Illuminate\Console\Command>[] + * @return list> */ public function provides(): array { diff --git a/src/Relations/BelongsToThrough.php b/src/Relations/BelongsToThrough.php index c81c9fb..20bcf77 100644 --- a/src/Relations/BelongsToThrough.php +++ b/src/Relations/BelongsToThrough.php @@ -10,13 +10,12 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Query\Expression; use Illuminate\Support\Str; -use RuntimeException; /** * @template TRelatedModel of \Illuminate\Database\Eloquent\Model * @template TDeclaringModel of \Illuminate\Database\Eloquent\Model - * - * @extends \Illuminate\Database\Eloquent\Relations\Relation + + * @extends \Illuminate\Database\Eloquent\Relations\Relation */ class BelongsToThrough extends Relation { @@ -253,7 +252,12 @@ public function first($columns = ['*']) return $this->query->first($columns); } - /** @inheritDoc */ + /** + * Execute the query as a "select" statement. + * + * @param list $columns + * @return \Illuminate\Database\Eloquent\Collection + */ public function get($columns = ['*']) { $columns = $this->query->getQuery()->columns ? [] : $columns; diff --git a/tests/IdeHelper/Models/Comment.php b/tests/IdeHelper/Models/Comment.php index f53f230..7a4a24f 100644 --- a/tests/IdeHelper/Models/Comment.php +++ b/tests/IdeHelper/Models/Comment.php @@ -10,9 +10,6 @@ class Comment extends Model { use BelongsToThroughTrait; - /** - * @return \Znck\Eloquent\Relations\BelongsToThrough<\Tests\IdeHelper\Models\Country, $this> - */ public function country(): BelongsToThroughRelation { return $this->belongsToThrough(Country::class, [User::class, Post::class]); diff --git a/tests/Models/Comment.php b/tests/Models/Comment.php index c5934b1..25f2e51 100644 --- a/tests/Models/Comment.php +++ b/tests/Models/Comment.php @@ -5,26 +5,15 @@ use Znck\Eloquent\Relations\BelongsToThrough; use Znck\Eloquent\Traits\HasTableAlias; -/** - * @property int $id - * - * @property-read \Tests\Models\Country|null $country - */ class Comment extends Model { use HasTableAlias; - /** - * @return \Znck\Eloquent\Relations\BelongsToThrough<\Tests\Models\Country, $this> - */ public function country(): BelongsToThrough { return $this->belongsToThrough(Country::class, [User::class, Post::class])->withDefault(); } - /** - * @return \Znck\Eloquent\Relations\BelongsToThrough<\Tests\Models\Country, $this> - */ public function countryWithCustomForeignKeys(): BelongsToThrough { return $this->belongsToThrough( @@ -36,35 +25,21 @@ public function countryWithCustomForeignKeys(): BelongsToThrough ); } - /** - * @return \Znck\Eloquent\Relations\BelongsToThrough<\Tests\Models\Country, $this> - */ public function countryWithTrashedUser(): BelongsToThrough { - /* @phpstan-ignore return.type */ return $this->country()->withTrashed(['users.deleted_at']); } - /** - * @return \Znck\Eloquent\Relations\BelongsToThrough<\Tests\Models\Country, $this> - */ public function countryWithPrefix(): BelongsToThrough { return $this->belongsToThrough(Country::class, [User::class, Post::class], null, 'custom_'); } - /** - * @return \Znck\Eloquent\Relations\BelongsToThrough - */ public function grandparent(): BelongsToThrough { - /* @phpstan-ignore argument.type */ return $this->belongsToThrough(self::class, self::class.' as alias', null, '', [self::class => 'parent_id']); } - /** - * @return \Znck\Eloquent\Relations\BelongsToThrough<\Tests\Models\User, $this> - */ public function user(): BelongsToThrough { return $this->belongsToThrough(User::class, Post::class); diff --git a/tests/Models/Country.php b/tests/Models/Country.php index 3d25a32..b565429 100644 --- a/tests/Models/Country.php +++ b/tests/Models/Country.php @@ -2,9 +2,6 @@ namespace Tests\Models; -/** - * @property int $id - */ class Country extends Model { // diff --git a/tests/Models/CustomerAddress.php b/tests/Models/CustomerAddress.php index 178d6cb..f1f4825 100644 --- a/tests/Models/CustomerAddress.php +++ b/tests/Models/CustomerAddress.php @@ -6,9 +6,6 @@ class CustomerAddress extends Model { - /** - * @return \Znck\Eloquent\Relations\BelongsToThrough<\Tests\Models\VendorCustomer, $this> - */ public function vendorCustomer(): BelongsToThrough { return $this->belongsToThrough( diff --git a/tests/TestCase.php b/tests/TestCase.php index 72a034e..7a96a9b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -35,12 +35,7 @@ protected function setUp(): void $this->seed(); } - /** - * Migrate the database. - * - * @return void - */ - protected function migrate() + protected function migrate(): void { DB::schema()->create('countries', function (Blueprint $table) { $table->increments('id'); @@ -80,12 +75,7 @@ protected function migrate() }); } - /** - * Seed the database. - * - * @return void - */ - protected function seed() + protected function seed(): void { Model::unguard();