tp5.1配置phpstan

先改一下composer.json

{
    "require-dev": {
        "symfony/var-dumper": "^4.2",
        "phpstan/phpstan": "^0.12.33"
    },
    "autoload": {
        "psr-4": {
            "app\\": "application"
        },
        "psr-0": {
            "": "extend/"
        },
        "files": [
            "application/common.php",
            "vendor/topthink/framework/helper.php"
        ]
    },
    "scripts": {
        "analyse": "phpstan analyse --memory-limit 2G -c phpstan.neon"
    }
}

主要是加一下phpstan包跟analyse脚本
在项目根目录下加一下phpstan.neon文件

# Magic behaviour with __get, __set, __call and __callStatic is not exactly static analyser-friendly :)
# Fortunately, You can ingore it by the following config.
#
# vendor/bin/phpstan analyse app --memory-limit 200M -l 0
#
parameters:
    level: 1
    paths:
         - ./application
    ignoreErrors:
#         - '#Static call to instance method think\[a-zA-Z0-9\]::[a-zA-Z0-9\\_]+\(\)#'

执行composer update

执行composer analyse

tp5.1配置phpstan
写一个错误试试

tp5.1配置phpstan

tp5.1配置phpstan
如上已经成功扫描出来错误

本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!