socheatsok78/laravel-psalm-helper

Laravel Psalm Helper

v1.0.1 2019-12-26 01:56 UTC

This package is auto-updated.

Last update: 2024-09-29 05:28:59 UTC


README

A zero-config installer for Psalm (a static analysis tool that’s designed to improve large PHP codebases by identifying both obvious and hard-to-spot bugs)

Required: PHP7.2 packagis packagis-download License

安装

composer require --dev socheatsok78/laravel-psalm-helper

将以下脚本添加到 composer.json

"scripts": {
    "psalm": [
        "vendor/bin/psalm --show-info=false"
    ],
    "psalm:info": [
        "vendor/bin/psalm --show-info=true"
    ],
    "psalm:dry-run": [
        "vendor/bin/psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType --dry-run"
    ],
    "psalm:alter": [
        "vendor/bin/psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType"
    ]
}

然后您只需运行 composer run psalm

使用方法

添加 psalm.xml 配置文件

./vendor/bin/psalm --init [source_directory=src] [config_level=3]

其中 config_level 表示您希望 Psalm 严格到什么程度。 1 是最严格的,8 是最宽容的。

示例

$ ./vendor/bin/psalm --init
Config file created successfully. Please re-run psalm.

$ ./vendor/bin/psalm-plugin enable psalm/plugin-laravel
[OK] Plugin enabled

然后运行 Psalm

./vendor/bin/psalm

更多详情请参阅 Psalm 文档

内容包含什么?

本包将仅安装以下依赖

📝 许可证

MIT 许可证 下许可。