phpstan / phpstan-beberlei-assert
PHPStan beberlei/assert 扩展
1.1.3
2024-09-11 15:44 UTC
Requires
- php: ^7.2 || ^8.0
- phpstan/phpstan: ^1.12
Requires (Dev)
- beberlei/assert: ^3.3.0
- nikic/php-parser: ^4.13.0
- php-parallel-lint/php-parallel-lint: ^1.4
- phpstan/phpstan-phpunit: ^1.4
- phpstan/phpstan-strict-rules: ^1.6
- phpunit/phpunit: ^9.5
README
描述
本扩展的主要作用是帮助 PHPStan 在 Assert\Assertion
验证之后检测对象的类型。
<?php declare(strict_types = 1); use Assert\Assertion; function demo(?int $a) { // ... Assertion::integer($a); // PHPStan is now aware that $a can no longer be `null` at this point return ($a === 10); }
安装
要使用此扩展,请在 Composer 中要求它
composer require --dev phpstan/phpstan-beberlei-assert
如果您还安装了 phpstan/extension-installer,那么您就设置好了!
手动安装
如果您不想使用 phpstan/extension-installer
,请将 extension.neon 包含在您的项目 PHPStan 配置中
includes:
- vendor/phpstan/phpstan-beberlei-assert/extension.neon