PHPStan extension for webmozart/assert

Overview

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::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::length
  • Assert::minLength
  • Assert::maxLength
  • Assert::lengthBetween
  • nullOr* and all* 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
Comments
Releases(1.2.2)
Owner
PHPStan
PHP Static Analysis Tool - discover bugs in your code without running it!
PHPStan
PHPStan extension to support #[Readonly] constructor properties

icanhazstring/phpstan-readonly-property Support #[Readonly] promoted constructor properties for PHPStan. This library is used to have a full transitio

Andreas Frömer 4 Apr 5, 2022
Magento specific extension for phpstan

bitexpert/phpstan-magento This package provides some additional features for PHPStan to make it work for Magento 2 projects. Installation The preferre

bitExpert AG 92 Dec 7, 2022
An extension for PHPStan for adding analysis for PHP Language Extensions.

PHPStan PHP Language Extensions (currently in BETA) This is an extension for PHPStan for adding analysis for PHP Language Extensions. Language feature

Dave Liddament 9 Nov 30, 2022
PHPStan extension for sealed classes and interfaces.

Sealed classes with PHPStan This extension adds support for sealed classes and interfaces to PHPStan. Installation To use this extension, require it v

Jiří Pudil 14 Nov 28, 2022
Extension for PHPStan to allow analysis of Drupal code.

phpstan-drupal Extension for PHPStan to allow analysis of Drupal code. Sponsors Would you like to sponsor? Usage When you are using phpstan/extension-

Matt Glaman 154 Jan 2, 2023
Analyzes PHPStan baseline files and creates aggregated error trend-reports

Analyzes phpstan baseline files Analyzes PHPStan baseline files and creates aggregated error trend-reports.

Markus Staab 22 Dec 23, 2022
Sandbox project for the PHPStan workshop

Sandbox project for a PHPStan workshop Installation Requirements Docker Engine Docker Compose Git Bash Getting started Clone this repository (git clon

Matthias Noback 4 Oct 17, 2022
A PHPStan package that supports working with Extbase

PHPStan for Extbase This package provides a couple of stubs and services to make your life easier when working with PHPStan and Extbase. Examples clas

Alexander Schnitzler 7 Dec 10, 2021
Custom PHPStan rules

phpstan-rules Provides additional rules for phpstan/phpstan. Installation Run $ composer require --dev alister/phpstan-rules Usage All of the rules pr

Alister Bulman 1 Nov 4, 2021
Doctrine extensions for PHPStan

Doctrine extensions for PHPStan PHPStan Doctrine This extension provides following features: DQL validation for parse errors, unknown entity classes a

PHPStan 478 Jan 3, 2023
Various PHPStan rules we found useful in ShipMonk.

ShipMonk PHPStan rules Various rules we found useful in ShipMonk. You may found some of them opinionated, so we recommend picking only those fitting y

ShipMonk R&D 31 Dec 22, 2022
Repository containing all the PHPStan rules from the book "Recipes for Decoupling"

PHPStan rules from the book "Recipes for Decoupling" by Matthias Noback In the book "Recipes for Decoupling" we discuss how to decouple from web and C

Matthias Noback 19 Sep 21, 2022
WordPress extensions for PHPStan ⛏️

WordPress extensions for PHPStan Static analysis for the WordPress ecosystem. PHPStan WordPress Installation Add this package to your project. compose

Viktor Szépe 183 Dec 30, 2022
Perform static analysis of Drupal PHP code with phpstan-drupal.

Perform static analysis of Drupal PHP code with PHPStan and PHPStan-Drupal on Drupal using PHP 8. For example: docker run --rm \ -v $(pwd)/example01

Dcycle 0 Dec 10, 2021
Magento 2 Extension to cleanup admin menu and Store > Configuration area by arranging third party extension items.

Clean Admin Menu - Magento 2 Extension It will merge all 3rd party extension's menu items in backend's primary menu to a common menu item named "Exten

RedChamps 109 Jan 3, 2023
Magento 2 Blog Extension is a better blog extension for Magento 2 platform. These include all useful features of Wordpress CMS

Magento 2 Blog extension FREE Magento 2 Better Blog by Mageplaza is integrated right into the Magento backend so you can manage your blog and your e-c

Mageplaza 113 Dec 14, 2022
Okex API Like the official document interface, Support for arbitrary extension.

It is recommended that you read the official document first Okex docs https://www.okex.com/docs/en Okex Simulation Test API https://www.okex.com/docs/

lin 34 Jan 1, 2023
Generate stubs for any PHP extension.

php-ext-stubs-generator Installation Run $ composer require --dev lctrs/php-ext-stubs-generator Usage $ php vendor/bin/generate-stubs-for-ext extensio

null 5 Dec 14, 2022
This Magento 2 extension integrates EasyTranslate into Magento 2.

EasyTranslate Magento 2 Connector This Magento 2 extension integrates EasyTranslate into Magento 2. Mind that you need to have an account with EasyTra

Easytranslate ApS 0 Oct 7, 2022