PHPStan nette/tester extension

Installs: 258 062

Dependents: 27

Suggesters: 0

Security: 0

Stars: 3

Watchers: 3

Forks: 1

Open Issues: 0


v1.2.0 2024-04-06 07:09 UTC

This package is auto-updated.

Last update: 2024-07-07 07:23:40 UTC


PHPStan nette/tester extension

Build Status Coverage Status Downloads this Month Latest stable

This extension was heavily inspired by phpstan/phpstan/phpstan-webmozart-assert developed by Ondřej Mirtes.

It was originally developed and published under damejidlo organization.


The main scope of this extension is to help phpstan to detect the type of object after the Tester\Assert validation.

declare(strict_types = 1);

use Tester\Assert;

function runTest(?int $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()


To use this extension, require it in Composer:

composer require --dev nepada/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:

		- '~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:

    - vendor/nepada/phpstan-nette-tester/extension.neon