phpstan deprecation rules
2.0.1
이 확장을 사용하려면 작곡가에 필요합니다.
composer require --dev phpstan/phpstan-deprecation-rules
Phpstan/Extension-Installer도 설치하면 모두 설정됩니다!
phpstan/extension-installer 사용하지 않으려면 프로젝트의 Phpstan 구성에 규칙을 포함시킵니다.
includes:
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
이 연장은 @deprecated 로 주석이 달린 속성/함수/메소드/클래스를 사용하는 코드에서 감가 상각 경고를 방출합니다.
더 이상 사용되지 않은 것으로 간주하려는 코드를 소유하지 않은 경우 Phpstan Stub 파일을 사용하여 공급 업체 파일에 대한 감가 상징을 선언하십시오.
/** @deprecated */
class ThirdPartyClass {}
더 이상 사용되지 않은 코드의 사용은 더 이상 사용되지 않는 코드에서보고되지 않습니다.
/** @deprecated */
function doFoo (): void
{
// not reported:
anotherDeprecatedFunction ();
} 의도적으로 더 이상 사용되지 않은 기호를 호출하는 코드를 표시하는 다른 방법이 있고 이러한 통화가보고되기를 원하지 않으면 DeprecatedScopeResolver 인터페이스를 구현하여 확장자를 작성할 수 있습니다.
예를 들어 @group legacy 로 사용되지 않는 코드를 테스트하는 PHPUnit 테스트를 표시하면 다음과 같은 방식으로 확장을 구현할 수 있습니다.
class GroupLegacyScopeResolver implements DeprecatedScopeResolver
{
public function isScopeDeprecated ( Scope $ scope ): bool
{
$ function = $ scope -> getFunction ();
return $ function !== null
&& $ function -> getDocComment () !== null
&& strpos ( $ function -> getDocComment (), ' @group legacy ' ) !== false ;
}
}구성 파일에 등록하십시오.
services :
-
class : GroupLegacyScopeResolver
tags :
- phpstan.deprecations.deprecatedScopeResolver사용자 정의 PHPSTAN 확장을 구현하기위한 핵심 개념 인 SCOPE에 대해 자세히 알아보십시오.