• Stars
    star
    160
  • Rank 234,703 (Top 5 %)
  • Language
    PHP
  • Created over 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PHPStan extension for webmozart/assert

PHPStan webmozart/assert extension

Build Latest Stable Version License

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, use isIterable or isInstanceOf 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* and allNullOr* 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

More Repositories

1

phpstan

PHP Static Analysis Tool - discover bugs in your code without running it!
PHP
12,763
star
2

phpdoc-parser

Next-gen phpDoc parser with support for intersection types and generics
PHP
1,303
star
3

phpstan-symfony

Symfony extension for PHPStan
PHP
691
star
4

phpstan-strict-rules

Extra strict and opinionated rules for PHPStan
PHP
586
star
5

phpstan-doctrine

Doctrine extensions for PHPStan
PHP
577
star
6

phpstan-phpunit

PHPUnit extensions and rules for PHPStan
PHP
450
star
7

extension-installer

Composer plugin for automatic installation of PHPStan extensions.
PHP
395
star
8

phpstan-deprecation-rules

PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.
PHP
360
star
9

phpstan-src

PHPStan's source code. This is where development happens. Check https://github.com/phpstan/phpstan for the distribution repository.
PHP
307
star
10

phpstan-nette

Nette Framework class reflection extension for PHPStan & framework-specific rules
PHP
100
star
11

phpstan-shim

[DEPRECATED] This repository provides easy way to install PHPStan without the risk of conflicting dependencies.
PHP
87
star
12

phpstan-mockery

PHPStan extension for Mockery
PHP
81
star
13

phpstan-beberlei-assert

PHPStan extension for beberlei/assert
PHP
38
star
14

vim-phpstan

A Vim plugin for PHPStan - https://github.com/phpstan/phpstan. It calls `phpstan` to do static analysis of your PHP code and displays the errors in Vim's quickfix list.
PHP
29
star
15

php-8-stubs

PHP
27
star
16

phpstan-php-parser

PHP-Parser extension for PHPStan
Makefile
23
star
17

phpstan-dibi

Dibi class reflection extension for PHPStan
PHP
15
star
18

build-cs

Coding standard for 1st party PHPStan extensions
2
star