titasgailius/larastan-extended
最新稳定版本:0.0.2
Composer 安装命令:
composer require titasgailius/larastan-extended
包简介
An opinionated Larastan extension. Automatically parse model's casts() method.
README 文档
README
Larastan Extended
Larastan Extended is an opinionated Larastan extension that inspects your Laravel application to make static analysis less verbose.
Features
Automatically infer the return type of the casts method.
/** * Get the attributes that should be cast. - * - * @return array{ - * user_id: 'integer', - * published_at: 'datetime', - * } */ public function casts(): array { return [ 'user_id' => 'integer', 'published_at' => 'datetime', ]; }
Detect non-nullable $request->user() calls in authenticated routes.
Route::get('posts', function (Request $request) {
- /** @var \App\Models\User */
- $user = $request->user();
-
- return $user->posts;
+ return $request->user()->posts;
})->middleware('auth');
Detect non-nullable relationships.
Route::get('teams/{team}/owner', function (Team $team) {
- /** @var \App\Models\User */
- $owner = $team->owner;
-
- return $owner;
+ return $team->owner;
});
Installation
You can install the package via Composer:
composer require --dev titasgailius/larastan-extended
Usage
Include the extension before the Larastan extension.
includes:
+ - vendor/titasgailius/larastan-extended/extension.neon
- vendor/larastan/larastan/extension.neon
统计信息
- 总下载量: 521
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-07
