damejidlo / phpstan-nette-tester
PHPStan nette/tester extension
Installs: 47 983
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 6
Forks: 0
Open Issues: 0
Type:phpstan-extension
Requires
- php: >=7.2
- nikic/php-parser: ^4.0
- phpstan/phpstan: ^0.12.0
Requires (Dev)
- damejidlo/coding-standard: ^1.1.0
- jakub-onderka/php-parallel-lint: ^1.0
- nette/tester: ^2.3.1
- phpstan/phpstan-phpunit: ^0.12
- phpstan/phpstan-strict-rules: ^0.12
- phpunit/phpunit: ^7.5.17
This package is auto-updated.
Last update: 2020-01-15 11:41:24 UTC
README
This extension was heavily inspired by phpstan/phpstan/phpstan-webmozart-assert developed by Ondřej Mirtes.
Description
The main scope of this extension is to help phpstan to detect the type of object after the Tester\Assert
validation.
<?php declare(strict_types = 1); use Tester\Assert; function runTest(?int $a) { // ... Assert::notNull($a); // phpstan is now aware that $a can no longer be `null` at this point return ($a === 10); }
This extension specifies types of values passed to:
Assert::null()
Assert::notNull()
Assert::true()
Assert::false()
Assert::truthy()
Assert::falsey()
Assert::nan()
Assert::same()
Assert::notSame()
Assert::type()
Assert::count()
Installation
To use this extension, require it in Composer:
composer require --dev damejidlo/phpstan-nette-tester
If you also install phpstan/extension-installer then you're all set!
If you have enabled checkAlwaysTrueCheckTypeFunctionCall: true
, you will need to add some ignored errors:
parameters:
ignoreErrors:
- '~Call to static method Tester\\Assert::(type|count|same|notSame)\(\) with .* and .* will always evaluate to true\.~'
- '~Call to static method Tester\\Assert::(null|notNull|true|false|truthy|falsey|nan)\(\) with .* will always evaluate to true\.~'
Manual installation
If you don't want to use phpstan/extension-installer
, include extension.neon in your project's PHPStan config:
includes:
- vendor/damejidlo/phpstan-nette-tester/extension.neon