具有自定义规则集的 phpstan 未找到所有错误

问题描述 投票:0回答:1

我想配置 phpstan,使其报告未定义方法调用的使用

<?php

namespace App;

class Testeroni
{
    public function asdf()
    {
        $this->iDoNotExist(); // Ok
        self::whatIsThat(); // OK 

        $me = new self();
        $me->iDoNotExist(); // does not get reported!! why? 
    }
}

但它不报告最后一个方法调用。 有人有想法吗?

这是使用的配置

parameters:
    customRulesetUsed: true
    paths:
        - src
        - libs
services:
    -
        class: PHPStan\Rules\Methods\CallMethodsRule
        tags: [phpstan.rules.rule]

    -
        class: PHPStan\Rules\Methods\CallStaticMethodsRule
        tags: [phpstan.rules.rule]

    -
        class: PHPStan\Rules\Methods\ExistingClassesInTypehintsRule
        tags: [phpstan.rules.rule]

它还报告错误

Parameter has invalid Type
。我怎样才能禁用它?

phpstan
1个回答
0
投票

简短的回答:因为除非您知道自己在做什么,否则您不应该使用自定义规则集😊坚持官方规则级别,您将获得更好的体验:https://phpstan.org/user-guide/rule-levels

长答案:除了包含特定的规则类之外,您还需要注意需要设置且 PHPStan 代表您处理的特定参数。此错误将在级别 2 上报告。

© www.soinside.com 2019 - 2024. All rights reserved.