Copied!

Efficient assertions to validate the input/output of your methods.

Cloneable
Methods
public static __callStatic ( $name , $arguments )
 
  • throws BadMethodCallException
public static allAlnum ( $value , $message = '' )
 
public static allAlpha ( $value , $message = '' )
 
public static allBoolean ( $value , $message = '' )
 
public static allClassExists ( $value , $message = '' )
 
public static allContains ( $value , $subString , $message = '' )
 
public static allCount ( $array , $number , $message = '' )
 
public static allCountBetween ( $array , $min , $max , $message = '' )
 
public static allDigits ( $value , $message = '' )
 
public static allDirectory ( $value , $message = '' )
 
public static allEmail ( $value , $message = '' )
 
public static allEndsWith ( $value , $suffix , $message = '' )
 
public static allEq ( $value , $expect , $message = '' )
 
public static allFalse ( $value , $message = '' )
 
public static allFile ( $value , $message = '' )
 
public static allFileExists ( $value , $message = '' )
 
public static allFloat ( $value , $message = '' )
 
public static allGreaterThan ( $value , $limit , $message = '' )
 
public static allGreaterThanEq ( $value , $limit , $message = '' )
 
public static allImplementsInterface ( $value , $interface , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $interface
  • psalm-assert iterable<class-string> $value
  • param mixed $value
  • param mixed $interface
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static allInArray ( $value , $values , $message = '' )
 
public static allInteger ( $value , $message = '' )
 
public static allIntegerish ( $value , $message = '' )
 
public static allInterfaceExists ( $value , $message = '' )
 
public static allIp ( $value , $message = '' )
 
public static allIpv4 ( $value , $message = '' )
 
public static allIpv6 ( $value , $message = '' )
 
public static allIsAnyOf ( $value , $classes , $message = '' )
 
public static allIsAOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert iterable<ExpectedType|class-string> $value
  • param iterable | string> $value
  • param string $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static allIsArray ( $value , $message = '' )
 
public static allIsArrayAccessible ( $value , $message = '' )
 
public static allIsCallable ( $value , $message = '' )
 
public static allIsCountable ( $value , $message = '' )
 
public static allIsEmpty ( $value , $message = '' )
 
public static allIsInstanceOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert iterable $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static allIsInstanceOfAny ( $value , $classes , $message = '' )
 
public static allIsIterable ( $value , $message = '' )
 
public static allIsList ( $array , $message = '' )
 
public static allIsMap ( $array , $message = '' )
 
  • psalm-pure
  • psalm-template T
  • psalm-param iterable<mixed|array> $array
  • psalm-assert iterable<array<string, T>> $array
  • param mixed $array
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static allIsNonEmptyList ( $array , $message = '' )
 
public static allIsNonEmptyMap ( $array , $message = '' )
 
public static allIsNotA ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template UnexpectedType of object
  • psalm-param class-string $class
  • param iterable | string> $value
  • param string $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static allIsTraversable ( $value , $message = '' )
 
public static allKeyExists ( $array , $key , $message = '' )
 
public static allKeyNotExists ( $array , $key , $message = '' )
 
public static allLength ( $value , $length , $message = '' )
 
public static allLengthBetween ( $value , $min , $max , $message = '' )
 
public static allLessThan ( $value , $limit , $message = '' )
 
public static allLessThanEq ( $value , $limit , $message = '' )
 
public static allLower ( $value , $message = '' )
 
public static allMaxCount ( $array , $max , $message = '' )
 
public static allMaxLength ( $value , $max , $message = '' )
 
public static allMethodExists ( $classOrObject , $method , $message = '' )
 
public static allMethodNotExists ( $classOrObject , $method , $message = '' )
 
public static allMinCount ( $array , $min , $message = '' )
 
public static allMinLength ( $value , $min , $message = '' )
 
public static allNatural ( $value , $message = '' )
 
public static allNotContains ( $value , $subString , $message = '' )
 
public static allNotEmpty ( $value , $message = '' )
 
public static allNotEndsWith ( $value , $suffix , $message = '' )
 
public static allNotEq ( $value , $expect , $message = '' )
 
public static allNotFalse ( $value , $message = '' )
 
public static allNotInstanceOf ( $value , $class , $message = '' )
 
public static allNotNull ( $value , $message = '' )
 
public static allNotRegex ( $value , $pattern , $message = '' )
 
public static allNotSame ( $value , $expect , $message = '' )
 
public static allNotStartsWith ( $value , $prefix , $message = '' )
 
public static allNotWhitespaceOnly ( $value , $message = '' )
 
public static allNull ( $value , $message = '' )
 
public static allNumeric ( $value , $message = '' )
 
public static allObject ( $value , $message = '' )
 
public static allOneOf ( $value , $values , $message = '' )
 
public static allPositiveInteger ( $value , $message = '' )
 
public static allPropertyExists ( $classOrObject , $property , $message = '' )
 
public static allPropertyNotExists ( $classOrObject , $property , $message = '' )
 
public static allRange ( $value , $min , $max , $message = '' )
 
public static allReadable ( $value , $message = '' )
 
public static allRegex ( $value , $pattern , $message = '' )
 
public static allResource ( $value , $type = NULL , $message = '' )
 
public static allSame ( $value , $expect , $message = '' )
 
public static allScalar ( $value , $message = '' )
 
public static allStartsWith ( $value , $prefix , $message = '' )
 
public static allStartsWithLetter ( $value , $message = '' )
 
public static allString ( $value , $message = '' )
 
public static allStringNotEmpty ( $value , $message = '' )
 
public static allSubclassOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert iterable<class-string|ExpectedType> $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static allThrows ( $expression , $class = 'Exception' , $message = '' )
 
public static allTrue ( $value , $message = '' )
 
public static allUnicodeLetters ( $value , $message = '' )
 
public static allUniqueValues ( $values , $message = '' )
 
public static allUpper ( $value , $message = '' )
 
public static allUuid ( $value , $message = '' )
 
public static allValidArrayKey ( $value , $message = '' )
 
public static allWritable ( $value , $message = '' )
 
public static alnum ( $value , $message = '' )
 
public static alpha ( $value , $message = '' )
 
public static boolean ( $value , $message = '' )
 
public static classExists ( $value , $message = '' )
 
public static contains ( $value , $subString , $message = '' )
 
public static count ( $array , $number , $message = '' )
 

Does not check if $array is countable, this can generate a warning on php versions after 7.2.

public static countBetween ( $array , $min , $max , $message = '' )
 

Does not check if $array is countable, this can generate a warning on php versions after 7.2.

public static digits ( $value , $message = '' )
 
public static directory ( $value , $message = '' )
 
public static email ( $value , $message = '' )
 
public static endsWith ( $value , $suffix , $message = '' )
 
public static eq ( $value , $expect , $message = '' )
 
public static false ( $value , $message = '' )
 
public static file ( $value , $message = '' )
 
public static fileExists ( $value , $message = '' )
 

Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file.

public static float ( $value , $message = '' )
 
public static greaterThan ( $value , $limit , $message = '' )
 
public static greaterThanEq ( $value , $limit , $message = '' )
 
public static implementsInterface ( $value , $interface , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $interface
  • psalm-assert class-string $value
  • param mixed $value
  • param mixed $interface
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
public static inArray ( $value , array $values , $message = '' )
 

Does strict comparison, so Assert::inArray(3, ['3']) does not pass the assertion.

public static integer ( $value , $message = '' )
 
public static integerish ( $value , $message = '' )
 
public static interfaceExists ( $value , $message = '' )
 
public static ip ( $value , $message = '' )
 
public static ipv4 ( $value , $message = '' )
 
public static ipv6 ( $value , $message = '' )
 
public static isAnyOf ( $value , array $classes , $message = '' )
 
public static isAOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert ExpectedType|class-string $value
  • param object | string $value
  • param string $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
public static isArray ( $value , $message = '' )
 
public static isArrayAccessible ( $value , $message = '' )
 
public static isCallable ( $value , $message = '' )
 
public static isCountable ( $value , $message = '' )
 
public static isEmpty ( $value , $message = '' )
 
public static isInstanceOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert ExpectedType $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
public static isInstanceOfAny ( $value , array $classes , $message = '' )
 
public static isIterable ( $value , $message = '' )
 
public static isList ( $array , $message = '' )
 
public static isMap ( $array , $message = '' )
 
public static isNonEmptyList ( $array , $message = '' )
 
public static isNonEmptyMap ( $array , $message = '' )
 
public static isNotA ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template UnexpectedType of object
  • psalm-param class-string $class
  • psalm-assert !UnexpectedType $value
  • psalm-assert !class-string $value
  • param object | string $value
  • param string $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
public static isTraversable ( $value , $message = '' )
 
public static keyExists ( $array , $key , $message = '' )
 
public static keyNotExists ( $array , $key , $message = '' )
 
public static length ( $value , $length , $message = '' )
 
public static lengthBetween ( $value , $min , $max , $message = '' )
 

Inclusive , so Assert::lengthBetween('asd', 3, 5); passes the assertion.

public static lessThan ( $value , $limit , $message = '' )
 
public static lessThanEq ( $value , $limit , $message = '' )
 
public static lower ( $value , $message = '' )
 
public static maxCount ( $array , $max , $message = '' )
 

Does not check if $array is countable, this can generate a warning on php versions after 7.2.

public static maxLength ( $value , $max , $message = '' )
 

Inclusive max.

public static methodExists ( $classOrObject , $method , $message = '' )
 
public static methodNotExists ( $classOrObject , $method , $message = '' )
 
public static minCount ( $array , $min , $message = '' )
 

Does not check if $array is countable, this can generate a warning on php versions after 7.2.

public static minLength ( $value , $min , $message = '' )
 

Inclusive min.

public static natural ( $value , $message = '' )
 
public static notContains ( $value , $subString , $message = '' )
 
public static notEmpty ( $value , $message = '' )
 
public static notEndsWith ( $value , $suffix , $message = '' )
 
public static notEq ( $value , $expect , $message = '' )
 
public static notFalse ( $value , $message = '' )
 
public static notInstanceOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert !ExpectedType $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
public static notNull ( $value , $message = '' )
 
public static notRegex ( $value , $pattern , $message = '' )
 
public static notSame ( $value , $expect , $message = '' )
 
public static notStartsWith ( $value , $prefix , $message = '' )
 
public static notWhitespaceOnly ( $value , $message = '' )
 
public static null ( $value , $message = '' )
 
public static nullOrAlnum ( $value , $message = '' )
 
public static nullOrAlpha ( $value , $message = '' )
 
public static nullOrBoolean ( $value , $message = '' )
 
public static nullOrClassExists ( $value , $message = '' )
 
public static nullOrContains ( $value , $subString , $message = '' )
 
public static nullOrCount ( $array , $number , $message = '' )
 
public static nullOrCountBetween ( $array , $min , $max , $message = '' )
 
public static nullOrDigits ( $value , $message = '' )
 
public static nullOrDirectory ( $value , $message = '' )
 
public static nullOrEmail ( $value , $message = '' )
 
public static nullOrEndsWith ( $value , $suffix , $message = '' )
 
public static nullOrEq ( $value , $expect , $message = '' )
 
public static nullOrFalse ( $value , $message = '' )
 
public static nullOrFile ( $value , $message = '' )
 
public static nullOrFileExists ( $value , $message = '' )
 
public static nullOrFloat ( $value , $message = '' )
 
public static nullOrGreaterThan ( $value , $limit , $message = '' )
 
public static nullOrGreaterThanEq ( $value , $limit , $message = '' )
 
public static nullOrImplementsInterface ( $value , $interface , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $interface
  • psalm-assert class-string|null $value
  • param mixed $value
  • param mixed $interface
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static nullOrInArray ( $value , $values , $message = '' )
 
public static nullOrInteger ( $value , $message = '' )
 
public static nullOrIntegerish ( $value , $message = '' )
 
public static nullOrInterfaceExists ( $value , $message = '' )
 
public static nullOrIp ( $value , $message = '' )
 
public static nullOrIpv4 ( $value , $message = '' )
 
public static nullOrIpv6 ( $value , $message = '' )
 
public static nullOrIsAnyOf ( $value , $classes , $message = '' )
 
public static nullOrIsAOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert ExpectedType|class-string|null $value
  • param object | string | null $value
  • param string $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static nullOrIsArray ( $value , $message = '' )
 
public static nullOrIsArrayAccessible ( $value , $message = '' )
 
public static nullOrIsCallable ( $value , $message = '' )
 
public static nullOrIsCountable ( $value , $message = '' )
 
public static nullOrIsEmpty ( $value , $message = '' )
 
public static nullOrIsInstanceOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert ExpectedType|null $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static nullOrIsInstanceOfAny ( $value , $classes , $message = '' )
 
public static nullOrIsIterable ( $value , $message = '' )
 
public static nullOrIsList ( $array , $message = '' )
 
public static nullOrIsMap ( $array , $message = '' )
 
public static nullOrIsNonEmptyList ( $array , $message = '' )
 
public static nullOrIsNonEmptyMap ( $array , $message = '' )
 
public static nullOrIsNotA ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template UnexpectedType of object
  • psalm-param class-string $class
  • param object | string | null $value
  • param string $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static nullOrIsTraversable ( $value , $message = '' )
 
public static nullOrKeyExists ( $array , $key , $message = '' )
 
public static nullOrKeyNotExists ( $array , $key , $message = '' )
 
public static nullOrLength ( $value , $length , $message = '' )
 
public static nullOrLengthBetween ( $value , $min , $max , $message = '' )
 
public static nullOrLessThan ( $value , $limit , $message = '' )
 
public static nullOrLessThanEq ( $value , $limit , $message = '' )
 
public static nullOrLower ( $value , $message = '' )
 
public static nullOrMaxCount ( $array , $max , $message = '' )
 
public static nullOrMaxLength ( $value , $max , $message = '' )
 
public static nullOrMethodExists ( $classOrObject , $method , $message = '' )
 
public static nullOrMethodNotExists ( $classOrObject , $method , $message = '' )
 
public static nullOrMinCount ( $array , $min , $message = '' )
 
public static nullOrMinLength ( $value , $min , $message = '' )
 
public static nullOrNatural ( $value , $message = '' )
 
public static nullOrNotContains ( $value , $subString , $message = '' )
 
public static nullOrNotEmpty ( $value , $message = '' )
 
public static nullOrNotEndsWith ( $value , $suffix , $message = '' )
 
public static nullOrNotEq ( $value , $expect , $message = '' )
 
public static nullOrNotFalse ( $value , $message = '' )
 
public static nullOrNotInstanceOf ( $value , $class , $message = '' )
 
public static nullOrNotRegex ( $value , $pattern , $message = '' )
 
public static nullOrNotSame ( $value , $expect , $message = '' )
 
public static nullOrNotStartsWith ( $value , $prefix , $message = '' )
 
public static nullOrNotWhitespaceOnly ( $value , $message = '' )
 
public static nullOrNumeric ( $value , $message = '' )
 
public static nullOrObject ( $value , $message = '' )
 
public static nullOrOneOf ( $value , $values , $message = '' )
 
public static nullOrPositiveInteger ( $value , $message = '' )
 
public static nullOrPropertyExists ( $classOrObject , $property , $message = '' )
 
public static nullOrPropertyNotExists ( $classOrObject , $property , $message = '' )
 
public static nullOrRange ( $value , $min , $max , $message = '' )
 
public static nullOrReadable ( $value , $message = '' )
 
public static nullOrRegex ( $value , $pattern , $message = '' )
 
public static nullOrResource ( $value , $type = NULL , $message = '' )
 
public static nullOrSame ( $value , $expect , $message = '' )
 
public static nullOrScalar ( $value , $message = '' )
 
public static nullOrStartsWith ( $value , $prefix , $message = '' )
 
public static nullOrStartsWithLetter ( $value , $message = '' )
 
public static nullOrString ( $value , $message = '' )
 
public static nullOrStringNotEmpty ( $value , $message = '' )
 
public static nullOrSubclassOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert class-string|ExpectedType|null $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static nullOrThrows ( $expression , $class = 'Exception' , $message = '' )
 
public static nullOrTrue ( $value , $message = '' )
 
public static nullOrUnicodeLetters ( $value , $message = '' )
 
public static nullOrUniqueValues ( $values , $message = '' )
 
public static nullOrUpper ( $value , $message = '' )
 
public static nullOrUuid ( $value , $message = '' )
 
public static nullOrValidArrayKey ( $value , $message = '' )
 
public static nullOrWritable ( $value , $message = '' )
 
public static numeric ( $value , $message = '' )
 
public static object ( $value , $message = '' )
 
public static oneOf ( $value , array $values , $message = '' )
 

A more human-readable alias of Assert::inArray().

public static positiveInteger ( $value , $message = '' )
 
public static propertyExists ( $classOrObject , $property , $message = '' )
 
public static propertyNotExists ( $classOrObject , $property , $message = '' )
 
public static range ( $value , $min , $max , $message = '' )
 

Inclusive range, so Assert::(3, 3, 5) passes.

public static readable ( $value , $message = '' )
 
public static regex ( $value , $pattern , $message = '' )
 
public static resource ( $value , $type = NULL , $message = '' )
 
public static same ( $value , $expect , $message = '' )
 
public static scalar ( $value , $message = '' )
 
public static startsWith ( $value , $prefix , $message = '' )
 
public static startsWithLetter ( $value , $message = '' )
 
public static string ( $value , $message = '' )
 
public static stringNotEmpty ( $value , $message = '' )
 
public static subclassOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert class-string|ExpectedType $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
public static throws ( Closure $expression , $class = 'Exception' , $message = '' )
 
public static true ( $value , $message = '' )
 
public static unicodeLetters ( $value , $message = '' )
 
public static uniqueValues ( array $values , $message = '' )
 

Does non strict comparisons on the items, so ['3', 3] will not pass the assertion.

public static upper ( $value , $message = '' )
 
public static uuid ( $value , $message = '' )
 
public static validArrayKey ( $value , $message = '' )
 

Checks if a value is a valid array key (int or string).

public static writable ( $value , $message = '' )
 
Methods
protected static reportInvalidArgument ( $message )
 
protected static strlen ( $value )
protected static typeToString ( $value )
 
  • param mixed $value
  • return string
protected static valueToString ( $value )
 
  • param mixed $value
  • return string
Methods
private __construct ()
Methods
public static __callStatic ( $name , $arguments )
 
  • throws BadMethodCallException
public static allAlnum ( $value , $message = '' )
 
public static allAlpha ( $value , $message = '' )
 
public static allBoolean ( $value , $message = '' )
 
public static allClassExists ( $value , $message = '' )
 
public static allContains ( $value , $subString , $message = '' )
 
public static allCount ( $array , $number , $message = '' )
 
public static allCountBetween ( $array , $min , $max , $message = '' )
 
public static allDigits ( $value , $message = '' )
 
public static allDirectory ( $value , $message = '' )
 
public static allEmail ( $value , $message = '' )
 
public static allEndsWith ( $value , $suffix , $message = '' )
 
public static allEq ( $value , $expect , $message = '' )
 
public static allFalse ( $value , $message = '' )
 
public static allFile ( $value , $message = '' )
 
public static allFileExists ( $value , $message = '' )
 
public static allFloat ( $value , $message = '' )
 
public static allGreaterThan ( $value , $limit , $message = '' )
 
public static allGreaterThanEq ( $value , $limit , $message = '' )
 
public static allImplementsInterface ( $value , $interface , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $interface
  • psalm-assert iterable<class-string> $value
  • param mixed $value
  • param mixed $interface
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static allInArray ( $value , $values , $message = '' )
 
public static allInteger ( $value , $message = '' )
 
public static allIntegerish ( $value , $message = '' )
 
public static allInterfaceExists ( $value , $message = '' )
 
public static allIp ( $value , $message = '' )
 
public static allIpv4 ( $value , $message = '' )
 
public static allIpv6 ( $value , $message = '' )
 
public static allIsAnyOf ( $value , $classes , $message = '' )
 
public static allIsAOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert iterable<ExpectedType|class-string> $value
  • param iterable | string> $value
  • param string $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static allIsArray ( $value , $message = '' )
 
public static allIsArrayAccessible ( $value , $message = '' )
 
public static allIsCallable ( $value , $message = '' )
 
public static allIsCountable ( $value , $message = '' )
 
public static allIsEmpty ( $value , $message = '' )
 
public static allIsInstanceOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert iterable $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static allIsInstanceOfAny ( $value , $classes , $message = '' )
 
public static allIsIterable ( $value , $message = '' )
 
public static allIsList ( $array , $message = '' )
 
public static allIsMap ( $array , $message = '' )
 
  • psalm-pure
  • psalm-template T
  • psalm-param iterable<mixed|array> $array
  • psalm-assert iterable<array<string, T>> $array
  • param mixed $array
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static allIsNonEmptyList ( $array , $message = '' )
 
public static allIsNonEmptyMap ( $array , $message = '' )
 
public static allIsNotA ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template UnexpectedType of object
  • psalm-param class-string $class
  • param iterable | string> $value
  • param string $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static allIsTraversable ( $value , $message = '' )
 
public static allKeyExists ( $array , $key , $message = '' )
 
public static allKeyNotExists ( $array , $key , $message = '' )
 
public static allLength ( $value , $length , $message = '' )
 
public static allLengthBetween ( $value , $min , $max , $message = '' )
 
public static allLessThan ( $value , $limit , $message = '' )
 
public static allLessThanEq ( $value , $limit , $message = '' )
 
public static allLower ( $value , $message = '' )
 
public static allMaxCount ( $array , $max , $message = '' )
 
public static allMaxLength ( $value , $max , $message = '' )
 
public static allMethodExists ( $classOrObject , $method , $message = '' )
 
public static allMethodNotExists ( $classOrObject , $method , $message = '' )
 
public static allMinCount ( $array , $min , $message = '' )
 
public static allMinLength ( $value , $min , $message = '' )
 
public static allNatural ( $value , $message = '' )
 
public static allNotContains ( $value , $subString , $message = '' )
 
public static allNotEmpty ( $value , $message = '' )
 
public static allNotEndsWith ( $value , $suffix , $message = '' )
 
public static allNotEq ( $value , $expect , $message = '' )
 
public static allNotFalse ( $value , $message = '' )
 
public static allNotInstanceOf ( $value , $class , $message = '' )
 
public static allNotNull ( $value , $message = '' )
 
public static allNotRegex ( $value , $pattern , $message = '' )
 
public static allNotSame ( $value , $expect , $message = '' )
 
public static allNotStartsWith ( $value , $prefix , $message = '' )
 
public static allNotWhitespaceOnly ( $value , $message = '' )
 
public static allNull ( $value , $message = '' )
 
public static allNumeric ( $value , $message = '' )
 
public static allObject ( $value , $message = '' )
 
public static allOneOf ( $value , $values , $message = '' )
 
public static allPositiveInteger ( $value , $message = '' )
 
public static allPropertyExists ( $classOrObject , $property , $message = '' )
 
public static allPropertyNotExists ( $classOrObject , $property , $message = '' )
 
public static allRange ( $value , $min , $max , $message = '' )
 
public static allReadable ( $value , $message = '' )
 
public static allRegex ( $value , $pattern , $message = '' )
 
public static allResource ( $value , $type = NULL , $message = '' )
 
public static allSame ( $value , $expect , $message = '' )
 
public static allScalar ( $value , $message = '' )
 
public static allStartsWith ( $value , $prefix , $message = '' )
 
public static allStartsWithLetter ( $value , $message = '' )
 
public static allString ( $value , $message = '' )
 
public static allStringNotEmpty ( $value , $message = '' )
 
public static allSubclassOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert iterable<class-string|ExpectedType> $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static allThrows ( $expression , $class = 'Exception' , $message = '' )
 
public static allTrue ( $value , $message = '' )
 
public static allUnicodeLetters ( $value , $message = '' )
 
public static allUniqueValues ( $values , $message = '' )
 
public static allUpper ( $value , $message = '' )
 
public static allUuid ( $value , $message = '' )
 
public static allValidArrayKey ( $value , $message = '' )
 
public static allWritable ( $value , $message = '' )
 
public static alnum ( $value , $message = '' )
 
public static alpha ( $value , $message = '' )
 
public static boolean ( $value , $message = '' )
 
public static classExists ( $value , $message = '' )
 
public static contains ( $value , $subString , $message = '' )
 
public static count ( $array , $number , $message = '' )
 

Does not check if $array is countable, this can generate a warning on php versions after 7.2.

public static countBetween ( $array , $min , $max , $message = '' )
 

Does not check if $array is countable, this can generate a warning on php versions after 7.2.

public static digits ( $value , $message = '' )
 
public static directory ( $value , $message = '' )
 
public static email ( $value , $message = '' )
 
public static endsWith ( $value , $suffix , $message = '' )
 
public static eq ( $value , $expect , $message = '' )
 
public static false ( $value , $message = '' )
 
public static file ( $value , $message = '' )
 
public static fileExists ( $value , $message = '' )
 

Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file.

public static float ( $value , $message = '' )
 
public static greaterThan ( $value , $limit , $message = '' )
 
public static greaterThanEq ( $value , $limit , $message = '' )
 
public static implementsInterface ( $value , $interface , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $interface
  • psalm-assert class-string $value
  • param mixed $value
  • param mixed $interface
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
public static inArray ( $value , array $values , $message = '' )
 

Does strict comparison, so Assert::inArray(3, ['3']) does not pass the assertion.

public static integer ( $value , $message = '' )
 
public static integerish ( $value , $message = '' )
 
public static interfaceExists ( $value , $message = '' )
 
public static ip ( $value , $message = '' )
 
public static ipv4 ( $value , $message = '' )
 
public static ipv6 ( $value , $message = '' )
 
public static isAnyOf ( $value , array $classes , $message = '' )
 
public static isAOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert ExpectedType|class-string $value
  • param object | string $value
  • param string $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
public static isArray ( $value , $message = '' )
 
public static isArrayAccessible ( $value , $message = '' )
 
public static isCallable ( $value , $message = '' )
 
public static isCountable ( $value , $message = '' )
 
public static isEmpty ( $value , $message = '' )
 
public static isInstanceOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert ExpectedType $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
public static isInstanceOfAny ( $value , array $classes , $message = '' )
 
public static isIterable ( $value , $message = '' )
 
public static isList ( $array , $message = '' )
 
public static isMap ( $array , $message = '' )
 
public static isNonEmptyList ( $array , $message = '' )
 
public static isNonEmptyMap ( $array , $message = '' )
 
public static isNotA ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template UnexpectedType of object
  • psalm-param class-string $class
  • psalm-assert !UnexpectedType $value
  • psalm-assert !class-string $value
  • param object | string $value
  • param string $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
public static isTraversable ( $value , $message = '' )
 
public static keyExists ( $array , $key , $message = '' )
 
public static keyNotExists ( $array , $key , $message = '' )
 
public static length ( $value , $length , $message = '' )
 
public static lengthBetween ( $value , $min , $max , $message = '' )
 

Inclusive , so Assert::lengthBetween('asd', 3, 5); passes the assertion.

public static lessThan ( $value , $limit , $message = '' )
 
public static lessThanEq ( $value , $limit , $message = '' )
 
public static lower ( $value , $message = '' )
 
public static maxCount ( $array , $max , $message = '' )
 

Does not check if $array is countable, this can generate a warning on php versions after 7.2.

public static maxLength ( $value , $max , $message = '' )
 

Inclusive max.

public static methodExists ( $classOrObject , $method , $message = '' )
 
public static methodNotExists ( $classOrObject , $method , $message = '' )
 
public static minCount ( $array , $min , $message = '' )
 

Does not check if $array is countable, this can generate a warning on php versions after 7.2.

public static minLength ( $value , $min , $message = '' )
 

Inclusive min.

public static natural ( $value , $message = '' )
 
public static notContains ( $value , $subString , $message = '' )
 
public static notEmpty ( $value , $message = '' )
 
public static notEndsWith ( $value , $suffix , $message = '' )
 
public static notEq ( $value , $expect , $message = '' )
 
public static notFalse ( $value , $message = '' )
 
public static notInstanceOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert !ExpectedType $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
public static notNull ( $value , $message = '' )
 
public static notRegex ( $value , $pattern , $message = '' )
 
public static notSame ( $value , $expect , $message = '' )
 
public static notStartsWith ( $value , $prefix , $message = '' )
 
public static notWhitespaceOnly ( $value , $message = '' )
 
public static null ( $value , $message = '' )
 
public static nullOrAlnum ( $value , $message = '' )
 
public static nullOrAlpha ( $value , $message = '' )
 
public static nullOrBoolean ( $value , $message = '' )
 
public static nullOrClassExists ( $value , $message = '' )
 
public static nullOrContains ( $value , $subString , $message = '' )
 
public static nullOrCount ( $array , $number , $message = '' )
 
public static nullOrCountBetween ( $array , $min , $max , $message = '' )
 
public static nullOrDigits ( $value , $message = '' )
 
public static nullOrDirectory ( $value , $message = '' )
 
public static nullOrEmail ( $value , $message = '' )
 
public static nullOrEndsWith ( $value , $suffix , $message = '' )
 
public static nullOrEq ( $value , $expect , $message = '' )
 
public static nullOrFalse ( $value , $message = '' )
 
public static nullOrFile ( $value , $message = '' )
 
public static nullOrFileExists ( $value , $message = '' )
 
public static nullOrFloat ( $value , $message = '' )
 
public static nullOrGreaterThan ( $value , $limit , $message = '' )
 
public static nullOrGreaterThanEq ( $value , $limit , $message = '' )
 
public static nullOrImplementsInterface ( $value , $interface , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $interface
  • psalm-assert class-string|null $value
  • param mixed $value
  • param mixed $interface
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static nullOrInArray ( $value , $values , $message = '' )
 
public static nullOrInteger ( $value , $message = '' )
 
public static nullOrIntegerish ( $value , $message = '' )
 
public static nullOrInterfaceExists ( $value , $message = '' )
 
public static nullOrIp ( $value , $message = '' )
 
public static nullOrIpv4 ( $value , $message = '' )
 
public static nullOrIpv6 ( $value , $message = '' )
 
public static nullOrIsAnyOf ( $value , $classes , $message = '' )
 
public static nullOrIsAOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert ExpectedType|class-string|null $value
  • param object | string | null $value
  • param string $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static nullOrIsArray ( $value , $message = '' )
 
public static nullOrIsArrayAccessible ( $value , $message = '' )
 
public static nullOrIsCallable ( $value , $message = '' )
 
public static nullOrIsCountable ( $value , $message = '' )
 
public static nullOrIsEmpty ( $value , $message = '' )
 
public static nullOrIsInstanceOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert ExpectedType|null $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static nullOrIsInstanceOfAny ( $value , $classes , $message = '' )
 
public static nullOrIsIterable ( $value , $message = '' )
 
public static nullOrIsList ( $array , $message = '' )
 
public static nullOrIsMap ( $array , $message = '' )
 
public static nullOrIsNonEmptyList ( $array , $message = '' )
 
public static nullOrIsNonEmptyMap ( $array , $message = '' )
 
public static nullOrIsNotA ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template UnexpectedType of object
  • psalm-param class-string $class
  • param object | string | null $value
  • param string $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static nullOrIsTraversable ( $value , $message = '' )
 
public static nullOrKeyExists ( $array , $key , $message = '' )
 
public static nullOrKeyNotExists ( $array , $key , $message = '' )
 
public static nullOrLength ( $value , $length , $message = '' )
 
public static nullOrLengthBetween ( $value , $min , $max , $message = '' )
 
public static nullOrLessThan ( $value , $limit , $message = '' )
 
public static nullOrLessThanEq ( $value , $limit , $message = '' )
 
public static nullOrLower ( $value , $message = '' )
 
public static nullOrMaxCount ( $array , $max , $message = '' )
 
public static nullOrMaxLength ( $value , $max , $message = '' )
 
public static nullOrMethodExists ( $classOrObject , $method , $message = '' )
 
public static nullOrMethodNotExists ( $classOrObject , $method , $message = '' )
 
public static nullOrMinCount ( $array , $min , $message = '' )
 
public static nullOrMinLength ( $value , $min , $message = '' )
 
public static nullOrNatural ( $value , $message = '' )
 
public static nullOrNotContains ( $value , $subString , $message = '' )
 
public static nullOrNotEmpty ( $value , $message = '' )
 
public static nullOrNotEndsWith ( $value , $suffix , $message = '' )
 
public static nullOrNotEq ( $value , $expect , $message = '' )
 
public static nullOrNotFalse ( $value , $message = '' )
 
public static nullOrNotInstanceOf ( $value , $class , $message = '' )
 
public static nullOrNotRegex ( $value , $pattern , $message = '' )
 
public static nullOrNotSame ( $value , $expect , $message = '' )
 
public static nullOrNotStartsWith ( $value , $prefix , $message = '' )
 
public static nullOrNotWhitespaceOnly ( $value , $message = '' )
 
public static nullOrNumeric ( $value , $message = '' )
 
public static nullOrObject ( $value , $message = '' )
 
public static nullOrOneOf ( $value , $values , $message = '' )
 
public static nullOrPositiveInteger ( $value , $message = '' )
 
public static nullOrPropertyExists ( $classOrObject , $property , $message = '' )
 
public static nullOrPropertyNotExists ( $classOrObject , $property , $message = '' )
 
public static nullOrRange ( $value , $min , $max , $message = '' )
 
public static nullOrReadable ( $value , $message = '' )
 
public static nullOrRegex ( $value , $pattern , $message = '' )
 
public static nullOrResource ( $value , $type = NULL , $message = '' )
 
public static nullOrSame ( $value , $expect , $message = '' )
 
public static nullOrScalar ( $value , $message = '' )
 
public static nullOrStartsWith ( $value , $prefix , $message = '' )
 
public static nullOrStartsWithLetter ( $value , $message = '' )
 
public static nullOrString ( $value , $message = '' )
 
public static nullOrStringNotEmpty ( $value , $message = '' )
 
public static nullOrSubclassOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert class-string|ExpectedType|null $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
  • return void
public static nullOrThrows ( $expression , $class = 'Exception' , $message = '' )
 
public static nullOrTrue ( $value , $message = '' )
 
public static nullOrUnicodeLetters ( $value , $message = '' )
 
public static nullOrUniqueValues ( $values , $message = '' )
 
public static nullOrUpper ( $value , $message = '' )
 
public static nullOrUuid ( $value , $message = '' )
 
public static nullOrValidArrayKey ( $value , $message = '' )
 
public static nullOrWritable ( $value , $message = '' )
 
public static numeric ( $value , $message = '' )
 
public static object ( $value , $message = '' )
 
public static oneOf ( $value , array $values , $message = '' )
 

A more human-readable alias of Assert::inArray().

public static positiveInteger ( $value , $message = '' )
 
public static propertyExists ( $classOrObject , $property , $message = '' )
 
public static propertyNotExists ( $classOrObject , $property , $message = '' )
 
public static range ( $value , $min , $max , $message = '' )
 

Inclusive range, so Assert::(3, 3, 5) passes.

public static readable ( $value , $message = '' )
 
public static regex ( $value , $pattern , $message = '' )
 
protected static reportInvalidArgument ( $message )
 
public static resource ( $value , $type = NULL , $message = '' )
 
public static same ( $value , $expect , $message = '' )
 
public static scalar ( $value , $message = '' )
 
public static startsWith ( $value , $prefix , $message = '' )
 
public static startsWithLetter ( $value , $message = '' )
 
public static string ( $value , $message = '' )
 
public static stringNotEmpty ( $value , $message = '' )
 
protected static strlen ( $value )
public static subclassOf ( $value , $class , $message = '' )
 
  • psalm-pure
  • psalm-template ExpectedType of object
  • psalm-param class-string $class
  • psalm-assert class-string|ExpectedType $value
  • param mixed $value
  • param string | object $class
  • param string $message
  • throws Webmozart\Assert\InvalidArgumentException
public static throws ( Closure $expression , $class = 'Exception' , $message = '' )
 
public static true ( $value , $message = '' )
 
protected static typeToString ( $value )
 
  • param mixed $value
  • return string
public static unicodeLetters ( $value , $message = '' )
 
public static uniqueValues ( array $values , $message = '' )
 

Does non strict comparisons on the items, so ['3', 3] will not pass the assertion.

public static upper ( $value , $message = '' )
 
public static uuid ( $value , $message = '' )
 
public static validArrayKey ( $value , $message = '' )
 

Checks if a value is a valid array key (int or string).

protected static valueToString ( $value )
 
  • param mixed $value
  • return string
public static writable ( $value , $message = '' )
 
© 2022 Bruce Wells
Search Namespaces \ Classes
Configuration