我想配置 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
。我怎样才能禁用它?
简短的回答:因为除非您知道自己在做什么,否则您不应该使用自定义规则集😊坚持官方规则级别,您将获得更好的体验:https://phpstan.org/user-guide/rule-levels
长答案:除了包含特定的规则类之外,您还需要注意需要设置且 PHPStan 代表您处理的特定参数。此错误将在级别 2 上报告。