phpstan / phpstan-webmozart-assert
PHPStan webmozart/assert extension
Installs: 9 807 127
Dependents: 707
Suggesters: 0
Security: 0
Stars: 143
Watchers: 7
Forks: 24
Open Issues: 4
Type:phpstan-extension
Requires
- php: ^7.2 || ^8.0
- phpstan/phpstan: ^1.10
Requires (Dev)
- nikic/php-parser: ^4.13.0
- php-parallel-lint/php-parallel-lint: ^1.2
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-strict-rules: ^1.0
- phpunit/phpunit: ^9.5
- webmozart/assert: ^1.11.0
- 1.2.x-dev
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.12.16
- 0.12.15
- 0.12.14
- 0.12.13
- 0.12.12
- 0.12.11
- 0.12.10
- 0.12.9
- 0.12.8
- 0.12.7
- 0.12.6
- 0.12.5
- 0.12.4
- 0.12.3
- 0.12.2
- 0.12.1
- 0.12.0
- 0.11.3
- 0.11.2
- 0.11.1
- 0.11
- 0.10
- dev-renovate/major-github-actions
This package is auto-updated.
Last update: 2023-09-11 09:46:23 UTC
README
Description
The main scope of this extension is to help phpstan to detect the type of object after the Webmozart\Assert
validation.
<?php declare(strict_types = 1); use Webmozart\Assert; function demo(?int $a) { // ... Assert::integer($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::integer
Assert::positiveInteger
Assert::string
Assert::stringNotEmpty
Assert::float
Assert::numeric
Assert::natural
Assert::integerish
Assert::boolean
Assert::scalar
Assert::object
Assert::resource
Assert::isCallable
Assert::isArray
Assert::isTraversable
(deprecated, useisIterable
orisInstanceOf
instead)Assert::isIterable
Assert::isCountable
Assert::isInstanceOf
Assert::isInstanceOfAny
Assert::notInstanceOf
Assert::isAOf
Assert::isAnyOf
Assert::isNotA
Assert::subclassOf
Assert::true
Assert::false
Assert::notFalse
Assert::null
Assert::notNull
Assert::isEmpty
Assert::notEmpty
Assert::eq
Assert::notEq
Assert::same
Assert::notSame
Assert::greaterThan
Assert::greaterThanEq
Assert::lessThan
Assert::lessThanEq
Assert::range
Assert::implementsInterface
Assert::classExists
Assert::interfaceExists
Assert::keyExists
Assert::keyNotExists
Assert::validArrayKey
Assert::count
Assert::minCount
Assert::maxCount
Assert::countBetween
Assert::isList
Assert::isNonEmptyList
Assert::isMap
Assert::isNonEmptyMap
Assert::inArray
Assert::oneOf
Assert::methodExists
Assert::propertyExists
Assert::isArrayAccessible
Assert::contains
Assert::startsWith
Assert::startsWithLetter
Assert::endsWith
Assert::unicodeLetters
Assert::alpha
Assert::digits
Assert::alnum
Assert::lower
Assert::upper
Assert::length
Assert::minLength
Assert::maxLength
Assert::lengthBetween
Assert::uuid
Assert::ip
Assert::ipv4
Assert::ipv6
Assert::email
Assert::notWhitespaceOnly
nullOr*
,all*
andallNullOr*
variants of the above methods
Installation
To use this extension, require it in Composer:
composer require --dev phpstan/phpstan-webmozart-assert
If you also install phpstan/extension-installer then you're all set!
Manual installation
If you don't want to use phpstan/extension-installer
, include extension.neon in your project's PHPStan config:
includes:
- vendor/phpstan/phpstan-webmozart-assert/extension.neon