承接 macroactive/laravel-psalm 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

macroactive/laravel-psalm

最新稳定版本:11.0.0

Composer 安装命令:

composer require macroactive/laravel-psalm

包简介

Psalm integration with Laravel. Do not cover Facades. Relatively simple integration

README 文档

README

Why?

Because we use Laravel and want to have decent Psalm coverage. Yes, we are aware on existence of official integration. But it's bigger and has some generalisations. Our implementation adds some limitations on code but, hopefully, more lightweight and makes better checks. Also, this one is more internal tool still, so lack of documentation and other drawbacks could still present :/ Choice is yours — check both and find what suits better for you.

Limitations

We try to make the code easier for Psalm understanding by introducing these limitations. Idea of them is to decrease amount of magic as much as possible.

  • all model requests must start with Model::query()
  • don't use facades (we consider this antipattern), only proper constructor/signature DI should be used
  • models must have proper notation. Version generated by ide-helper must be adjusted
  • we don't use Eloquent collections and fallbacks to Support Collections at all time

Example of a model

//declare strict, NS and other usages here

use Illuminate\Support\Collection;

/**
 * @property int                                                                           $id
… other columns
 * @property-read       Collection|CountryRegion[] $regions
 * @psalm-property-read Collection<CountryRegion>  $regions
 *
 * @method self published()
 */
final class Country extends Model
{

You can see Psalm notation for relations/ro-properties here. Also, the method published() is a form of scope annotation.

统计信息

  • 总下载量: 16.86k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 13
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-16