tzmfreedom/phpstan-extensions
最新稳定版本:v0.1.7
Composer 安装命令:
composer require --dev tzmfreedom/phpstan-extensions
包简介
PHPStan extensions
README 文档
README
VisibleForTestingRule
PHPStan custom rules to ensure that VisibleForTesting annotated public methods are called in private/protected scopes outside of the test environment, inspired by @VisibleForTesting annotation on Flutter, Java (Guava)
In following code, this extension report error outside of the test environment.
<?php use Tzmfreedom\Attributes\VisibleForTesting; class Foo { #[VisibleForTesting] public function exampleWithAttribute() {} /** * @visibleForTesting */ public function exampleWithPhpdoc() {} } (new Foo)->exampleWithAttribute(); // error: VisibleForTesting annotated method Foo::visibleForTestingWithAttribute should be called in private scope outside of the test environment
UnusedReturnRule
<?php class Foo { public function getString(): string { return ''; } } (new Foo)->getString(); // error: Return value on Method Foo::getString() is unused $_ = (new Foo)->getString(); // OK
OverwriteVariableRule
<?php $var = null; $var = 'hoge'; // OK, changing from null to any $var = 'fuga'; // NG
OverwriteDifferentTypeVariableRule
<?php $var = null; $var = 'hoge'; // OK, changing from null to any $var = 1; // NG, changing from string to integer $var = 1.0; // OK, changing from integer to float $var = 1; // OK, changeing from float to integer $var = new \stdClass(); // NG $var = new class extends \stdClass{}; // OK $var = new \stdClass(); // OK
Installation
$ composer require --dev tzmfreedom/phpstan-extensions
phpstan.neon
rules: - Tzmfreedom\PHPStan\Rules\VisibleForTestingRule - Tzmfreedom\PHPStan\Rules\UnusedReturnRule
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-02