Showing preview only (387K chars total). Download the full file or copy to clipboard to get everything.
Repository: webmozarts/assert
Branch: master
Commit: ff31ad6efc62
Files: 124
Total size: 356.6 KB
Directory structure:
gitextract_vsvow73w/
├── .editorconfig
├── .gitattributes
├── .github/
│ └── workflows/
│ └── ci.yaml
├── .gitignore
├── .php-cs-fixer.php
├── CHANGELOG.md
├── LICENSE
├── README.md
├── bin/
│ ├── generate.php
│ └── src/
│ └── MixinGenerator.php
├── composer.json
├── phpunit.xml.dist
├── psalm.xml
├── src/
│ ├── Assert.php
│ ├── InvalidArgumentException.php
│ └── Mixin.php
├── tests/
│ ├── AssertTest.php
│ ├── DummyEnum.php
│ ├── ProjectCodeTest.php
│ └── static-analysis/
│ ├── assert-alnum.php
│ ├── assert-alpha.php
│ ├── assert-boolean.php
│ ├── assert-classExists.php
│ ├── assert-contains.php
│ ├── assert-count.php
│ ├── assert-countBetween.php
│ ├── assert-digits.php
│ ├── assert-directory.php
│ ├── assert-email.php
│ ├── assert-endsWith.php
│ ├── assert-eq.php
│ ├── assert-false.php
│ ├── assert-file.php
│ ├── assert-fileExists.php
│ ├── assert-float.php
│ ├── assert-greaterThan.php
│ ├── assert-greaterThanEq.php
│ ├── assert-implementsInterface.php
│ ├── assert-inArray.php
│ ├── assert-integer.php
│ ├── assert-integerish.php
│ ├── assert-interfaceExists.php
│ ├── assert-ip.php
│ ├── assert-ipv4.php
│ ├── assert-ipv6.php
│ ├── assert-isAOf.php
│ ├── assert-isAnyOf.php
│ ├── assert-isArray.php
│ ├── assert-isArrayAccessible.php
│ ├── assert-isCallable.php
│ ├── assert-isCountable.php
│ ├── assert-isEmpty.php
│ ├── assert-isInitialized.php
│ ├── assert-isInstanceOf.php
│ ├── assert-isInstanceOfAny.php
│ ├── assert-isIterable.php
│ ├── assert-isList.php
│ ├── assert-isMap.php
│ ├── assert-isNonEmptyList.php
│ ├── assert-isNonEmptyMap.php
│ ├── assert-isNotA.php
│ ├── assert-isStatic.php
│ ├── assert-keyExists.php
│ ├── assert-keyNotExists.php
│ ├── assert-length.php
│ ├── assert-lengthBetween.php
│ ├── assert-lessThan.php
│ ├── assert-lessThanEq.php
│ ├── assert-lower.php
│ ├── assert-maxCount.php
│ ├── assert-maxLength.php
│ ├── assert-methodExists.php
│ ├── assert-methodNotExists.php
│ ├── assert-minCount.php
│ ├── assert-minLength.php
│ ├── assert-natural.php
│ ├── assert-negativeInteger.php
│ ├── assert-notContains.php
│ ├── assert-notEmpty.php
│ ├── assert-notEq.php
│ ├── assert-notFalse.php
│ ├── assert-notInArray.php
│ ├── assert-notInstanceOf.php
│ ├── assert-notNegativeInteger.php
│ ├── assert-notNull.php
│ ├── assert-notOneOf.php
│ ├── assert-notRegex.php
│ ├── assert-notSame.php
│ ├── assert-notStatic.php
│ ├── assert-notWhitespaceOnly.php
│ ├── assert-null.php
│ ├── assert-numeric.php
│ ├── assert-object.php
│ ├── assert-objectish.php
│ ├── assert-oneOf.php
│ ├── assert-positiveInteger.php
│ ├── assert-propertyExists.php
│ ├── assert-propertyNotExists.php
│ ├── assert-psalm-notRedundant.php
│ ├── assert-psalm-preserveContainerType.php
│ ├── assert-psalm-preserveStringType.php
│ ├── assert-range.php
│ ├── assert-readable.php
│ ├── assert-regex.php
│ ├── assert-resource.php
│ ├── assert-same.php
│ ├── assert-scalar.php
│ ├── assert-startsWith.php
│ ├── assert-startsWithLetter.php
│ ├── assert-string.php
│ ├── assert-stringNotEmpty.php
│ ├── assert-subclassOf.php
│ ├── assert-throws.php
│ ├── assert-true.php
│ ├── assert-unicodeLetters.php
│ ├── assert-uniqueValues.php
│ ├── assert-upper.php
│ ├── assert-uuid.php
│ ├── assert-validArrayKey.php
│ └── assert-writable.php
└── tools/
├── php-cs-fixer/
│ └── composer.json
├── phpunit/
│ └── composer.json
├── psalm/
│ └── composer.json
└── roave-bc-check/
└── composer.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
root = true
[*]
charset=utf-8
end_of_line=lf
trim_trailing_whitespace=true
insert_final_newline=true
indent_style=space
indent_size=4
[*.{yaml,yml}]
indent_size=2
================================================
FILE: .gitattributes
================================================
/.gitattributes export-ignore
/.gitignore export-ignore
/.github export-ignore
/.php-cs-fixer.php export-ignore
/.editorconfig export-ignore
/psalm.xml export-ignore
/bin export-ignore
/ci export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/tools export-ignore
================================================
FILE: .github/workflows/ci.yaml
================================================
# https://docs.github.com/en/actions
name: CI
on:
pull_request: ~
push:
branches:
- master
jobs:
static-code-analysis:
name: Static Code Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none
extensions: mbstring
- name: Install dependencies
run: >-
composer install
- name: Install tools
run: >-
composer run install-tools
- name: Run code style check
run: >-
composer run cs-check
- name: Run static analysis
run: >-
composer run static-analysis
# Disabled for version 2.0, since there is no BC promise at this time.
# - name: Run backwards compatibility check
# run: >-
# composer run bc-check
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- "8.2"
- "8.3"
- "8.4"
- "8.5"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
extensions: mbstring
- name: Install dependencies
run: >-
composer install
- name: Install phpunit
run: >-
composer --working-dir=tools/phpunit install
- name: Run tests
run: >-
composer run test
windows-tests:
name: Windows tests
runs-on: windows-latest
strategy:
matrix:
php-version:
- "8.2"
- "8.3"
- "8.4"
- "8.5"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
extensions: mbstring
- name: Install dependencies
run: >-
composer install
- name: Install phpunit
run: >-
composer --working-dir=tools/phpunit install
- name: Run tests
run: >-
composer run test
================================================
FILE: .gitignore
================================================
vendor/
/composer.lock
.php-cs-fixer.cache
.phpunit.result.cache
================================================
FILE: .php-cs-fixer.php
================================================
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
;
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'@Symfony' => true,
'ordered_imports' => true,
'array_syntax' => ['syntax' => 'short'],
'fully_qualified_strict_types' => false,
'global_namespace_import' => true,
'no_superfluous_phpdoc_tags' => false,
'phpdoc_annotation_without_dot' => false,
'phpdoc_types_order' => false,
'phpdoc_separation' => ['skip_unlisted_annotations' => true],
'phpdoc_summary' => false,
'phpdoc_to_comment' => false,
'phpdoc_align' => false,
'yoda_style' => false,
])
->setFinder($finder)
;
================================================
FILE: CHANGELOG.md
================================================
Changelog
=========
## 2.1.6
### Fixed
- Corrected docblocks for `list*` methods.
## 2.1.5
### Fixed
- Fixed regression of `instanceOf` messages
## 2.1.4
### Fixed
- Use custom message for more internal calls.
## 2.1.3
### Fixed
- Corrected `isList` type documentation.
- Corrected `isAOf`, `isInstanceOf`, etc type documentation.
## 2.1.2
### Fixed
- Changed `all*` assertion values back to `mixed`.
## 2.1.1
### Fixed
- Optimized `stringNotEmpty` by internally using `notSame`.
## 2.1.0
### Fixed
- Corrected `@param` declaration for `isMap`.
- Pass custom message to internal assertion calls.
## 2.0.0
### Changed
- **BREAKING** Minimum PHP version is now 8.2 (was 7.2).
- **BREAKING** Remove deprecated `isTraversable`, use `isIterable` or `isInstanceOf` instead.
- **BREAKING** Added `declare(strict_types=1)` to all classes.
- Updated CI/CD test matrix to test PHP 8.2, 8.3, 8.4, and 8.5.
- Updated development tools (PHPUnit, Psalm, PHP-CS-Fixer) to supported versions.
- Added explicit return types and parameter types to all methods in both source code and tests.
### Added
- All assertion methods now return the checked value.
- Added `notInArray` and `notOneOf`.
- Added `isInitialized`, to check if a class property is initialized.
- Added `negativeInteger` and `notNegativeInteger`
- Added `isStatic` and `notStatic`
### Fixed
- Corrected validation of emails with unicode characters.
## 1.12.1
### Fixed
- Exclude tools from export.
## 1.12.0
### Fixed
- Corrected messages and typos in various assertions.
- Document `void` return type.
- Prevent UUIDs with trailing newlines from validating.
- Assert values are strings before ctype checks.
## 1.11.0
### Added
* Added explicit (non-magic) `allNullOr*` methods, with `@psalm-assert` annotations, for better Psalm support.
### Changed
* Trait methods will now check the assertion themselves, instead of using `__callStatic`
* `isList` will now deal correctly with (modified) lists that contain `NaN`
* `reportInvalidArgument` now has a return type of `never`.
### Removed
* Removed `symfony/polyfill-ctype` as a dependency, and require `ext-ctype` instead.
* You can still require the `symfony/polyfill-ctype` in your project if you need it, as it provides `ext-ctype`
## 1.10.0
### Added
* On invalid assertion, we throw a `Webmozart\Assert\InvalidArgumentException`
* Added `Assert::positiveInteger()`
### Changed
* Using a trait with real implementations of `all*()` and `nullOr*()` methods to improve psalm compatibility.
### Removed
* Support for PHP <7.2
## 1.9.1
## Fixed
* provisional support for PHP 8.0
## 1.9.0
* added better Psalm support for `all*` & `nullOr*` methods
* These methods are now understood by Psalm through a mixin. You may need a newer version of Psalm in order to use this
* added `@psalm-pure` annotation to `Assert::notFalse()`
* added more `@psalm-assert` annotations where appropriate
## Changed
* the `all*` & `nullOr*` methods are now declared on an interface, instead of `@method` annotations.
This interface is linked to the `Assert` class with a `@mixin` annotation. Most IDEs have supported this
for a long time, and you should not lose any autocompletion capabilities. PHPStan has supported this since
version `0.12.20`. This package is marked incompatible (with a composer conflict) with phpstan version prior to that.
If you do not use PHPStan than this does not matter.
## 1.8.0
### Added
* added `Assert::notStartsWith()`
* added `Assert::notEndsWith()`
* added `Assert::inArray()`
* added `@psalm-pure` annotations to pure assertions
### Fixed
* Exception messages of comparisons between `DateTime(Immutable)` objects now display their date & time.
* Custom Exception messages for `Assert::count()` now use the values to render the exception message.
## 1.7.0 (2020-02-14)
### Added
* added `Assert::notFalse()`
* added `Assert::isAOf()`
* added `Assert::isAnyOf()`
* added `Assert::isNotA()`
## 1.6.0 (2019-11-24)
### Added
* added `Assert::validArrayKey()`
* added `Assert::isNonEmptyList()`
* added `Assert::isNonEmptyMap()`
* added `@throws InvalidArgumentException` annotations to all methods that throw.
* added `@psalm-assert` for the list type to the `isList` assertion.
### Fixed
* `ResourceBundle` & `SimpleXMLElement` now pass the `isCountable` assertions.
They are countable, without implementing the `Countable` interface.
* The doc block of `range` now has the proper variables.
* An empty array will now pass `isList` and `isMap`. As it is a valid form of both.
If a non-empty variant is needed, use `isNonEmptyList` or `isNonEmptyMap`.
### Changed
* Removed some `@psalm-assert` annotations, that were 'side effect' assertions See:
* [#144](https://github.com/webmozart/assert/pull/144)
* [#145](https://github.com/webmozart/assert/issues/145)
* [#146](https://github.com/webmozart/assert/pull/146)
* [#150](https://github.com/webmozart/assert/pull/150)
* If you use Psalm, the minimum version needed is `3.6.0`. Which is enforced through a composer conflict.
If you don't use Psalm, then this has no impact.
## 1.5.0 (2019-08-24)
### Added
* added `Assert::uniqueValues()`
* added `Assert::unicodeLetters()`
* added: `Assert::email()`
* added support for [Psalm](https://github.com/vimeo/psalm), by adding `@psalm-assert` annotations where appropriate.
### Fixed
* `Assert::endsWith()` would not give the correct result when dealing with a multibyte suffix.
* `Assert::length(), minLength, maxLength, lengthBetween` would not give the correct result when dealing with multibyte characters.
**NOTE**: These 2 changes may break your assertions if you relied on the fact that multibyte characters didn't behave correctly.
### Changed
* The names of some variables have been updated to better reflect what they are.
* All function calls are now in their FQN form, slightly increasing performance.
* Tests are now properly ran against HHVM-3.30 and PHP nightly.
### Deprecation
* deprecated `Assert::isTraversable()` in favor of `Assert::isIterable()`
* This was already done in 1.3.0, but it was only done through a silenced `trigger_error`. It is now annotated as well.
## 1.4.0 (2018-12-25)
### Added
* added `Assert::ip()`
* added `Assert::ipv4()`
* added `Assert::ipv6()`
* added `Assert::notRegex()`
* added `Assert::interfaceExists()`
* added `Assert::isList()`
* added `Assert::isMap()`
* added polyfill for ctype
### Fixed
* Special case when comparing objects implementing `__toString()`
## 1.3.0 (2018-01-29)
### Added
* added `Assert::minCount()`
* added `Assert::maxCount()`
* added `Assert::countBetween()`
* added `Assert::isCountable()`
* added `Assert::notWhitespaceOnly()`
* added `Assert::natural()`
* added `Assert::notContains()`
* added `Assert::isArrayAccessible()`
* added `Assert::isInstanceOfAny()`
* added `Assert::isIterable()`
### Fixed
* `stringNotEmpty` will no longer report "0" is an empty string
### Deprecation
* deprecated `Assert::isTraversable()` in favor of `Assert::isIterable()`
## 1.2.0 (2016-11-23)
* added `Assert::throws()`
* added `Assert::count()`
* added extension point `Assert::reportInvalidArgument()` for custom subclasses
## 1.1.0 (2016-08-09)
* added `Assert::object()`
* added `Assert::propertyExists()`
* added `Assert::propertyNotExists()`
* added `Assert::methodExists()`
* added `Assert::methodNotExists()`
* added `Assert::uuid()`
## 1.0.2 (2015-08-24)
* integrated Style CI
* add tests for minimum package dependencies on Travis CI
## 1.0.1 (2015-05-12)
* added support for PHP 5.3.3
## 1.0.0 (2015-05-12)
* first stable release
## 1.0.0-beta (2015-03-19)
* first beta release
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2014 Bernhard Schussek
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: README.md
================================================
Webmozart Assert
================
[](https://packagist.org/packages/webmozart/assert)
[](https://packagist.org/packages/webmozart/assert)
This library contains efficient assertions to test the input and output of
your methods. With these assertions, you can greatly reduce the amount of coding
needed to write a safe implementation.
All assertions in the [`Assert`] class throw an `Webmozart\Assert\InvalidArgumentException` if
they fail.
FAQ
---
**What's the difference to [beberlei/assert]?**
This library is heavily inspired by Benjamin Eberlei's wonderful [assert package],
but fixes a usability issue with error messages that can't be fixed there without
breaking backwards compatibility.
This package features usable error messages by default. However, you can also
easily write custom error messages:
```
Assert::string($path, 'The path is expected to be a string. Got: %s');
```
In [beberlei/assert], the ordering of the `%s` placeholders is different for
every assertion. This package, on the contrary, provides consistent placeholder
ordering for all assertions:
* `%s`: The tested value as string, e.g. `"/foo/bar"`.
* `%2$s`, `%3$s`, ...: Additional assertion-specific values, e.g. the
minimum/maximum length, allowed values, etc.
Check the source code of the assertions to find out details about the additional
available placeholders.
Installation
------------
Use [Composer] to install the package:
```bash
composer require webmozart/assert
```
Example
-------
```php
use Webmozart\Assert\Assert;
class Employee
{
public function __construct($id)
{
Assert::integer($id, 'The employee ID must be an integer. Got: %s');
Assert::greaterThan($id, 0, 'The employee ID must be a positive integer. Got: %s');
}
}
```
If you create an employee with an invalid ID, an exception is thrown:
```php
new Employee('foobar');
// => Webmozart\Assert\InvalidArgumentException:
// The employee ID must be an integer. Got: string
new Employee(-10);
// => Webmozart\Assert\InvalidArgumentException:
// The employee ID must be a positive integer. Got: -10
```
Assertions
----------
The [`Assert`] class provides the following assertions:
### Type Assertions
Method | Description
-------------------------------------------------------- | --------------------------------------------------
`string($value, $message = '')` | Check that a value is a string
`stringNotEmpty($value, $message = '')` | Check that a value is a non-empty string
`integer($value, $message = '')` | Check that a value is an integer
`integerish($value, $message = '')` | Check that a value casts to an integer
`positiveInteger($value, $message = '')` | Check that a value is a positive (non-zero) integer
`negativeInteger($value, $message = '')` | Check that a value is a negative integer
`notNegativeInteger($value, $message = '')` | Check that a value is a non-negative integer
`float($value, $message = '')` | Check that a value is a float
`numeric($value, $message = '')` | Check that a value is numeric
`natural($value, $message = '')` | Check that a value is a non-negative integer
`boolean($value, $message = '')` | Check that a value is a boolean
`scalar($value, $message = '')` | Check that a value is a scalar
`object($value, $message = '')` | Check that a value is an object
`objectish($value, $message = '')` | Check that a value is an object or a string of a class that exists
`resource($value, $type = null, $message = '')` | Check that a value is a resource
`isInitialized($value, $property, $message = '')` | Check that a value has an initialized property
`isCallable($value, $message = '')` | Check that a value is a callable
`isArray($value, $message = '')` | Check that a value is an array
`isIterable($value, $message = '')` | Check that a value is an array or a `\Traversable`
`isCountable($value, $message = '')` | Check that a value is an array or a `\Countable`
`isInstanceOf($value, $class, $message = '')` | Check that a value is an `instanceof` a class
`isInstanceOfAny($value, array $classes, $message = '')` | Check that a value is an `instanceof` at least one class on the array of classes
`notInstanceOf($value, $class, $message = '')` | Check that a value is not an `instanceof` a class
`isAOf($value, $class, $message = '')` | Check that a value is of the class or has one of its parents
`isAnyOf($value, array $classes, $message = '')` | Check that a value is of at least one of the classes or has one of its parents
`isNotA($value, $class, $message = '')` | Check that a value is not of the class or has not one of its parents
`isArrayAccessible($value, $message = '')` | Check that a value can be accessed as an array
`uniqueValues($values, $message = '')` | Check that the given array contains unique values
### Comparison Assertions
Method | Description
----------------------------------------------------- | ------------------------------------------------------------------
`true($value, $message = '')` | Check that a value is `true`
`false($value, $message = '')` | Check that a value is `false`
`notFalse($value, $message = '')` | Check that a value is not `false`
`null($value, $message = '')` | Check that a value is `null`
`notNull($value, $message = '')` | Check that a value is not `null`
`isEmpty($value, $message = '')` | Check that a value is `empty()`
`notEmpty($value, $message = '')` | Check that a value is not `empty()`
`eq($value, $value2, $message = '')` | Check that a value equals another (`==`)
`notEq($value, $value2, $message = '')` | Check that a value does not equal another (`!=`)
`same($value, $value2, $message = '')` | Check that a value is identical to another (`===`)
`notSame($value, $value2, $message = '')` | Check that a value is not identical to another (`!==`)
`greaterThan($value, $value2, $message = '')` | Check that a value is greater than another
`greaterThanEq($value, $value2, $message = '')` | Check that a value is greater than or equal to another
`lessThan($value, $value2, $message = '')` | Check that a value is less than another
`lessThanEq($value, $value2, $message = '')` | Check that a value is less than or equal to another
`range($value, $min, $max, $message = '')` | Check that a value is within a range
`inArray($value, array $values, $message = '')` | Check that a value is one of a list of values
`notInArray($value, array $values, $message = '')` | Check that a value is not one of a list of values
`oneOf($value, array $values, $message = '')` | Check that a value is one of a list of values (alias of `inArray`)
`notOneOf($value, array $values, $message = '')` | Check that a value is not one of a list of values (alias of `notInArray`)
### String Assertions
You should check that a value is a string with `Assert::string()` before making
any of the following assertions.
Method | Description
--------------------------------------------------- | -----------------------------------------------------------------
`contains($value, $subString, $message = '')` | Check that a string contains a substring
`notContains($value, $subString, $message = '')` | Check that a string does not contain a substring
`startsWith($value, $prefix, $message = '')` | Check that a string has a prefix
`notStartsWith($value, $prefix, $message = '')` | Check that a string does not have a prefix
`startsWithLetter($value, $message = '')` | Check that a string starts with a letter
`endsWith($value, $suffix, $message = '')` | Check that a string has a suffix
`notEndsWith($value, $suffix, $message = '')` | Check that a string does not have a suffix
`regex($value, $pattern, $message = '')` | Check that a string matches a regular expression
`notRegex($value, $pattern, $message = '')` | Check that a string does not match a regular expression
`unicodeLetters($value, $message = '')` | Check that a string contains Unicode letters only
`alpha($value, $message = '')` | Check that a string contains letters only
`digits($value, $message = '')` | Check that a string contains digits only
`alnum($value, $message = '')` | Check that a string contains letters and digits only
`lower($value, $message = '')` | Check that a string contains lowercase characters only
`upper($value, $message = '')` | Check that a string contains uppercase characters only
`length($value, $length, $message = '')` | Check that a string has a certain number of characters
`minLength($value, $min, $message = '')` | Check that a string has at least a certain number of characters
`maxLength($value, $max, $message = '')` | Check that a string has at most a certain number of characters
`lengthBetween($value, $min, $max, $message = '')` | Check that a string has a length in the given range
`uuid($value, $message = '')` | Check that a string is a valid UUID
`ip($value, $message = '')` | Check that a string is a valid IP (either IPv4 or IPv6)
`ipv4($value, $message = '')` | Check that a string is a valid IPv4
`ipv6($value, $message = '')` | Check that a string is a valid IPv6
`email($value, $message = '')` | Check that a string is a valid e-mail address
`notWhitespaceOnly($value, $message = '')` | Check that a string contains at least one non-whitespace character
### File Assertions
Method | Description
----------------------------------- | --------------------------------------------------
`fileExists($value, $message = '')` | Check that a value is an existing path
`file($value, $message = '')` | Check that a value is an existing file
`directory($value, $message = '')` | Check that a value is an existing directory
`readable($value, $message = '')` | Check that a value is a readable path
`writable($value, $message = '')` | Check that a value is a writable path
### Object Assertions
Method | Description
----------------------------------------------------- | --------------------------------------------------
`classExists($value, $message = '')` | Check that a value is an existing class name
`subclassOf($value, $class, $message = '')` | Check that a class is a subclass of another
`interfaceExists($value, $message = '')` | Check that a value is an existing interface name
`implementsInterface($value, $class, $message = '')` | Check that a class implements an interface
`propertyExists($value, $property, $message = '')` | Check that a property exists in a class/object
`propertyNotExists($value, $property, $message = '')` | Check that a property does not exist in a class/object
`methodExists($value, $method, $message = '')` | Check that a method exists in a class/object
`methodNotExists($value, $method, $message = '')` | Check that a method does not exist in a class/object
### Array Assertions
Method | Description
-------------------------------------------------- | ------------------------------------------------------------------
`keyExists($array, $key, $message = '')` | Check that a key exists in an array
`keyNotExists($array, $key, $message = '')` | Check that a key does not exist in an array
`validArrayKey($key, $message = '')` | Check that a value is a valid array key (int or string)
`count($array, $number, $message = '')` | Check that an array contains a specific number of elements
`minCount($array, $min, $message = '')` | Check that an array contains at least a certain number of elements
`maxCount($array, $max, $message = '')` | Check that an array contains at most a certain number of elements
`countBetween($array, $min, $max, $message = '')` | Check that an array has a count in the given range
`isList($array, $message = '')` | Check that an array is a non-associative list
`isNonEmptyList($array, $message = '')` | Check that an array is a non-associative list, and not empty
`isMap($array, $message = '')` | Check that an array is associative and has strings as keys
`isNonEmptyMap($array, $message = '')` | Check that an array is associative and has strings as keys, and is not empty
### Function Assertions
Method | Description
------------------------------------------| -----------------------------------------------------------------------------------------------------
`throws($closure, $class, $message = '')` | Check that a function throws a certain exception. Subclasses of the exception class will be accepted.
`isStatic($closure, $message = '')` | Check that a function is static.
`notStatic($closure, $message = '')` | Check that a function is not static.
### Collection Assertions
All of the above assertions can be prefixed with `all*()` to test the contents
of an array or a `\Traversable`:
```php
Assert::allIsInstanceOf($employees, 'Acme\Employee');
```
### Nullable Assertions
All of the above assertions can be prefixed with `nullOr*()` to run the
assertion only if the value is not `null`:
```php
Assert::nullOrString($middleName, 'The middle name must be a string or null. Got: %s');
```
### Extending Assert
The `Assert` class comes with a few methods, which can be overridden to change the class behaviour. You can also extend it to
add your own assertions.
#### Overriding methods
Overriding the following methods in your assertion class allows you to change the behaviour of the assertions:
* `public static function __callStatic($name, $arguments)`
* This method is used to 'create' the `nullOr` and `all` versions of the assertions.
* `protected static function valueToString($value)`
* This method is used for error messages, to convert the value to a string value for displaying. You could use this for representing a value object with a `__toString` method for example.
* `protected static function typeToString($value)`
* This method is used for error messages, to convert a value to a string representing its type.
* `protected static function strlen($value)`
* This method is used to calculate string length for relevant methods, using the `mb_strlen` if available and useful.
* `protected static function reportInvalidArgument($message)`
* This method is called when an assertion fails, with the specified error message. Here you can throw your own exception, or log something.
## Static analysis support
Where applicable, assertion functions are annotated to support Psalm's
[Assertion syntax](https://psalm.dev/docs/annotating_code/assertion_syntax/).
A dedicated [PHPStan Plugin](https://github.com/phpstan/phpstan-webmozart-assert) is
required for proper type support.
Authors
-------
* [Bernhard Schussek] a.k.a. [@webmozart]
* [The Community Contributors]
Contribute
----------
Contributions to the package are always welcome!
* Report any bugs or issues you find on the [issue tracker].
* You can grab the source code at the package's [Git repository].
License
-------
All contents of this package are licensed under the [MIT license].
[beberlei/assert]: https://github.com/beberlei/assert
[assert package]: https://github.com/beberlei/assert
[Composer]: https://getcomposer.org
[Bernhard Schussek]: https://webmozarts.com
[The Community Contributors]: https://github.com/webmozart/assert/graphs/contributors
[issue tracker]: https://github.com/webmozart/assert/issues
[Git repository]: https://github.com/webmozart/assert
[@webmozart]: https://twitter.com/webmozart
[MIT license]: LICENSE
[`Assert`]: src/Assert.php
================================================
FILE: bin/generate.php
================================================
<?php
declare(strict_types=1);
/**
* this file is used by maintainers of the library to re-generate the type definitions
* of webmozart/assert: you probably don't need to use it.
*/
use Webmozart\Assert\Bin\MixinGenerator;
require_once __DIR__.'/../vendor/autoload.php';
file_put_contents(__DIR__.'/../src/Mixin.php', (new MixinGenerator())->generate());
echo "Done.";
================================================
FILE: bin/src/MixinGenerator.php
================================================
<?php
declare(strict_types=1);
namespace Webmozart\Assert\Bin;
use ArrayAccess;
use Countable;
use ReflectionClass;
use ReflectionException;
use ReflectionIntersectionType;
use ReflectionMethod;
use ReflectionNamedType;
use ReflectionType;
use ReflectionUnionType;
use RuntimeException;
use Throwable;
use Webmozart\Assert\Assert;
final class MixinGenerator
{
/**
* @psalm-var list<string>
*
* @var string[]
*/
private array $unsupportedMethods = [
'nullOrNotInstanceOf', // not supported by psalm (https://github.com/vimeo/psalm/issues/3443)
'allNotInstanceOf', // not supported by psalm (https://github.com/vimeo/psalm/issues/3443)
'nullOrNotEmpty', // not supported by psalm (https://github.com/vimeo/psalm/issues/3443)
'allNotEmpty', // not supported by psalm (https://github.com/vimeo/psalm/issues/3443)
'allNotNull', // not supported by psalm (https://github.com/vimeo/psalm/issues/3443)
'nullOrIsNotA', // not supported by psalm (https://github.com/vimeo/psalm/issues/3444)
'allIsNotA', // not supported by psalm (https://github.com/vimeo/psalm/issues/3444)
'nullOrNotFalse', // not supported by psalm (https://github.com/vimeo/psalm/issues/3443)
'allNotFalse', // not supported by psalm (https://github.com/vimeo/psalm/issues/3443)
'nullOrUpper', // not supported by psalm (https://github.com/vimeo/psalm/issues/3443)
'allUpper', // not supported by psalm (https://github.com/vimeo/psalm/issues/3443)
'nullOrIsNonEmptyMap', // not supported by psalm (https://github.com/vimeo/psalm/issues/3444)
'allIsNonEmptyMap', // not supported by psalm (https://github.com/vimeo/psalm/issues/3444)
];
private array $skipGenerateForMethods = [
'isInitialized',
];
/**
* @psalm-var list<string>
*
* @var string[]
*/
private array $skipMethods = [
'nullOrNull', // meaningless
'nullOrNotNull', // meaningless
'allNullOrNull', // meaningless
'allNullOrNotNull', // meaningless
];
public function generate(): string
{
return \sprintf(
<<<'PHP'
<?php
declare(strict_types=1);
%s
PHP
,
$this->namespace()
);
}
private function namespace(): string
{
$assert = new ReflectionClass(Assert::class);
$namespace = sprintf("namespace %s;\n\n", $assert->getNamespaceName());
$namespace .= sprintf("use %s;\n", ArrayAccess::class);
$namespace .= sprintf("use %s;\n", Countable::class);
$namespace .= sprintf("use %s;\n", Throwable::class);
$namespace .= "\n";
$namespace .= $this->trait($assert);
return $namespace;
}
private function trait(ReflectionClass $assert): string
{
$staticMethods = $this->getMethods($assert);
$declaredMethods = [];
foreach ($staticMethods as $method) {
$nullOr = $this->nullOr($method, 4);
if (null !== $nullOr) {
$declaredMethods[] = $nullOr;
}
$all = $this->all($method, 4);
if (null !== $all) {
$declaredMethods[] = $all;
}
$allNullOr = $this->allNullOr($method, 4);
if (null !== $allNullOr) {
$declaredMethods[] = $allNullOr;
}
}
return \sprintf(
<<<'PHP'
/**
* This trait provides nullOr*, all* and allNullOr* variants of assertion base methods.
* Do not use this trait directly: it will change, and is not designed for reuse.
*/
trait Mixin
{
%s
}
PHP
,
\implode("\n\n", $declaredMethods)
);
}
/**
* @param ReflectionMethod $method
* @param int $indent
*
* @return string|null
*
* @throws ReflectionException
*/
private function nullOr(ReflectionMethod $method, int $indent): ?string
{
return $this->assertion($method, 'nullOr%s', '%s|null', $indent, function (string $firstParameter, string $parameters) use ($method) {
return <<<BODY
null === {$firstParameter} || static::{$method->name}({$firstParameter}, {$parameters});
return {$firstParameter};
BODY;
});
}
/**
* @param ReflectionMethod $method
* @param int $indent
*
* @return string|null
*
* @throws ReflectionException
*/
private function all(ReflectionMethod $method, int $indent): ?string
{
return $this->assertion($method, 'all%s', 'iterable<%s>', $indent, function (string $firstParameter, string $parameters) use ($method) {
return <<<BODY
static::isIterable({$firstParameter});
foreach ({$firstParameter} as \$entry) {
static::{$method->name}(\$entry, {$parameters});
}
return {$firstParameter};
BODY;
});
}
/**
* @param ReflectionMethod $method
* @param int $indent
*
* @return string|null
*
* @throws ReflectionException
*/
private function allNullOr(ReflectionMethod $method, int $indent): ?string
{
return $this->assertion($method, 'allNullOr%s', 'iterable<%s|null>', $indent, function (string $firstParameter, string $parameters) use ($method) {
return <<<BODY
static::isIterable({$firstParameter});
foreach ({$firstParameter} as \$entry) {
null === \$entry || static::{$method->name}(\$entry, {$parameters});
}
return {$firstParameter};
BODY;
});
}
/**
* @psalm-param callable(string,string):string $body
*
* @param ReflectionMethod $method
* @param string $methodNameTemplate
* @param string $typeTemplate
* @param int $indent
* @param callable $body
*
* @return string|null
*
* @throws ReflectionException
*/
private function assertion(ReflectionMethod $method, string $methodNameTemplate, string $typeTemplate, int $indent, callable $body): ?string
{
$newMethodName = sprintf($methodNameTemplate, ucfirst($method->name));
$comment = $method->getDocComment();
$parsedComment = $this->parseDocComment($comment);
$parameters = [];
/** @psalm-var array<string, scalar|null> $parametersDefaults */
$parametersDefaults = [];
/** @var array<string, string> $parameterTypes */
$parameterTypes = [];
$parametersReflection = $method->getParameters();
$nativeReturnType = 'mixed';
foreach ($parametersReflection as $parameterReflection) {
$parameters[] = $parameterReflection->name;
if ($parameterReflection->isDefaultValueAvailable()) {
$defaultValue = $parameterReflection->getDefaultValue();
$defaultValue = Assert::nullOrScalar($defaultValue);
$parametersDefaults[$parameterReflection->name] = $defaultValue;
}
if ($parameterReflection->hasType()) {
if ($parameterReflection->name === 'value') {
$parameterTypes[$parameterReflection->name] = 'mixed';
$nativeReturnType = match ($typeTemplate) {
'%s|null' => $this->reduceParameterType($parameterReflection->getType()),
'iterable<%s>' => 'iterable',
'iterable<%s|null>' => 'iterable',
};
} else {
$parameterTypes[$parameterReflection->name] = $this->reduceParameterType($parameterReflection->getType());
}
}
}
if (in_array($newMethodName, $this->skipMethods, true)) {
return null;
}
$paramsAdded = false;
$phpdocReturnType = 'mixed';
$phpdocLines = [];
foreach ($parsedComment as $key => $values) {
if ($this->shouldSkipAnnotation($newMethodName, $key)) {
continue;
}
if ($paramsAdded || 'param' === $key) {
$paramsAdded = true;
if (count($phpdocLines) > 0) {
$phpdocLines[] = '';
}
}
if ('deprecated' === $key) {
$phpdocLines[] = '';
}
$longestType = 0;
$longestName = 0;
foreach ($values as $i => $value) {
$parts = $this->splitDocLine($value);
if (('param' === $key || 'psalm-param' === $key) && isset($parts[1]) && isset($parameters[0]) && $parts[1] === '$'.$parameters[0] && 'mixed' !== $parts[0]) {
$parts[0] = $this->applyTypeTemplate($parts[0], $typeTemplate);
$values[$i] = \implode(' ', $parts);
}
}
if ('psalm-return' === $key || 'return' === $key) {
continue;
}
if ('param' === $key) {
[$longestType, $longestName] = $this->findLongestTypeAndName($values);
}
foreach ($values as $value) {
$parts = $this->splitDocLine($value);
$type = $parts[0];
if ('psalm-assert' === $key) {
$type = $this->applyTypeTemplate($type, $typeTemplate);
$phpdocReturnType = $type;
}
if ('param' === $key) {
if (!isset($parts[1])) {
throw new RuntimeException(sprintf('param key must come with type and variable name in method: %s', $method->name));
}
$type = str_pad($type, $longestType, ' ');
$parts[1] = str_pad($parts[1], $longestName, ' ');
}
$comment = sprintf('@%s %s', $key, $type);
if (count($parts) >= 2) {
$comment .= sprintf(' %s', \implode(' ', array_slice($parts, 1)));
}
$phpdocLines[] = trim($comment);
}
if ('deprecated' === $key || 'psalm-pure' === $key || 'psalm-assert' === $key || 'see' === $key) {
$phpdocLines[] = '';
}
}
$phpdocLines[] = '@return '.$phpdocReturnType;
$phpdocLines[] = '';
$phpdocLinesDeduplicatedEmptyLines = [];
foreach ($phpdocLines as $line) {
$currentLine = trim($line);
if ('' === $currentLine && count($phpdocLinesDeduplicatedEmptyLines) > 0) {
$previousLine = trim($phpdocLinesDeduplicatedEmptyLines[count($phpdocLinesDeduplicatedEmptyLines) - 1]);
if ('' === $previousLine) {
continue;
}
}
$phpdocLinesDeduplicatedEmptyLines[] = $line;
}
return $this->staticMethod($newMethodName, $parameters, $parameterTypes, $parametersDefaults, $phpdocLinesDeduplicatedEmptyLines, $indent, $body, $nativeReturnType);
}
private function reduceParameterType(ReflectionType $type): string
{
if ($type instanceof ReflectionIntersectionType) {
return \implode('&', \array_map([$this, 'reduceParameterType'], $type->getTypes()));
}
if ($type instanceof ReflectionUnionType) {
return \implode('|', \array_map([$this, 'reduceParameterType'], $type->getTypes()));
}
$type = Assert::isInstanceOf($type, ReflectionNamedType::class);
if ($type->getName() === 'mixed') {
return $type->getName();
}
return ($type->allowsNull() ? '?' : '') . $type->getName();
}
private function applyTypeTemplate(string $type, string $typeTemplate): string
{
$combinedType = sprintf($typeTemplate, $type);
if ('empty|null' === $combinedType) {
$combinedType = 'empty'; // @see https://github.com/vimeo/psalm/issues/3492
}
return $combinedType;
}
private function shouldSkipAnnotation(string $newMethodName, string $key): bool
{
if (!in_array($newMethodName, $this->unsupportedMethods, true)) {
return false;
}
return 'psalm-assert' === $key || 'psalm-return' === $key;
}
/**
* @psalm-param array<int, string> $values
* @psalm-return array{int, int}
*
* @param string[] $values
*
* @return int[]
*/
private function findLongestTypeAndName(array $values): array
{
$longestType = 0;
$longestName = 0;
foreach ($values as $value) {
$parts = $this->splitDocLine($value);
$type = $parts[0];
if (strlen($type) > $longestType) {
$longestType = strlen($type);
}
if (!isset($parts[1])) {
continue;
}
$name = $parts[1];
if (strlen($name) > $longestName) {
$longestName = strlen($name);
}
}
return [$longestType, $longestName];
}
/**
* @psalm-param list<string> $parameters
* @psalm-param array<string, scalar|null> $defaults
* @psalm-param list<string> $phpdocLines
*
* @param string $name
* @param string[] $parameters
* @param array<string, string> $types
* @param string[] $defaults
* @param array $phpdocLines
* @param int $indent
* @param callable(string,string): string $body
* @param string $returnType
*
* @return string
*/
private function staticMethod(string $name, array $parameters, array $types, array $defaults, array $phpdocLines, int $indent, callable $body, string $returnType): string
{
Assert::notEmpty($parameters);
$indentation = str_repeat(' ', $indent);
$parameterList = \array_map(static fn (string $parameter): string => '$'.$parameter, $parameters);
$firstParameter = \array_shift($parameterList);
$parameterList = \implode(', ', $parameterList);
$methodBody = \preg_replace('/(?<=^|\n)(?!\n)/', $indentation.$indentation, $body($firstParameter, $parameterList));
Assert::stringNotEmpty($methodBody);
$staticFunction = $this->phpdoc($phpdocLines, $indent)."\n";
$staticFunction .= $indentation.'public static function '.$name.$this->functionParameters($parameters, $types, $defaults).": {$returnType}\n"
.$indentation."{\n";
$staticFunction .= $methodBody."\n".$indentation."}";
return $staticFunction;
}
/**
* @psalm-param list<string> $parameters
* @psalm-param array<string, scalar|null> $defaults
*
* @param string[] $parameters
* @param array<string, string> $types
* @param string[] $defaults
*
* @return string
*/
private function functionParameters(array $parameters, array $types, array $defaults): string
{
$result = '';
foreach ($parameters as $i => $parameter) {
if ($i > 0) {
$result .= ', ';
}
Assert::keyExists($types, $parameter);
$result .= $types[$parameter].' $'.$parameter;
if (array_key_exists($parameter, $defaults)) {
$defaultValue = null === $defaults[$parameter] ? 'null' : var_export($defaults[$parameter], true);
$result .= ' = '.$defaultValue;
}
}
return '('.$result.')';
}
/**
* @psalm-param list<string> $lines
*
* @param string[] $lines
* @param int $indent
*
* @return string
*/
private function phpdoc(array $lines, int $indent): string
{
$indentation = str_repeat(' ', $indent);
$phpdoc = $indentation.'/**';
$throws = '';
foreach ($lines as $line) {
if (\str_starts_with($line, '@throws')) {
$throws .= "\n".$indentation.\rtrim(' * '.$line);
} else {
$phpdoc .= "\n".$indentation.\rtrim(' * '.$line);
}
}
if (strlen($throws) > 0) {
$phpdoc .= $throws;
}
$phpdoc .= "\n".$indentation.' */';
return $phpdoc;
}
/**
* @psalm-return array<string, list<string>>
*
* @param string $comment
*
* @return string[][]
*/
private function parseDocComment(string $comment): array
{
$lines = explode("\n", $comment);
$result = [];
foreach ($lines as $line) {
if (preg_match('~^\*\s+@(\S+)(\s+.*)?$~', trim($line), $matches)) {
if (2 === count($matches)) {
$matches[2] = '';
}
$result[$matches[1]][] = trim($matches[2]);
}
}
return $result;
}
/**
* @psalm-return list{string, string|null, string|null}
*
* @param string $line
*
* @return string[]
*/
private function splitDocLine(string $line): array
{
if (!preg_match('~^(.*)\s+(\$\S+)(?:\s+(.*))?$~', $line, $matches)) {
return [$line, null, null];
}
return [trim($matches[1]), $matches[2], $matches[3] ?? null];
}
/**
* @psalm-return list<ReflectionMethod>
*
* @param ReflectionClass $assert
*
* @return ReflectionMethod[]
*/
private function getMethods(ReflectionClass $assert): array
{
$methods = [];
$staticMethods = $assert->getMethods(ReflectionMethod::IS_STATIC);
foreach ($staticMethods as $staticMethod) {
if (in_array($staticMethod->name, $this->skipGenerateForMethods)) {
continue;
}
$modifiers = $staticMethod->getModifiers();
if (0 === ($modifiers & ReflectionMethod::IS_PUBLIC)) {
continue;
}
if ($staticMethod->getFileName() !== $assert->getFileName()) {
// Skip this method - was imported by generated mixin
continue;
}
if ('__callStatic' === $staticMethod->name) {
continue;
}
$methods[] = $staticMethod;
}
return $methods;
}
}
================================================
FILE: composer.json
================================================
{
"name": "webmozart/assert",
"description": "Assertions to validate method input/output with nice error messages.",
"license": "MIT",
"keywords": [
"assert",
"check",
"validate"
],
"authors": [
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
},
{
"name": "Woody Gilk",
"email": "woody.gilk@gmail.com"
}
],
"require": {
"php": "^8.2",
"ext-ctype": "*",
"ext-date": "*",
"ext-filter": "*"
},
"suggest": {
"ext-intl": "",
"ext-simplexml": "",
"ext-spl": ""
},
"autoload": {
"psr-4": {
"Webmozart\\Assert\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Webmozart\\Assert\\Bin\\": "bin/src",
"Webmozart\\Assert\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-feature/2-0": "2.0-dev"
}
},
"scripts": {
"install-tools": [
"composer --working-dir=tools/php-cs-fixer install",
"composer --working-dir=tools/phpunit install",
"composer --working-dir=tools/psalm install",
"composer --working-dir=tools/roave-bc-check install"
],
"update-tools": [
"composer --working-dir=tools/php-cs-fixer update",
"composer --working-dir=tools/phpunit update",
"composer --working-dir=tools/psalm update",
"composer --working-dir=tools/roave-bc-check update"
],
"generate-mixin": "php bin/generate.php",
"bc-check": "./tools/roave-bc-check/vendor/bin/roave-backward-compatibility-check",
"cs-check" : "./tools/php-cs-fixer/vendor/bin/php-cs-fixer check",
"cs-fix": "./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix",
"static-analysis": "./tools/psalm/vendor/bin/psalm --threads=4 --root=$(pwd)",
"test": "./tools/phpunit/vendor/bin/phpunit"
}
}
================================================
FILE: phpunit.xml.dist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="Webmozart Assert Test Suite">
<directory>./tests/</directory>
<exclude>./tests/static-analysis</exclude>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src/</directory>
</include>
</source>
</phpunit>
================================================
FILE: psalm.xml
================================================
<?xml version="1.0"?>
<psalm
errorLevel="8"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="bin"/>
<directory name="tests/static-analysis" />
</projectFiles>
</psalm>
================================================
FILE: src/Assert.php
================================================
<?php
declare(strict_types=1);
/*
* This file is part of the webmozart/assert package.
*
* (c) Bernhard Schussek <bschussek@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Webmozart\Assert;
use ArrayAccess;
use Closure;
use Countable;
use DateTime;
use DateTimeImmutable;
use ReflectionFunction;
use ReflectionProperty;
use Throwable;
use Traversable;
/**
* Efficient assertions to validate the input/output of your methods.
*
* @since 1.0
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class Assert
{
use Mixin;
/**
* @psalm-pure
*
* @psalm-assert string $value
*
* @throws InvalidArgumentException
*/
public static function string(mixed $value, string $message = ''): string
{
if (!\is_string($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a string. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert non-empty-string $value
*
* @psalm-return non-empty-string
*
* @throws InvalidArgumentException
*/
public static function stringNotEmpty(mixed $value, string $message = ''): string
{
static::string($value, $message);
static::notSame($value, '', $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert int $value
*
* @throws InvalidArgumentException
*/
public static function integer(mixed $value, string $message = ''): int
{
if (!\is_int($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an integer. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert numeric $value
*
* @throws InvalidArgumentException
*/
public static function integerish(mixed $value, string $message = ''): int|float|string
{
if (!\is_numeric($value) || $value != (int) $value) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an integerish value. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert positive-int $value
*
* @psalm-return positive-int
*
* @throws InvalidArgumentException
*/
public static function positiveInteger(mixed $value, string $message = ''): int
{
static::integer($value, $message);
if ($value < 1) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a positive integer. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
* @psalm-assert non-negative-int $value
*
* @psalm-return non-negative-int
*
* @throws InvalidArgumentException
*/
public static function notNegativeInteger(mixed $value, string $message = ''): int
{
static::integer($value, $message);
if ($value < 0) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a non negative integer. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
* @psalm-assert negative-int $value
*
* @psalm-return negative-int
*
* @throws InvalidArgumentException
*/
public static function negativeInteger(mixed $value, string $message = ''): int
{
static::integer($value, $message);
if ($value >= 0) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a negative integer. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert float $value
*
* @throws InvalidArgumentException
*/
public static function float(mixed $value, string $message = ''): float
{
if (!\is_float($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a float. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert numeric $value
*
* @throws InvalidArgumentException
*/
public static function numeric(mixed $value, string $message = ''): int|float|string
{
if (!\is_numeric($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a numeric. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert positive-int|0 $value
*
* @psalm-return positive-int|0
*
* @throws InvalidArgumentException
*/
public static function natural(mixed $value, string $message = ''): int
{
if (!\is_int($value) || $value < 0) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a non-negative integer. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert bool $value
*
* @throws InvalidArgumentException
*/
public static function boolean(mixed $value, string $message = ''): bool
{
if (!\is_bool($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a boolean. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert scalar $value
*
* @throws InvalidArgumentException
*/
public static function scalar(mixed $value, string $message = ''): int|bool|float|string
{
if (!\is_scalar($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a scalar. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert object $value
*
* @throws InvalidArgumentException
*/
public static function object(mixed $value, string $message = ''): object
{
if (!\is_object($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an object. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert object|string $value
*
* @psalm-return object|string
*
* @throws InvalidArgumentException
*/
public static function objectish(mixed $value, string $message = ''): object|string
{
if (!\is_object($value) && !\is_string($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an objectish value. Got: %s',
static::typeToString($value)
));
}
if (\is_string($value) && !\class_exists($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected class to be defined. Got: %s',
$value
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert resource $value
*
* @see https://www.php.net/manual/en/function.get-resource-type.php
*
* @psalm-return resource
*
* @throws InvalidArgumentException
*/
public static function resource(mixed $value, ?string $type = null, string $message = ''): mixed
{
if (!\is_resource($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a resource. Got: %s',
static::typeToString($value),
$type // User supplied message might include the second placeholder.
));
}
if ($type && $type !== \get_resource_type($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a resource of type %2$s. Got: %s',
static::typeToString($value),
$type
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert object $value
*
* @throws InvalidArgumentException
*/
public static function isInitialized(mixed $value, string $property, string $message = ''): object
{
Assert::object($value);
$reflectionProperty = new ReflectionProperty($value, $property);
if (!$reflectionProperty->isInitialized($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected property %s to be initialized.',
$property,
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert callable $value
*
* @throws InvalidArgumentException
*/
public static function isCallable(mixed $value, string $message = ''): callable
{
if (!\is_callable($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a callable. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert array $value
*
* @throws InvalidArgumentException
*/
public static function isArray(mixed $value, string $message = ''): array
{
if (!\is_array($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an array. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert array|ArrayAccess $value
*
* @throws InvalidArgumentException
*/
public static function isArrayAccessible(mixed $value, string $message = ''): array|ArrayAccess
{
if (!\is_array($value) && !($value instanceof ArrayAccess)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an array accessible. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert countable $value
*
* @throws InvalidArgumentException
*/
public static function isCountable(mixed $value, string $message = ''): array|Countable
{
if (!\is_array($value) && !($value instanceof Countable)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a countable. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable $value
*
* @throws InvalidArgumentException
*/
public static function isIterable(mixed $value, string $message = ''): iterable
{
if (!\is_array($value) && !($value instanceof Traversable)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an iterable. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @template T of object
*
* @psalm-assert T $value
*
* @psalm-param class-string<T> $class
*
* @return T
*
* @throws InvalidArgumentException
*/
public static function isInstanceOf(mixed $value, mixed $class, string $message = ''): object
{
static::string($class, 'Expected class as a string. Got: %s');
if (!($value instanceof $class)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an instance of %2$s. Got: %s',
static::typeToString($value),
$class
));
}
return $value;
}
/**
* @template T of object
*
* @psalm-assert object $value
* @psalm-param class-string<T> $class
*
* @return !T
*
* @throws InvalidArgumentException
*/
public static function notInstanceOf(mixed $value, mixed $class, string $message = ''): object
{
static::string($class, 'Expected class as a string. Got: %s');
if (!\is_object($value) || $value instanceof $class) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an instance other than %2$s. Got: %s',
static::typeToString($value),
$class
));
}
return $value;
}
/**
* @template T of object
*
* @psalm-assert T $value
*
* @param T $value
*
* @return T
*
* @throws InvalidArgumentException
*/
public static function isInstanceOfAny(mixed $value, mixed $classes, string $message = ''): object
{
static::isIterable($classes);
foreach ($classes as $class) {
static::string($class, 'Expected class as a string. Got: %s');
if ($value instanceof $class) {
return $value;
}
}
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an instance of any of %2$s. Got: %s',
static::typeToString($value),
\implode(', ', \array_map(static::valueToString(...), \iterator_to_array($classes)))
));
}
/**
* @psalm-pure
*
* @template T of object
*
* @psalm-assert T|class-string<T> $value
*
* @return T
*
* @throws InvalidArgumentException
*/
public static function isAOf(mixed $value, mixed $class, string $message = ''): object|string
{
static::string($class, 'Expected class as a string. Got: %s');
if (!\is_a($value, $class, \is_string($value))) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an instance of this class or to this class among its parents "%2$s". Got: %s',
static::valueToString($value),
$class
));
}
return $value;
}
/**
* @psalm-pure
*
* @template T
*
* @psalm-assert object|class-string $value
*
* @param T $value
*
* @return T
*
* @throws InvalidArgumentException
*/
public static function isNotA(mixed $value, mixed $class, string $message = ''): object|string
{
static::objectish($value, $message);
static::string($class, 'Expected class as a string. Got: %s');
if (\is_a($value, $class, \is_string($value))) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an instance of this class or to this class among its parents other than "%2$s". Got: %s',
static::valueToString($value),
$class
));
}
return $value;
}
/**
* @psalm-pure
*
* @param object|string $value
* @param string[] $classes
* @psalm-param array<class-string> $classes
*
* @throws InvalidArgumentException
*/
public static function isAnyOf(mixed $value, mixed $classes, string $message = ''): object|string
{
static::objectish($value, $message);
static::isIterable($classes);
foreach ($classes as $class) {
static::string($class, 'Expected class as a string. Got: %s');
if (\is_a($value, $class, \is_string($value))) {
return $value;
}
}
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an instance of any of this classes or any of those classes among their parents "%2$s". Got: %s',
static::valueToString($value),
\implode(', ', \iterator_to_array($classes))
));
}
/**
* @psalm-pure
*
* @psalm-assert empty $value
*
* @psalm-return empty
*
* @throws InvalidArgumentException
*/
public static function isEmpty(mixed $value, string $message = ''): mixed
{
if (!empty($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an empty value. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert !empty $value
*
* @psalm-return !empty
*
* @throws InvalidArgumentException
*/
public static function notEmpty(mixed $value, string $message = ''): mixed
{
if (empty($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a non-empty value. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert null $value
*
* @throws InvalidArgumentException
*/
public static function null(mixed $value, string $message = ''): null
{
if (null !== $value) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected null. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert !null $value
*
* @psalm-return !null
*
* @throws InvalidArgumentException
*/
public static function notNull(mixed $value, string $message = ''): mixed
{
if (null === $value) {
static::reportInvalidArgument(
$message ?: 'Expected a value other than null.'
);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert true $value
*
* @throws InvalidArgumentException
*/
public static function true(mixed $value, string $message = ''): true
{
if (true !== $value) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to be true. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert false $value
*
* @throws InvalidArgumentException
*/
public static function false(mixed $value, string $message = ''): false
{
if (false !== $value) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to be false. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert !false $value
*
* @throws InvalidArgumentException
*/
public static function notFalse(mixed $value, string $message = ''): mixed
{
if (false === $value) {
static::reportInvalidArgument(
$message ?: 'Expected a value other than false.'
);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-param string $value
*
* @throws InvalidArgumentException
*/
public static function ip(mixed $value, string $message = ''): string
{
static::string($value, $message);
if (false === \filter_var($value, \FILTER_VALIDATE_IP)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to be an IP. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-param string $value
*
* @throws InvalidArgumentException
*/
public static function ipv4(mixed $value, string $message = ''): string
{
static::string($value, $message);
if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to be an IPv4. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-param string $value
*
* @throws InvalidArgumentException
*/
public static function ipv6(mixed $value, string $message = ''): string
{
static::string($value, $message);
if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to be an IPv6. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-param string $value
*
* @throws InvalidArgumentException
*/
public static function email(mixed $value, string $message = ''): string
{
static::string($value, $message);
if (false === \filter_var($value, FILTER_VALIDATE_EMAIL, FILTER_FLAG_EMAIL_UNICODE)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to be a valid e-mail address. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* Does non-strict comparisons on the items, so ['3', 3] will not pass the assertion.
*
* @throws InvalidArgumentException
*/
public static function uniqueValues(mixed $values, string $message = ''): array
{
static::isArray($values);
$allValues = \count($values);
$uniqueValues = \count(\array_unique($values));
if ($allValues !== $uniqueValues) {
$difference = $allValues - $uniqueValues;
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an array of unique values, but %s of them %s duplicated',
$difference,
1 === $difference ? 'is' : 'are'
));
}
return $values;
}
/**
* @throws InvalidArgumentException
*/
public static function eq(mixed $value, mixed $expect, string $message = ''): mixed
{
if ($expect != $value) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value equal to %2$s. Got: %s',
static::valueToString($value),
static::valueToString($expect)
));
}
return $value;
}
/**
* @throws InvalidArgumentException
*/
public static function notEq(mixed $value, mixed $expect, string $message = ''): mixed
{
if ($expect == $value) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a different value than %s.',
static::valueToString($expect)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function same(mixed $value, mixed $expect, string $message = ''): mixed
{
if ($expect !== $value) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value identical to %2$s. Got: %s',
static::valueToString($value),
static::valueToString($expect)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function notSame(mixed $value, mixed $expect, string $message = ''): mixed
{
if ($expect === $value) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value not identical to %s.',
static::valueToString($expect)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function greaterThan(mixed $value, mixed $limit, string $message = ''): mixed
{
if ($value <= $limit) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value greater than %2$s. Got: %s',
static::valueToString($value),
static::valueToString($limit)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function greaterThanEq(mixed $value, mixed $limit, string $message = ''): mixed
{
if ($value < $limit) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value greater than or equal to %2$s. Got: %s',
static::valueToString($value),
static::valueToString($limit)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function lessThan(mixed $value, mixed $limit, string $message = ''): mixed
{
if ($value >= $limit) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value less than %2$s. Got: %s',
static::valueToString($value),
static::valueToString($limit)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function lessThanEq(mixed $value, mixed $limit, string $message = ''): mixed
{
if ($value > $limit) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value less than or equal to %2$s. Got: %s',
static::valueToString($value),
static::valueToString($limit)
));
}
return $value;
}
/**
* Inclusive range, so Assert::(3, 3, 5) passes.
*
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function range(mixed $value, mixed $min, mixed $max, string $message = ''): mixed
{
if ($value < $min || $value > $max) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value between %2$s and %3$s. Got: %s',
static::valueToString($value),
static::valueToString($min),
static::valueToString($max)
));
}
return $value;
}
/**
* A more human-readable alias of Assert::inArray().
*
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function oneOf(mixed $value, mixed $values, string $message = ''): mixed
{
static::inArray($value, $values, $message);
return $value;
}
/**
* Does strict comparison, so Assert::inArray(3, ['3']) does not pass the assertion.
*
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function inArray(mixed $value, mixed $values, string $message = ''): mixed
{
static::isArray($values);
if (!\in_array($value, $values, true)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected one of: %2$s. Got: %s',
static::valueToString($value),
\implode(', ', \array_map(static::valueToString(...), $values))
));
}
return $value;
}
/**
* A more human-readable alias of Assert::notInArray().
*
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function notOneOf(mixed $value, mixed $values, string $message = ''): mixed
{
static::notInArray($value, $values, $message);
return $value;
}
/**
* Check that a value is not present
*
* Does strict comparison, so Assert::notInArray(3, [1, 2, 3]) will not pass
* the assertion, but Assert::notInArray(3, ['3']) will.
*
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function notInArray(mixed $value, mixed $values, string $message = ''): mixed
{
static::isArray($values);
if (\in_array($value, $values, true)) {
static::reportInvalidArgument(\sprintf(
$message ?: '%2$s was not expected to contain a value. Got: %s',
static::valueToString($value),
\implode(', ', \array_map(static::valueToString(...), $values))
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function contains(mixed $value, mixed $subString, string $message = ''): string
{
static::string($value);
static::string($subString);
if (!\str_contains($value, $subString)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to contain %2$s. Got: %s',
static::valueToString($value),
static::valueToString($subString)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function notContains(mixed $value, mixed $subString, string $message = ''): string
{
static::string($value);
static::string($subString);
if (\str_contains($value, $subString)) {
static::reportInvalidArgument(\sprintf(
$message ?: '%2$s was not expected to be contained in a value. Got: %s',
static::valueToString($value),
static::valueToString($subString)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function notWhitespaceOnly(mixed $value, string $message = ''): string
{
static::string($value);
if (\preg_match('/^\s*$/', $value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a non-whitespace string. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function startsWith(mixed $value, mixed $prefix, string $message = ''): string
{
static::string($value);
static::string($prefix);
if (!\str_starts_with($value, $prefix)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to start with %2$s. Got: %s',
static::valueToString($value),
static::valueToString($prefix)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function notStartsWith(mixed $value, mixed $prefix, string $message = ''): string
{
static::string($value);
static::string($prefix);
if (\str_starts_with($value, $prefix)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value not to start with %2$s. Got: %s',
static::valueToString($value),
static::valueToString($prefix)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function startsWithLetter(mixed $value, string $message = ''): string
{
static::string($value);
$valid = isset($value[0]);
if ($valid) {
$locale = \setlocale(LC_CTYPE, '0');
\setlocale(LC_CTYPE, 'C');
$valid = \ctype_alpha($value[0]);
\setlocale(LC_CTYPE, $locale);
}
if (!$valid) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to start with a letter. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function endsWith(mixed $value, mixed $suffix, string $message = ''): string
{
static::string($value);
static::string($suffix);
if (!\str_ends_with($value, $suffix)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to end with %2$s. Got: %s',
static::valueToString($value),
static::valueToString($suffix)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function notEndsWith(mixed $value, mixed $suffix, string $message = ''): string
{
static::string($value);
static::string($suffix);
if (\str_ends_with($value, $suffix)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value not to end with %2$s. Got: %s',
static::valueToString($value),
static::valueToString($suffix)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function regex(mixed $value, mixed $pattern, string $message = ''): string
{
static::string($value);
static::string($pattern);
if (!\preg_match($pattern, $value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'The value %s does not match the expected pattern.',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function notRegex(mixed $value, mixed $pattern, string $message = ''): string
{
static::string($value);
static::string($pattern);
if (\preg_match($pattern, $value, $matches, PREG_OFFSET_CAPTURE)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'The value %s matches the pattern %s (at offset %d).',
static::valueToString($value),
static::valueToString($pattern),
$matches[0][1]
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function unicodeLetters(mixed $value, string $message = ''): string
{
static::string($value, $message);
if (!\preg_match('/^\p{L}+$/u', $value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to contain only Unicode letters. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function alpha(mixed $value, string $message = ''): string
{
static::string($value, $message);
$locale = \setlocale(LC_CTYPE, '0');
\setlocale(LC_CTYPE, 'C');
$valid = !\ctype_alpha($value);
\setlocale(LC_CTYPE, $locale);
if ($valid) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to contain only letters. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function digits(mixed $value, string $message = ''): string
{
static::string($value, $message);
$locale = \setlocale(LC_CTYPE, '0');
\setlocale(LC_CTYPE, 'C');
$valid = !\ctype_digit($value);
\setlocale(LC_CTYPE, $locale);
if ($valid) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to contain digits only. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function alnum(mixed $value, string $message = ''): string
{
static::string($value, $message);
$locale = \setlocale(LC_CTYPE, '0');
\setlocale(LC_CTYPE, 'C');
$valid = !\ctype_alnum($value);
\setlocale(LC_CTYPE, $locale);
if ($valid) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to contain letters and digits only. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert lowercase-string $value
*
* @throws InvalidArgumentException
*/
public static function lower(mixed $value, string $message = ''): string
{
static::string($value, $message);
$locale = \setlocale(LC_CTYPE, '0');
\setlocale(LC_CTYPE, 'C');
$valid = !\ctype_lower($value);
\setlocale(LC_CTYPE, $locale);
if ($valid) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to contain lowercase characters only. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert !lowercase-string $value
*
* @throws InvalidArgumentException
*/
public static function upper(mixed $value, string $message = ''): string
{
static::string($value, $message);
$locale = \setlocale(LC_CTYPE, '0');
\setlocale(LC_CTYPE, 'C');
$valid = !\ctype_upper($value);
\setlocale(LC_CTYPE, $locale);
if ($valid) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to contain uppercase characters only. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function length(mixed $value, mixed $length, string $message = ''): string
{
static::string($value);
static::integerish($length);
if ($length !== static::strlen($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to contain %2$s characters. Got: %s',
static::valueToString($value),
$length
));
}
return $value;
}
/**
* Inclusive min.
*
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function minLength(mixed $value, mixed $min, string $message = ''): string
{
static::string($value);
static::integerish($min);
if (static::strlen($value) < $min) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to contain at least %2$s characters. Got: %s',
static::valueToString($value),
$min
));
}
return $value;
}
/**
* Inclusive max.
*
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function maxLength(mixed $value, mixed $max, string $message = ''): string
{
static::string($value);
static::integerish($max);
if (static::strlen($value) > $max) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to contain at most %2$s characters. Got: %s',
static::valueToString($value),
$max
));
}
return $value;
}
/**
* Inclusive, so Assert::lengthBetween('asd', 3, 5); passes the assertion.
*
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function lengthBetween(mixed $value, mixed $min, mixed $max, string $message = ''): string
{
static::string($value);
static::integerish($min);
static::integerish($max);
$length = static::strlen($value);
if ($length < $min || $length > $max) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s',
static::valueToString($value),
$min,
$max
));
}
return $value;
}
/**
* Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file.
*
* @throws InvalidArgumentException
*/
public static function fileExists(mixed $value, string $message = ''): string
{
static::string($value);
if (!\file_exists($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'The path %s does not exist.',
static::valueToString($value)
));
}
return $value;
}
/**
* @throws InvalidArgumentException
*/
public static function file(mixed $value, string $message = ''): string
{
static::string($value);
if (!\is_file($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'The path %s is not a file.',
static::valueToString($value)
));
}
return $value;
}
/**
* @throws InvalidArgumentException
*/
public static function directory(mixed $value, string $message = ''): string
{
static::string($value);
if (!\is_dir($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'The path %s is not a directory.',
static::valueToString($value)
));
}
return $value;
}
/**
* @throws InvalidArgumentException
*/
public static function readable(mixed $value, string $message = ''): string
{
static::string($value);
if (!\is_readable($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'The path %s is not readable.',
static::valueToString($value)
));
}
return $value;
}
/**
* @throws InvalidArgumentException
*/
public static function writable(mixed $value, string $message = ''): string
{
static::string($value);
if (!\is_writable($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'The path %s is not writable.',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-assert class-string $value
*
* @throws InvalidArgumentException
*/
public static function classExists(mixed $value, string $message = ''): string
{
static::string($value);
if (!\class_exists($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an existing class name. Got: %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @template ExpectedType of object
*
* @psalm-assert class-string<ExpectedType> $value
*
* @param class-string<ExpectedType> $class
*
* @return class-string<ExpectedType>
*
* @throws InvalidArgumentException
*/
public static function subclassOf(mixed $value, mixed $class, string $message = ''): string
{
static::string($value);
static::string($class);
if (!\is_subclass_of($value, $class)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected a sub-class of %2$s. Got: %s',
static::valueToString($value),
static::valueToString($class)
));
}
return $value;
}
/**
* @psalm-assert class-string $value
*
* @throws InvalidArgumentException
*/
public static function interfaceExists(mixed $value, string $message = ''): string
{
static::string($value);
if (!\interface_exists($value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an existing interface name. got %s',
static::valueToString($value)
));
}
return $value;
}
/**
* @psalm-pure
*
* @template ExpectedType of object
*
* @psalm-assert class-string<ExpectedType>|ExpectedType $value
*
* @param class-string<ExpectedType>|ExpectedType $value
* @param class-string<ExpectedType> $interface
*
* @throws InvalidArgumentException
*/
public static function implementsInterface(mixed $value, mixed $interface, string $message = ''): object|string
{
static::objectish($value);
$implements = \class_implements($value);
static::isArray($implements);
if (!\in_array($interface, $implements, true)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an implementation of %2$s. Got: %s',
static::valueToString($value),
static::valueToString($interface)
));
}
return $value;
}
/**
* @psalm-pure
*
* @param string|object $classOrObject
*
* @throws InvalidArgumentException
*/
public static function propertyExists(mixed $classOrObject, mixed $property, string $message = ''): object|string
{
static::objectish($classOrObject);
if (!\property_exists($classOrObject, $property)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected the property %s to exist.',
static::valueToString($property)
));
}
return $classOrObject;
}
/**
* @psalm-pure
*
* @param string|object $classOrObject
* @psalm-param class-string|object $classOrObject
*
* @throws InvalidArgumentException
*/
public static function propertyNotExists(mixed $classOrObject, mixed $property, string $message = ''): mixed
{
if (!(\is_string($classOrObject) || \is_object($classOrObject)) || \property_exists($classOrObject, $property)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected the property %s to not exist.',
static::valueToString($property)
));
}
return $classOrObject;
}
/**
* @psalm-pure
*
* @param string|object $classOrObject
* @psalm-param class-string|object $classOrObject
*
* @throws InvalidArgumentException
*/
public static function methodExists(mixed $classOrObject, mixed $method, string $message = ''): object|string
{
static::objectish($classOrObject);
if (!\method_exists($classOrObject, $method)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected the method %s to exist.',
static::valueToString($method)
));
}
return $classOrObject;
}
/**
* @psalm-pure
*
* @param string|object $classOrObject
* @psalm-param class-string|object $classOrObject
*
* @throws InvalidArgumentException
*/
public static function methodNotExists(mixed $classOrObject, mixed $method, string $message = ''): mixed
{
static::objectish($classOrObject);
if (\method_exists($classOrObject, $method)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected the method %s to not exist.',
static::valueToString($method)
));
}
return $classOrObject;
}
/**
* @psalm-pure
*
* @param string|int $key
*
* @throws InvalidArgumentException
*/
public static function keyExists(mixed $array, string|int $key, string $message = ''): array
{
static::isArray($array, $message);
if (!(isset($array[$key]) || \array_key_exists($key, $array))) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected the key %s to exist.',
static::valueToString($key)
));
}
return $array;
}
/**
* @psalm-pure
*
* @param string|int $key
*
* @throws InvalidArgumentException
*/
public static function keyNotExists(mixed $array, string|int $key, string $message = ''): array
{
static::isArray($array, $message);
if (isset($array[$key]) || \array_key_exists($key, $array)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected the key %s to not exist.',
static::valueToString($key)
));
}
return $array;
}
/**
* Checks if a value is a valid array key (int or string).
*
* @psalm-pure
*
* @psalm-assert array-key $value
*
* @throws InvalidArgumentException
*/
public static function validArrayKey(mixed $value, string $message = ''): string|int
{
if (!(\is_int($value) || \is_string($value))) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected string or integer. Got: %s',
static::typeToString($value)
));
}
return $value;
}
/**
* @throws InvalidArgumentException
*/
public static function count(mixed $array, mixed $number, string $message = ''): array|Countable
{
static::isCountable($array);
static::integerish($number);
static::eq(
\count($array),
$number,
\sprintf(
$message ?: 'Expected an array to contain %d elements. Got: %d.',
$number,
\count($array)
)
);
return $array;
}
/**
* @throws InvalidArgumentException
*/
public static function minCount(mixed $array, mixed $min, string $message = ''): array|Countable
{
static::isCountable($array);
static::integerish($min);
if (\count($array) < $min) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an array to contain at least %2$d elements. Got: %d',
\count($array),
$min
));
}
return $array;
}
/**
* @throws InvalidArgumentException
*/
public static function maxCount(mixed $array, mixed $max, string $message = ''): array|Countable
{
static::isCountable($array);
static::integerish($max);
if (\count($array) > $max) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an array to contain at most %2$d elements. Got: %d',
\count($array),
$max
));
}
return $array;
}
/**
* @throws InvalidArgumentException
*/
public static function countBetween(mixed $array, mixed $min, mixed $max, string $message = ''): array|Countable
{
static::isCountable($array);
static::integerish($min);
static::integerish($max);
$count = \count($array);
if ($count < $min || $count > $max) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an array to contain between %2$d and %3$d elements. Got: %d',
$count,
$min,
$max
));
}
return $array;
}
/**
* @psalm-pure
*
* @psalm-assert list<mixed> $array
*
* @psalm-return list<mixed>
*
* @throws InvalidArgumentException
*/
public static function isList(mixed $array, string $message = ''): array
{
if (!\is_array($array) || !\array_is_list($array)) {
static::reportInvalidArgument(
$message ?: 'Expected list - non-associative array.'
);
}
return $array;
}
/**
* @psalm-pure
*
* @psalm-assert non-empty-list<mixed> $array
*
* @psalm-return non-empty-list<mixed>
*
* @throws InvalidArgumentException
*/
public static function isNonEmptyList(mixed $array, string $message = ''): array
{
static::isList($array, $message);
static::notEmpty($array, $message);
return $array;
}
/**
* @psalm-pure
*
* @template T
*
* @psalm-assert array<string, T> $array
*
* @param mixed|array<array-key, T> $array
*
* @return array<string, T>
*
* @throws InvalidArgumentException
*/
public static function isMap(mixed $array, string $message = ''): array
{
static::isArray($array, $message);
if (\count($array) > 0 && \array_is_list($array)) {
static::reportInvalidArgument(
$message ?: 'Expected map - associative array with string keys.'
);
}
return $array;
}
/**
* @psalm-assert callable $callable
*
* @param Closure|callable $callable
*
* @return Closure|callable-string
*
* @throws InvalidArgumentException
*/
public static function isStatic(mixed $callable, string $message = ''): Closure|string
{
static::isCallable($callable, $message);
$callable = static::callableToClosure($callable);
$reflection = new ReflectionFunction($callable);
if (!$reflection->isStatic()) {
static::reportInvalidArgument(
$message ?: 'Closure is not static.'
);
}
return $callable;
}
/**
* @psalm-assert callable $callable
*
* @param Closure|callable $callable
*
* @return Closure|callable-string
*
* @throws InvalidArgumentException
*/
public static function notStatic(mixed $callable, string $message = ''): Closure|string
{
static::isCallable($callable, $message);
$callable = static::callableToClosure($callable);
$reflection = new ReflectionFunction($callable);
if ($reflection->isStatic()) {
static::reportInvalidArgument(
$message ?: 'Closure is not static.'
);
}
return $callable;
}
/**
* @psalm-pure
*
* @template T
*
* @psalm-assert array<string, T> $array
* @psalm-assert !empty $array
*
* @param array<string, T> $array
*
* @return array<string, T>
*
* @throws InvalidArgumentException
*/
public static function isNonEmptyMap(mixed $array, string $message = ''): array
{
static::isMap($array, $message);
static::notEmpty($array, $message);
return $array;
}
/**
* @psalm-pure
*
* @throws InvalidArgumentException
*/
public static function uuid(mixed $value, string $message = ''): string
{
static::string($value, $message);
$originalValue = $value;
$value = \str_replace(['urn:', 'uuid:', '{', '}'], '', $value);
// The nil UUID is special form of UUID that is specified to have all
// 128 bits set to zero.
if ('00000000-0000-0000-0000-000000000000' === $value) {
return $originalValue;
}
if (!\preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/D', $value)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Value %s is not a valid UUID.',
static::valueToString($value)
));
}
return $originalValue;
}
/**
* @psalm-param class-string<Throwable> $class
*
* @throws InvalidArgumentException
*/
public static function throws(mixed $expression, string $class = Throwable::class, string $message = ''): callable
{
static::string($class);
static::isCallable($expression);
$actual = 'none';
try {
$expression();
} catch (Throwable $e) {
$actual = \get_class($e);
if ($e instanceof $class) {
return $expression;
}
}
static::reportInvalidArgument($message ?: \sprintf(
'Expected to throw "%s", got "%s"',
$class,
$actual
));
}
/**
* @psalm-pure
*
* @return Closure|callable-string
*/
protected static function callableToClosure(callable $callable): Closure|string
{
if (\is_string($callable) && \function_exists($callable)) {
return $callable;
}
if ($callable instanceof Closure) {
return $callable;
}
return $callable(...);
}
/**
* @psalm-pure
*/
protected static function valueToString(mixed $value): string
{
if (null === $value) {
return 'null';
}
if (true === $value) {
return 'true';
}
if (false === $value) {
return 'false';
}
if (\is_array($value)) {
return 'array';
}
if (\is_object($value)) {
if (\method_exists($value, '__toString')) {
return \get_class($value).': '.self::valueToString($value->__toString());
}
if ($value instanceof DateTime || $value instanceof DateTimeImmutable) {
return \get_class($value).': '.self::valueToString($value->format('c'));
}
if (\enum_exists(\get_class($value))) {
return \get_class($value).'::'.$value->name;
}
return \get_class($value);
}
if (\is_resource($value)) {
return 'resource';
}
if (\is_string($value)) {
return '"'.$value.'"';
}
return (string) $value;
}
/**
* @psalm-pure
*/
protected static function typeToString(mixed $value): string
{
return \is_object($value) ? \get_class($value) : \gettype($value);
}
protected static function strlen(string $value): int
{
if (!\function_exists('mb_detect_encoding')) {
return \strlen($value);
}
if (false === $encoding = \mb_detect_encoding($value)) {
return \strlen($value);
}
return \mb_strlen($value, $encoding);
}
/**
* @psalm-pure this method is not supposed to perform side effects
*
* @throws InvalidArgumentException
*/
protected static function reportInvalidArgument(string $message): never
{
throw new InvalidArgumentException($message);
}
private function __construct()
{
}
}
================================================
FILE: src/InvalidArgumentException.php
================================================
<?php
declare(strict_types=1);
/*
* This file is part of the webmozart/assert package.
*
* (c) Bernhard Schussek <bschussek@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Webmozart\Assert;
class InvalidArgumentException extends \InvalidArgumentException
{
}
================================================
FILE: src/Mixin.php
================================================
<?php
declare(strict_types=1);
namespace Webmozart\Assert;
use ArrayAccess;
use Countable;
use Throwable;
/**
* This trait provides nullOr*, all* and allNullOr* variants of assertion base methods.
* Do not use this trait directly: it will change, and is not designed for reuse.
*/
trait Mixin
{
/**
* @psalm-pure
*
* @psalm-assert string|null $value
*
* @return string|null
*
* @throws InvalidArgumentException
*/
public static function nullOrString(mixed $value, string $message = ''): mixed
{
null === $value || static::string($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<string> $value
*
* @return iterable<string>
*
* @throws InvalidArgumentException
*/
public static function allString(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::string($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<string|null> $value
*
* @return iterable<string|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrString(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::string($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert non-empty-string|null $value
*
* @return non-empty-string|null
*
* @throws InvalidArgumentException
*/
public static function nullOrStringNotEmpty(mixed $value, string $message = ''): mixed
{
null === $value || static::stringNotEmpty($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<non-empty-string> $value
*
* @return iterable<non-empty-string>
*
* @throws InvalidArgumentException
*/
public static function allStringNotEmpty(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::stringNotEmpty($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<non-empty-string|null> $value
*
* @return iterable<non-empty-string|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrStringNotEmpty(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::stringNotEmpty($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert int|null $value
*
* @return int|null
*
* @throws InvalidArgumentException
*/
public static function nullOrInteger(mixed $value, string $message = ''): mixed
{
null === $value || static::integer($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<int> $value
*
* @return iterable<int>
*
* @throws InvalidArgumentException
*/
public static function allInteger(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::integer($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<int|null> $value
*
* @return iterable<int|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrInteger(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::integer($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert numeric|null $value
*
* @return numeric|null
*
* @throws InvalidArgumentException
*/
public static function nullOrIntegerish(mixed $value, string $message = ''): mixed
{
null === $value || static::integerish($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<numeric> $value
*
* @return iterable<numeric>
*
* @throws InvalidArgumentException
*/
public static function allIntegerish(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::integerish($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<numeric|null> $value
*
* @return iterable<numeric|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrIntegerish(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::integerish($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert positive-int|null $value
*
* @return positive-int|null
*
* @throws InvalidArgumentException
*/
public static function nullOrPositiveInteger(mixed $value, string $message = ''): mixed
{
null === $value || static::positiveInteger($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<positive-int> $value
*
* @return iterable<positive-int>
*
* @throws InvalidArgumentException
*/
public static function allPositiveInteger(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::positiveInteger($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<positive-int|null> $value
*
* @return iterable<positive-int|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrPositiveInteger(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::positiveInteger($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert non-negative-int|null $value
*
* @return non-negative-int|null
*
* @throws InvalidArgumentException
*/
public static function nullOrNotNegativeInteger(mixed $value, string $message = ''): mixed
{
null === $value || static::notNegativeInteger($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<non-negative-int> $value
*
* @return iterable<non-negative-int>
*
* @throws InvalidArgumentException
*/
public static function allNotNegativeInteger(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notNegativeInteger($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<non-negative-int|null> $value
*
* @return iterable<non-negative-int|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrNotNegativeInteger(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::notNegativeInteger($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert negative-int|null $value
*
* @return negative-int|null
*
* @throws InvalidArgumentException
*/
public static function nullOrNegativeInteger(mixed $value, string $message = ''): mixed
{
null === $value || static::negativeInteger($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<negative-int> $value
*
* @return iterable<negative-int>
*
* @throws InvalidArgumentException
*/
public static function allNegativeInteger(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::negativeInteger($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<negative-int|null> $value
*
* @return iterable<negative-int|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrNegativeInteger(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::negativeInteger($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert float|null $value
*
* @return float|null
*
* @throws InvalidArgumentException
*/
public static function nullOrFloat(mixed $value, string $message = ''): mixed
{
null === $value || static::float($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<float> $value
*
* @return iterable<float>
*
* @throws InvalidArgumentException
*/
public static function allFloat(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::float($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<float|null> $value
*
* @return iterable<float|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrFloat(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::float($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert numeric|null $value
*
* @return numeric|null
*
* @throws InvalidArgumentException
*/
public static function nullOrNumeric(mixed $value, string $message = ''): mixed
{
null === $value || static::numeric($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<numeric> $value
*
* @return iterable<numeric>
*
* @throws InvalidArgumentException
*/
public static function allNumeric(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::numeric($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<numeric|null> $value
*
* @return iterable<numeric|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrNumeric(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::numeric($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert positive-int|0|null $value
*
* @return positive-int|0|null
*
* @throws InvalidArgumentException
*/
public static function nullOrNatural(mixed $value, string $message = ''): mixed
{
null === $value || static::natural($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<positive-int|0> $value
*
* @return iterable<positive-int|0>
*
* @throws InvalidArgumentException
*/
public static function allNatural(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::natural($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<positive-int|0|null> $value
*
* @return iterable<positive-int|0|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrNatural(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::natural($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert bool|null $value
*
* @return bool|null
*
* @throws InvalidArgumentException
*/
public static function nullOrBoolean(mixed $value, string $message = ''): mixed
{
null === $value || static::boolean($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<bool> $value
*
* @return iterable<bool>
*
* @throws InvalidArgumentException
*/
public static function allBoolean(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::boolean($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<bool|null> $value
*
* @return iterable<bool|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrBoolean(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::boolean($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert scalar|null $value
*
* @return scalar|null
*
* @throws InvalidArgumentException
*/
public static function nullOrScalar(mixed $value, string $message = ''): mixed
{
null === $value || static::scalar($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<scalar> $value
*
* @return iterable<scalar>
*
* @throws InvalidArgumentException
*/
public static function allScalar(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::scalar($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<scalar|null> $value
*
* @return iterable<scalar|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrScalar(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::scalar($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert object|null $value
*
* @return object|null
*
* @throws InvalidArgumentException
*/
public static function nullOrObject(mixed $value, string $message = ''): mixed
{
null === $value || static::object($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<object> $value
*
* @return iterable<object>
*
* @throws InvalidArgumentException
*/
public static function allObject(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::object($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<object|null> $value
*
* @return iterable<object|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrObject(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::object($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert object|string|null $value
*
* @return object|string|null
*
* @throws InvalidArgumentException
*/
public static function nullOrObjectish(mixed $value, string $message = ''): mixed
{
null === $value || static::objectish($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<object|string> $value
*
* @return iterable<object|string>
*
* @throws InvalidArgumentException
*/
public static function allObjectish(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::objectish($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<object|string|null> $value
*
* @return iterable<object|string|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrObjectish(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::objectish($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert resource|null $value
*
* @see https://www.php.net/manual/en/function.get-resource-type.php
*
* @return resource|null
*
* @throws InvalidArgumentException
*/
public static function nullOrResource(mixed $value, ?string $type = null, string $message = ''): mixed
{
null === $value || static::resource($value, $type, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<resource> $value
*
* @see https://www.php.net/manual/en/function.get-resource-type.php
*
* @return iterable<resource>
*
* @throws InvalidArgumentException
*/
public static function allResource(mixed $value, ?string $type = null, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::resource($entry, $type, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<resource|null> $value
*
* @see https://www.php.net/manual/en/function.get-resource-type.php
*
* @return iterable<resource|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrResource(mixed $value, ?string $type = null, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::resource($entry, $type, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert callable|null $value
*
* @return callable|null
*
* @throws InvalidArgumentException
*/
public static function nullOrIsCallable(mixed $value, string $message = ''): mixed
{
null === $value || static::isCallable($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<callable> $value
*
* @return iterable<callable>
*
* @throws InvalidArgumentException
*/
public static function allIsCallable(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::isCallable($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<callable|null> $value
*
* @return iterable<callable|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrIsCallable(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::isCallable($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert array|null $value
*
* @return array|null
*
* @throws InvalidArgumentException
*/
public static function nullOrIsArray(mixed $value, string $message = ''): mixed
{
null === $value || static::isArray($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<array> $value
*
* @return iterable<array>
*
* @throws InvalidArgumentException
*/
public static function allIsArray(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::isArray($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<array|null> $value
*
* @return iterable<array|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrIsArray(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::isArray($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert array|ArrayAccess|null $value
*
* @return array|ArrayAccess|null
*
* @throws InvalidArgumentException
*/
public static function nullOrIsArrayAccessible(mixed $value, string $message = ''): mixed
{
null === $value || static::isArrayAccessible($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<array|ArrayAccess> $value
*
* @return iterable<array|ArrayAccess>
*
* @throws InvalidArgumentException
*/
public static function allIsArrayAccessible(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::isArrayAccessible($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<array|ArrayAccess|null> $value
*
* @return iterable<array|ArrayAccess|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrIsArrayAccessible(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::isArrayAccessible($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert countable|null $value
*
* @return countable|null
*
* @throws InvalidArgumentException
*/
public static function nullOrIsCountable(mixed $value, string $message = ''): mixed
{
null === $value || static::isCountable($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<countable> $value
*
* @return iterable<countable>
*
* @throws InvalidArgumentException
*/
public static function allIsCountable(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::isCountable($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<countable|null> $value
*
* @return iterable<countable|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrIsCountable(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::isCountable($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable|null $value
*
* @return iterable|null
*
* @throws InvalidArgumentException
*/
public static function nullOrIsIterable(mixed $value, string $message = ''): mixed
{
null === $value || static::isIterable($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<iterable> $value
*
* @return iterable<iterable>
*
* @throws InvalidArgumentException
*/
public static function allIsIterable(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::isIterable($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<iterable|null> $value
*
* @return iterable<iterable|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrIsIterable(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::isIterable($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @template T of object
* @psalm-assert T|null $value
*
* @psalm-param class-string<T> $class
* @return T|null
*
* @throws InvalidArgumentException
*/
public static function nullOrIsInstanceOf(mixed $value, mixed $class, string $message = ''): mixed
{
null === $value || static::isInstanceOf($value, $class, $message);
return $value;
}
/**
* @psalm-pure
*
* @template T of object
* @psalm-assert iterable<T> $value
*
* @psalm-param class-string<T> $class
* @return iterable<T>
*
* @throws InvalidArgumentException
*/
public static function allIsInstanceOf(mixed $value, mixed $class, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::isInstanceOf($entry, $class, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @template T of object
* @psalm-assert iterable<T|null> $value
*
* @psalm-param class-string<T> $class
* @return iterable<T|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrIsInstanceOf(mixed $value, mixed $class, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::isInstanceOf($entry, $class, $message);
}
return $value;
}
/**
* @template T of object
* @psalm-param class-string<T> $class
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrNotInstanceOf(mixed $value, mixed $class, string $message = ''): mixed
{
null === $value || static::notInstanceOf($value, $class, $message);
return $value;
}
/**
* @template T of object
* @psalm-param class-string<T> $class
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNotInstanceOf(mixed $value, mixed $class, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notInstanceOf($entry, $class, $message);
}
return $value;
}
/**
* @template T of object
* @psalm-assert iterable<object|null> $value
*
* @psalm-param class-string<T> $class
* @return iterable<object|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrNotInstanceOf(mixed $value, mixed $class, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::notInstanceOf($entry, $class, $message);
}
return $value;
}
/**
* @template T of object
* @psalm-assert T|null $value
*
* @param T|null $value
*
* @return T|null
*
* @throws InvalidArgumentException
*/
public static function nullOrIsInstanceOfAny(mixed $value, mixed $classes, string $message = ''): mixed
{
null === $value || static::isInstanceOfAny($value, $classes, $message);
return $value;
}
/**
* @template T of object
* @psalm-assert iterable<T> $value
*
* @param iterable<T> $value
*
* @return iterable<T>
*
* @throws InvalidArgumentException
*/
public static function allIsInstanceOfAny(mixed $value, mixed $classes, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::isInstanceOfAny($entry, $classes, $message);
}
return $value;
}
/**
* @template T of object
* @psalm-assert iterable<T|null> $value
*
* @param iterable<T|null> $value
*
* @return iterable<T|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrIsInstanceOfAny(mixed $value, mixed $classes, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::isInstanceOfAny($entry, $classes, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @template T of object
* @psalm-assert T|class-string<T>|null $value
*
* @return T|class-string<T>|null
*
* @throws InvalidArgumentException
*/
public static function nullOrIsAOf(mixed $value, mixed $class, string $message = ''): mixed
{
null === $value || static::isAOf($value, $class, $message);
return $value;
}
/**
* @psalm-pure
*
* @template T of object
* @psalm-assert iterable<T|class-string<T>> $value
*
* @return iterable<T|class-string<T>>
*
* @throws InvalidArgumentException
*/
public static function allIsAOf(mixed $value, mixed $class, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::isAOf($entry, $class, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @template T of object
* @psalm-assert iterable<T|class-string<T>|null> $value
*
* @return iterable<T|class-string<T>|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrIsAOf(mixed $value, mixed $class, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::isAOf($entry, $class, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @template T
*
* @param T|null $value
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrIsNotA(mixed $value, mixed $class, string $message = ''): mixed
{
null === $value || static::isNotA($value, $class, $message);
return $value;
}
/**
* @psalm-pure
*
* @template T
*
* @param iterable<T> $value
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allIsNotA(mixed $value, mixed $class, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::isNotA($entry, $class, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @template T
* @psalm-assert iterable<object|class-string|null> $value
*
* @param iterable<T|null> $value
*
* @return iterable<object|class-string|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrIsNotA(mixed $value, mixed $class, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::isNotA($entry, $class, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @param object|string|null $value
* @param string[] $classes
*
* @psalm-param array<class-string> $classes
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrIsAnyOf(mixed $value, mixed $classes, string $message = ''): mixed
{
null === $value || static::isAnyOf($value, $classes, $message);
return $value;
}
/**
* @psalm-pure
*
* @param iterable<object|string> $value
* @param string[] $classes
*
* @psalm-param array<class-string> $classes
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allIsAnyOf(mixed $value, mixed $classes, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::isAnyOf($entry, $classes, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @param iterable<object|string|null> $value
* @param string[] $classes
*
* @psalm-param array<class-string> $classes
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrIsAnyOf(mixed $value, mixed $classes, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::isAnyOf($entry, $classes, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert empty $value
*
* @return empty
*
* @throws InvalidArgumentException
*/
public static function nullOrIsEmpty(mixed $value, string $message = ''): mixed
{
null === $value || static::isEmpty($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<empty> $value
*
* @return iterable<empty>
*
* @throws InvalidArgumentException
*/
public static function allIsEmpty(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::isEmpty($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<empty|null> $value
*
* @return iterable<empty|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrIsEmpty(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::isEmpty($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrNotEmpty(mixed $value, string $message = ''): mixed
{
null === $value || static::notEmpty($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNotEmpty(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notEmpty($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<!empty|null> $value
*
* @return iterable<!empty|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrNotEmpty(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::notEmpty($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<null> $value
*
* @return iterable<null>
*
* @throws InvalidArgumentException
*/
public static function allNull(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::null($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNotNull(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notNull($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert true|null $value
*
* @return true|null
*
* @throws InvalidArgumentException
*/
public static function nullOrTrue(mixed $value, string $message = ''): mixed
{
null === $value || static::true($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<true> $value
*
* @return iterable<true>
*
* @throws InvalidArgumentException
*/
public static function allTrue(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::true($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<true|null> $value
*
* @return iterable<true|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrTrue(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::true($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert false|null $value
*
* @return false|null
*
* @throws InvalidArgumentException
*/
public static function nullOrFalse(mixed $value, string $message = ''): mixed
{
null === $value || static::false($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<false> $value
*
* @return iterable<false>
*
* @throws InvalidArgumentException
*/
public static function allFalse(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::false($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<false|null> $value
*
* @return iterable<false|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrFalse(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::false($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrNotFalse(mixed $value, string $message = ''): mixed
{
null === $value || static::notFalse($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNotFalse(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notFalse($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<!false|null> $value
*
* @return iterable<!false|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrNotFalse(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::notFalse($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-param string|null $value
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrIp(mixed $value, string $message = ''): mixed
{
null === $value || static::ip($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-param iterable<string> $value
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allIp(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::ip($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-param iterable<string|null> $value
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrIp(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::ip($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-param string|null $value
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrIpv4(mixed $value, string $message = ''): mixed
{
null === $value || static::ipv4($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-param iterable<string> $value
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allIpv4(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::ipv4($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-param iterable<string|null> $value
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrIpv4(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::ipv4($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-param string|null $value
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrIpv6(mixed $value, string $message = ''): mixed
{
null === $value || static::ipv6($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-param iterable<string> $value
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allIpv6(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::ipv6($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-param iterable<string|null> $value
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrIpv6(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::ipv6($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-param string|null $value
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrEmail(mixed $value, string $message = ''): mixed
{
null === $value || static::email($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-param iterable<string> $value
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allEmail(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::email($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-param iterable<string|null> $value
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrEmail(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::email($entry, $message);
}
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrUniqueValues(mixed $values, string $message = ''): mixed
{
null === $values || static::uniqueValues($values, $message);
return $values;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allUniqueValues(mixed $values, string $message = ''): mixed
{
static::isIterable($values);
foreach ($values as $entry) {
static::uniqueValues($entry, $message);
}
return $values;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrUniqueValues(mixed $values, string $message = ''): mixed
{
static::isIterable($values);
foreach ($values as $entry) {
null === $entry || static::uniqueValues($entry, $message);
}
return $values;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrEq(mixed $value, mixed $expect, string $message = ''): mixed
{
null === $value || static::eq($value, $expect, $message);
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allEq(mixed $value, mixed $expect, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::eq($entry, $expect, $message);
}
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrEq(mixed $value, mixed $expect, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::eq($entry, $expect, $message);
}
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrNotEq(mixed $value, mixed $expect, string $message = ''): mixed
{
null === $value || static::notEq($value, $expect, $message);
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNotEq(mixed $value, mixed $expect, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notEq($entry, $expect, $message);
}
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrNotEq(mixed $value, mixed $expect, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::notEq($entry, $expect, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrSame(mixed $value, mixed $expect, string $message = ''): mixed
{
null === $value || static::same($value, $expect, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allSame(mixed $value, mixed $expect, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::same($entry, $expect, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrSame(mixed $value, mixed $expect, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::same($entry, $expect, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrNotSame(mixed $value, mixed $expect, string $message = ''): mixed
{
null === $value || static::notSame($value, $expect, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNotSame(mixed $value, mixed $expect, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notSame($entry, $expect, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrNotSame(mixed $value, mixed $expect, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::notSame($entry, $expect, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrGreaterThan(mixed $value, mixed $limit, string $message = ''): mixed
{
null === $value || static::greaterThan($value, $limit, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allGreaterThan(mixed $value, mixed $limit, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::greaterThan($entry, $limit, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrGreaterThan(mixed $value, mixed $limit, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::greaterThan($entry, $limit, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrGreaterThanEq(mixed $value, mixed $limit, string $message = ''): mixed
{
null === $value || static::greaterThanEq($value, $limit, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allGreaterThanEq(mixed $value, mixed $limit, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::greaterThanEq($entry, $limit, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrGreaterThanEq(mixed $value, mixed $limit, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::greaterThanEq($entry, $limit, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrLessThan(mixed $value, mixed $limit, string $message = ''): mixed
{
null === $value || static::lessThan($value, $limit, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allLessThan(mixed $value, mixed $limit, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::lessThan($entry, $limit, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrLessThan(mixed $value, mixed $limit, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::lessThan($entry, $limit, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrLessThanEq(mixed $value, mixed $limit, string $message = ''): mixed
{
null === $value || static::lessThanEq($value, $limit, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allLessThanEq(mixed $value, mixed $limit, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::lessThanEq($entry, $limit, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrLessThanEq(mixed $value, mixed $limit, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::lessThanEq($entry, $limit, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrRange(mixed $value, mixed $min, mixed $max, string $message = ''): mixed
{
null === $value || static::range($value, $min, $max, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allRange(mixed $value, mixed $min, mixed $max, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::range($entry, $min, $max, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrRange(mixed $value, mixed $min, mixed $max, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::range($entry, $min, $max, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrOneOf(mixed $value, mixed $values, string $message = ''): mixed
{
null === $value || static::oneOf($value, $values, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allOneOf(mixed $value, mixed $values, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::oneOf($entry, $values, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrOneOf(mixed $value, mixed $values, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::oneOf($entry, $values, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrInArray(mixed $value, mixed $values, string $message = ''): mixed
{
null === $value || static::inArray($value, $values, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allInArray(mixed $value, mixed $values, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::inArray($entry, $values, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrInArray(mixed $value, mixed $values, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::inArray($entry, $values, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrNotOneOf(mixed $value, mixed $values, string $message = ''): mixed
{
null === $value || static::notOneOf($value, $values, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNotOneOf(mixed $value, mixed $values, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notOneOf($entry, $values, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrNotOneOf(mixed $value, mixed $values, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::notOneOf($entry, $values, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrNotInArray(mixed $value, mixed $values, string $message = ''): mixed
{
null === $value || static::notInArray($value, $values, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNotInArray(mixed $value, mixed $values, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notInArray($entry, $values, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrNotInArray(mixed $value, mixed $values, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::notInArray($entry, $values, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrContains(mixed $value, mixed $subString, string $message = ''): mixed
{
null === $value || static::contains($value, $subString, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allContains(mixed $value, mixed $subString, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::contains($entry, $subString, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrContains(mixed $value, mixed $subString, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::contains($entry, $subString, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrNotContains(mixed $value, mixed $subString, string $message = ''): mixed
{
null === $value || static::notContains($value, $subString, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNotContains(mixed $value, mixed $subString, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notContains($entry, $subString, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrNotContains(mixed $value, mixed $subString, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::notContains($entry, $subString, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrNotWhitespaceOnly(mixed $value, string $message = ''): mixed
{
null === $value || static::notWhitespaceOnly($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNotWhitespaceOnly(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notWhitespaceOnly($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrNotWhitespaceOnly(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::notWhitespaceOnly($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrStartsWith(mixed $value, mixed $prefix, string $message = ''): mixed
{
null === $value || static::startsWith($value, $prefix, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allStartsWith(mixed $value, mixed $prefix, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::startsWith($entry, $prefix, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrStartsWith(mixed $value, mixed $prefix, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::startsWith($entry, $prefix, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrNotStartsWith(mixed $value, mixed $prefix, string $message = ''): mixed
{
null === $value || static::notStartsWith($value, $prefix, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNotStartsWith(mixed $value, mixed $prefix, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notStartsWith($entry, $prefix, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrNotStartsWith(mixed $value, mixed $prefix, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::notStartsWith($entry, $prefix, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrStartsWithLetter(mixed $value, string $message = ''): mixed
{
null === $value || static::startsWithLetter($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allStartsWithLetter(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::startsWithLetter($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrStartsWithLetter(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::startsWithLetter($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrEndsWith(mixed $value, mixed $suffix, string $message = ''): mixed
{
null === $value || static::endsWith($value, $suffix, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allEndsWith(mixed $value, mixed $suffix, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::endsWith($entry, $suffix, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrEndsWith(mixed $value, mixed $suffix, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::endsWith($entry, $suffix, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrNotEndsWith(mixed $value, mixed $suffix, string $message = ''): mixed
{
null === $value || static::notEndsWith($value, $suffix, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNotEndsWith(mixed $value, mixed $suffix, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notEndsWith($entry, $suffix, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrNotEndsWith(mixed $value, mixed $suffix, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::notEndsWith($entry, $suffix, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrRegex(mixed $value, mixed $pattern, string $message = ''): mixed
{
null === $value || static::regex($value, $pattern, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allRegex(mixed $value, mixed $pattern, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::regex($entry, $pattern, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrRegex(mixed $value, mixed $pattern, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::regex($entry, $pattern, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrNotRegex(mixed $value, mixed $pattern, string $message = ''): mixed
{
null === $value || static::notRegex($value, $pattern, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNotRegex(mixed $value, mixed $pattern, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::notRegex($entry, $pattern, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrNotRegex(mixed $value, mixed $pattern, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::notRegex($entry, $pattern, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrUnicodeLetters(mixed $value, string $message = ''): mixed
{
null === $value || static::unicodeLetters($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allUnicodeLetters(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::unicodeLetters($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrUnicodeLetters(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::unicodeLetters($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrAlpha(mixed $value, string $message = ''): mixed
{
null === $value || static::alpha($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allAlpha(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::alpha($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrAlpha(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::alpha($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrDigits(mixed $value, string $message = ''): mixed
{
null === $value || static::digits($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allDigits(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::digits($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrDigits(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::digits($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrAlnum(mixed $value, string $message = ''): mixed
{
null === $value || static::alnum($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allAlnum(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::alnum($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrAlnum(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::alnum($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert lowercase-string|null $value
*
* @return lowercase-string|null
*
* @throws InvalidArgumentException
*/
public static function nullOrLower(mixed $value, string $message = ''): mixed
{
null === $value || static::lower($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<lowercase-string> $value
*
* @return iterable<lowercase-string>
*
* @throws InvalidArgumentException
*/
public static function allLower(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::lower($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<lowercase-string|null> $value
*
* @return iterable<lowercase-string|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrLower(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::lower($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrUpper(mixed $value, string $message = ''): mixed
{
null === $value || static::upper($value, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allUpper(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::upper($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @psalm-assert iterable<!lowercase-string|null> $value
*
* @return iterable<!lowercase-string|null>
*
* @throws InvalidArgumentException
*/
public static function allNullOrUpper(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::upper($entry, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrLength(mixed $value, mixed $length, string $message = ''): mixed
{
null === $value || static::length($value, $length, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allLength(mixed $value, mixed $length, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::length($entry, $length, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrLength(mixed $value, mixed $length, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::length($entry, $length, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrMinLength(mixed $value, mixed $min, string $message = ''): mixed
{
null === $value || static::minLength($value, $min, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allMinLength(mixed $value, mixed $min, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::minLength($entry, $min, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrMinLength(mixed $value, mixed $min, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::minLength($entry, $min, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrMaxLength(mixed $value, mixed $max, string $message = ''): mixed
{
null === $value || static::maxLength($value, $max, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allMaxLength(mixed $value, mixed $max, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::maxLength($entry, $max, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrMaxLength(mixed $value, mixed $max, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::maxLength($entry, $max, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrLengthBetween(mixed $value, mixed $min, mixed $max, string $message = ''): mixed
{
null === $value || static::lengthBetween($value, $min, $max, $message);
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allLengthBetween(mixed $value, mixed $min, mixed $max, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::lengthBetween($entry, $min, $max, $message);
}
return $value;
}
/**
* @psalm-pure
*
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrLengthBetween(mixed $value, mixed $min, mixed $max, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::lengthBetween($entry, $min, $max, $message);
}
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrFileExists(mixed $value, string $message = ''): mixed
{
null === $value || static::fileExists($value, $message);
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allFileExists(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::fileExists($entry, $message);
}
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrFileExists(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::fileExists($entry, $message);
}
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrFile(mixed $value, string $message = ''): mixed
{
null === $value || static::file($value, $message);
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allFile(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::file($entry, $message);
}
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allNullOrFile(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
null === $entry || static::file($entry, $message);
}
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function nullOrDirectory(mixed $value, string $message = ''): mixed
{
null === $value || static::directory($value, $message);
return $value;
}
/**
* @return mixed
*
* @throws InvalidArgumentException
*/
public static function allDirectory(mixed $value, string $message = ''): iterable
{
static::isIterable($value);
foreach ($value as $entry) {
static::directory($entry,
gitextract_vsvow73w/
├── .editorconfig
├── .gitattributes
├── .github/
│ └── workflows/
│ └── ci.yaml
├── .gitignore
├── .php-cs-fixer.php
├── CHANGELOG.md
├── LICENSE
├── README.md
├── bin/
│ ├── generate.php
│ └── src/
│ └── MixinGenerator.php
├── composer.json
├── phpunit.xml.dist
├── psalm.xml
├── src/
│ ├── Assert.php
│ ├── InvalidArgumentException.php
│ └── Mixin.php
├── tests/
│ ├── AssertTest.php
│ ├── DummyEnum.php
│ ├── ProjectCodeTest.php
│ └── static-analysis/
│ ├── assert-alnum.php
│ ├── assert-alpha.php
│ ├── assert-boolean.php
│ ├── assert-classExists.php
│ ├── assert-contains.php
│ ├── assert-count.php
│ ├── assert-countBetween.php
│ ├── assert-digits.php
│ ├── assert-directory.php
│ ├── assert-email.php
│ ├── assert-endsWith.php
│ ├── assert-eq.php
│ ├── assert-false.php
│ ├── assert-file.php
│ ├── assert-fileExists.php
│ ├── assert-float.php
│ ├── assert-greaterThan.php
│ ├── assert-greaterThanEq.php
│ ├── assert-implementsInterface.php
│ ├── assert-inArray.php
│ ├── assert-integer.php
│ ├── assert-integerish.php
│ ├── assert-interfaceExists.php
│ ├── assert-ip.php
│ ├── assert-ipv4.php
│ ├── assert-ipv6.php
│ ├── assert-isAOf.php
│ ├── assert-isAnyOf.php
│ ├── assert-isArray.php
│ ├── assert-isArrayAccessible.php
│ ├── assert-isCallable.php
│ ├── assert-isCountable.php
│ ├── assert-isEmpty.php
│ ├── assert-isInitialized.php
│ ├── assert-isInstanceOf.php
│ ├── assert-isInstanceOfAny.php
│ ├── assert-isIterable.php
│ ├── assert-isList.php
│ ├── assert-isMap.php
│ ├── assert-isNonEmptyList.php
│ ├── assert-isNonEmptyMap.php
│ ├── assert-isNotA.php
│ ├── assert-isStatic.php
│ ├── assert-keyExists.php
│ ├── assert-keyNotExists.php
│ ├── assert-length.php
│ ├── assert-lengthBetween.php
│ ├── assert-lessThan.php
│ ├── assert-lessThanEq.php
│ ├── assert-lower.php
│ ├── assert-maxCount.php
│ ├── assert-maxLength.php
│ ├── assert-methodExists.php
│ ├── assert-methodNotExists.php
│ ├── assert-minCount.php
│ ├── assert-minLength.php
│ ├── assert-natural.php
│ ├── assert-negativeInteger.php
│ ├── assert-notContains.php
│ ├── assert-notEmpty.php
│ ├── assert-notEq.php
│ ├── assert-notFalse.php
│ ├── assert-notInArray.php
│ ├── assert-notInstanceOf.php
│ ├── assert-notNegativeInteger.php
│ ├── assert-notNull.php
│ ├── assert-notOneOf.php
│ ├── assert-notRegex.php
│ ├── assert-notSame.php
│ ├── assert-notStatic.php
│ ├── assert-notWhitespaceOnly.php
│ ├── assert-null.php
│ ├── assert-numeric.php
│ ├── assert-object.php
│ ├── assert-objectish.php
│ ├── assert-oneOf.php
│ ├── assert-positiveInteger.php
│ ├── assert-propertyExists.php
│ ├── assert-propertyNotExists.php
│ ├── assert-psalm-notRedundant.php
│ ├── assert-psalm-preserveContainerType.php
│ ├── assert-psalm-preserveStringType.php
│ ├── assert-range.php
│ ├── assert-readable.php
│ ├── assert-regex.php
│ ├── assert-resource.php
│ ├── assert-same.php
│ ├── assert-scalar.php
│ ├── assert-startsWith.php
│ ├── assert-startsWithLetter.php
│ ├── assert-string.php
│ ├── assert-stringNotEmpty.php
│ ├── assert-subclassOf.php
│ ├── assert-throws.php
│ ├── assert-true.php
│ ├── assert-unicodeLetters.php
│ ├── assert-uniqueValues.php
│ ├── assert-upper.php
│ ├── assert-uuid.php
│ ├── assert-validArrayKey.php
│ └── assert-writable.php
└── tools/
├── php-cs-fixer/
│ └── composer.json
├── phpunit/
│ └── composer.json
├── psalm/
│ └── composer.json
└── roave-bc-check/
└── composer.json
SYMBOL INDEX (849 symbols across 107 files)
FILE: bin/src/MixinGenerator.php
class MixinGenerator (line 20) | final class MixinGenerator
method generate (line 59) | public function generate(): string
method namespace (line 74) | private function namespace(): string
method trait (line 89) | private function trait(ReflectionClass $assert): string
method nullOr (line 137) | private function nullOr(ReflectionMethod $method, int $indent): ?string
method all (line 156) | private function all(ReflectionMethod $method, int $indent): ?string
method allNullOr (line 179) | private function allNullOr(ReflectionMethod $method, int $indent): ?st...
method assertion (line 207) | private function assertion(ReflectionMethod $method, string $methodNam...
method reduceParameterType (line 344) | private function reduceParameterType(ReflectionType $type): string
method applyTypeTemplate (line 363) | private function applyTypeTemplate(string $type, string $typeTemplate)...
method shouldSkipAnnotation (line 374) | private function shouldSkipAnnotation(string $newMethodName, string $k...
method findLongestTypeAndName (line 391) | private function findLongestTypeAndName(array $values): array
method staticMethod (line 432) | private function staticMethod(string $name, array $parameters, array $...
method functionParameters (line 464) | private function functionParameters(array $parameters, array $types, a...
method phpdoc (line 495) | private function phpdoc(array $lines, int $indent): string
method parseDocComment (line 526) | private function parseDocComment(string $comment): array
method splitDocLine (line 551) | private function splitDocLine(string $line): array
method getMethods (line 567) | private function getMethods(ReflectionClass $assert): array
FILE: src/Assert.php
class Assert (line 33) | class Assert
method string (line 44) | public static function string(mixed $value, string $message = ''): string
method stringNotEmpty (line 65) | public static function stringNotEmpty(mixed $value, string $message = ...
method integer (line 80) | public static function integer(mixed $value, string $message = ''): int
method integerish (line 99) | public static function integerish(mixed $value, string $message = ''):...
method positiveInteger (line 120) | public static function positiveInteger(mixed $value, string $message =...
method notNegativeInteger (line 142) | public static function notNegativeInteger(mixed $value, string $messag...
method negativeInteger (line 164) | public static function negativeInteger(mixed $value, string $message =...
method float (line 185) | public static function float(mixed $value, string $message = ''): float
method numeric (line 204) | public static function numeric(mixed $value, string $message = ''): in...
method natural (line 225) | public static function natural(mixed $value, string $message = ''): int
method boolean (line 244) | public static function boolean(mixed $value, string $message = ''): bool
method scalar (line 263) | public static function scalar(mixed $value, string $message = ''): int...
method object (line 282) | public static function object(mixed $value, string $message = ''): object
method objectish (line 303) | public static function objectish(mixed $value, string $message = ''): ...
method resource (line 333) | public static function resource(mixed $value, ?string $type = null, st...
method isInitialized (line 361) | public static function isInitialized(mixed $value, string $property, s...
method isCallable (line 384) | public static function isCallable(mixed $value, string $message = ''):...
method isArray (line 403) | public static function isArray(mixed $value, string $message = ''): array
method isArrayAccessible (line 422) | public static function isArrayAccessible(mixed $value, string $message...
method isCountable (line 441) | public static function isCountable(mixed $value, string $message = '')...
method isIterable (line 460) | public static function isIterable(mixed $value, string $message = ''):...
method isInstanceOf (line 485) | public static function isInstanceOf(mixed $value, mixed $class, string...
method notInstanceOf (line 510) | public static function notInstanceOf(mixed $value, mixed $class, strin...
method isInstanceOfAny (line 536) | public static function isInstanceOfAny(mixed $value, mixed $classes, s...
method isAOf (line 566) | public static function isAOf(mixed $value, mixed $class, string $messa...
method isNotA (line 594) | public static function isNotA(mixed $value, mixed $class, string $mess...
method isAnyOf (line 619) | public static function isAnyOf(mixed $value, mixed $classes, string $m...
method isEmpty (line 648) | public static function isEmpty(mixed $value, string $message = ''): mixed
method notEmpty (line 669) | public static function notEmpty(mixed $value, string $message = ''): m...
method null (line 688) | public static function null(mixed $value, string $message = ''): null
method notNull (line 709) | public static function notNull(mixed $value, string $message = ''): mixed
method true (line 727) | public static function true(mixed $value, string $message = ''): true
method false (line 746) | public static function false(mixed $value, string $message = ''): false
method notFalse (line 765) | public static function notFalse(mixed $value, string $message = ''): m...
method ip (line 783) | public static function ip(mixed $value, string $message = ''): string
method ipv4 (line 804) | public static function ipv4(mixed $value, string $message = ''): string
method ipv6 (line 825) | public static function ipv6(mixed $value, string $message = ''): string
method email (line 846) | public static function email(mixed $value, string $message = ''): string
method uniqueValues (line 865) | public static function uniqueValues(mixed $values, string $message = '...
method eq (line 888) | public static function eq(mixed $value, mixed $expect, string $message...
method notEq (line 904) | public static function notEq(mixed $value, mixed $expect, string $mess...
method same (line 921) | public static function same(mixed $value, mixed $expect, string $messa...
method notSame (line 939) | public static function notSame(mixed $value, mixed $expect, string $me...
method greaterThan (line 956) | public static function greaterThan(mixed $value, mixed $limit, string ...
method greaterThanEq (line 974) | public static function greaterThanEq(mixed $value, mixed $limit, strin...
method lessThan (line 992) | public static function lessThan(mixed $value, mixed $limit, string $me...
method lessThanEq (line 1010) | public static function lessThanEq(mixed $value, mixed $limit, string $...
method range (line 1030) | public static function range(mixed $value, mixed $min, mixed $max, str...
method oneOf (line 1051) | public static function oneOf(mixed $value, mixed $values, string $mess...
method inArray (line 1065) | public static function inArray(mixed $value, mixed $values, string $me...
method notOneOf (line 1087) | public static function notOneOf(mixed $value, mixed $values, string $m...
method notInArray (line 1104) | public static function notInArray(mixed $value, mixed $values, string ...
method contains (line 1124) | public static function contains(mixed $value, mixed $subString, string...
method notContains (line 1145) | public static function notContains(mixed $value, mixed $subString, str...
method notWhitespaceOnly (line 1166) | public static function notWhitespaceOnly(mixed $value, string $message...
method startsWith (line 1185) | public static function startsWith(mixed $value, mixed $prefix, string ...
method notStartsWith (line 1206) | public static function notStartsWith(mixed $value, mixed $prefix, stri...
method startsWithLetter (line 1227) | public static function startsWithLetter(mixed $value, string $message ...
method endsWith (line 1255) | public static function endsWith(mixed $value, mixed $suffix, string $m...
method notEndsWith (line 1276) | public static function notEndsWith(mixed $value, mixed $suffix, string...
method regex (line 1297) | public static function regex(mixed $value, mixed $pattern, string $mes...
method notRegex (line 1317) | public static function notRegex(mixed $value, mixed $pattern, string $...
method unicodeLetters (line 1339) | public static function unicodeLetters(mixed $value, string $message = ...
method alpha (line 1358) | public static function alpha(mixed $value, string $message = ''): string
method digits (line 1382) | public static function digits(mixed $value, string $message = ''): string
method alnum (line 1406) | public static function alnum(mixed $value, string $message = ''): string
method lower (line 1432) | public static function lower(mixed $value, string $message = ''): string
method upper (line 1458) | public static function upper(mixed $value, string $message = ''): string
method length (line 1482) | public static function length(mixed $value, mixed $length, string $mes...
method minLength (line 1505) | public static function minLength(mixed $value, mixed $min, string $mes...
method maxLength (line 1528) | public static function maxLength(mixed $value, mixed $max, string $mes...
method lengthBetween (line 1551) | public static function lengthBetween(mixed $value, mixed $min, mixed $...
method fileExists (line 1576) | public static function fileExists(mixed $value, string $message = ''):...
method file (line 1593) | public static function file(mixed $value, string $message = ''): string
method directory (line 1610) | public static function directory(mixed $value, string $message = ''): ...
method readable (line 1627) | public static function readable(mixed $value, string $message = ''): s...
method writable (line 1644) | public static function writable(mixed $value, string $message = ''): s...
method classExists (line 1663) | public static function classExists(mixed $value, string $message = '')...
method subclassOf (line 1690) | public static function subclassOf(mixed $value, mixed $class, string $...
method interfaceExists (line 1711) | public static function interfaceExists(mixed $value, string $message =...
method implementsInterface (line 1737) | public static function implementsInterface(mixed $value, mixed $interf...
method propertyExists (line 1763) | public static function propertyExists(mixed $classOrObject, mixed $pro...
method propertyNotExists (line 1785) | public static function propertyNotExists(mixed $classOrObject, mixed $...
method methodExists (line 1805) | public static function methodExists(mixed $classOrObject, mixed $metho...
method methodNotExists (line 1827) | public static function methodNotExists(mixed $classOrObject, mixed $me...
method keyExists (line 1848) | public static function keyExists(mixed $array, string|int $key, string...
method keyNotExists (line 1869) | public static function keyNotExists(mixed $array, string|int $key, str...
method validArrayKey (line 1892) | public static function validArrayKey(mixed $value, string $message = '...
method count (line 1907) | public static function count(mixed $array, mixed $number, string $mess...
method minCount (line 1928) | public static function minCount(mixed $array, mixed $min, string $mess...
method maxCount (line 1947) | public static function maxCount(mixed $array, mixed $max, string $mess...
method countBetween (line 1966) | public static function countBetween(mixed $array, mixed $min, mixed $m...
method isList (line 1995) | public static function isList(mixed $array, string $message = ''): array
method isNonEmptyList (line 2015) | public static function isNonEmptyList(mixed $array, string $message = ...
method isMap (line 2036) | public static function isMap(mixed $array, string $message = ''): array
method isStatic (line 2058) | public static function isStatic(mixed $callable, string $message = '')...
method notStatic (line 2084) | public static function notStatic(mixed $callable, string $message = ''...
method isNonEmptyMap (line 2115) | public static function isNonEmptyMap(mixed $array, string $message = '...
method uuid (line 2128) | public static function uuid(mixed $value, string $message = ''): string
method throws (line 2156) | public static function throws(mixed $expression, string $class = Throw...
method callableToClosure (line 2184) | protected static function callableToClosure(callable $callable): Closu...
method valueToString (line 2200) | protected static function valueToString(mixed $value): string
method typeToString (line 2248) | protected static function typeToString(mixed $value): string
method strlen (line 2253) | protected static function strlen(string $value): int
method reportInvalidArgument (line 2271) | protected static function reportInvalidArgument(string $message): never
method __construct (line 2276) | private function __construct()
FILE: src/InvalidArgumentException.php
class InvalidArgumentException (line 15) | class InvalidArgumentException extends \InvalidArgumentException
FILE: src/Mixin.php
type Mixin (line 15) | trait Mixin
method nullOrString (line 26) | public static function nullOrString(mixed $value, string $message = ''...
method allString (line 42) | public static function allString(mixed $value, string $message = ''): ...
method allNullOrString (line 62) | public static function allNullOrString(mixed $value, string $message =...
method nullOrStringNotEmpty (line 82) | public static function nullOrStringNotEmpty(mixed $value, string $mess...
method allStringNotEmpty (line 98) | public static function allStringNotEmpty(mixed $value, string $message...
method allNullOrStringNotEmpty (line 118) | public static function allNullOrStringNotEmpty(mixed $value, string $m...
method nullOrInteger (line 138) | public static function nullOrInteger(mixed $value, string $message = '...
method allInteger (line 154) | public static function allInteger(mixed $value, string $message = ''):...
method allNullOrInteger (line 174) | public static function allNullOrInteger(mixed $value, string $message ...
method nullOrIntegerish (line 194) | public static function nullOrIntegerish(mixed $value, string $message ...
method allIntegerish (line 210) | public static function allIntegerish(mixed $value, string $message = '...
method allNullOrIntegerish (line 230) | public static function allNullOrIntegerish(mixed $value, string $messa...
method nullOrPositiveInteger (line 250) | public static function nullOrPositiveInteger(mixed $value, string $mes...
method allPositiveInteger (line 266) | public static function allPositiveInteger(mixed $value, string $messag...
method allNullOrPositiveInteger (line 286) | public static function allNullOrPositiveInteger(mixed $value, string $...
method nullOrNotNegativeInteger (line 306) | public static function nullOrNotNegativeInteger(mixed $value, string $...
method allNotNegativeInteger (line 322) | public static function allNotNegativeInteger(mixed $value, string $mes...
method allNullOrNotNegativeInteger (line 342) | public static function allNullOrNotNegativeInteger(mixed $value, strin...
method nullOrNegativeInteger (line 362) | public static function nullOrNegativeInteger(mixed $value, string $mes...
method allNegativeInteger (line 378) | public static function allNegativeInteger(mixed $value, string $messag...
method allNullOrNegativeInteger (line 398) | public static function allNullOrNegativeInteger(mixed $value, string $...
method nullOrFloat (line 418) | public static function nullOrFloat(mixed $value, string $message = '')...
method allFloat (line 434) | public static function allFloat(mixed $value, string $message = ''): i...
method allNullOrFloat (line 454) | public static function allNullOrFloat(mixed $value, string $message = ...
method nullOrNumeric (line 474) | public static function nullOrNumeric(mixed $value, string $message = '...
method allNumeric (line 490) | public static function allNumeric(mixed $value, string $message = ''):...
method allNullOrNumeric (line 510) | public static function allNullOrNumeric(mixed $value, string $message ...
method nullOrNatural (line 530) | public static function nullOrNatural(mixed $value, string $message = '...
method allNatural (line 546) | public static function allNatural(mixed $value, string $message = ''):...
method allNullOrNatural (line 566) | public static function allNullOrNatural(mixed $value, string $message ...
method nullOrBoolean (line 586) | public static function nullOrBoolean(mixed $value, string $message = '...
method allBoolean (line 602) | public static function allBoolean(mixed $value, string $message = ''):...
method allNullOrBoolean (line 622) | public static function allNullOrBoolean(mixed $value, string $message ...
method nullOrScalar (line 642) | public static function nullOrScalar(mixed $value, string $message = ''...
method allScalar (line 658) | public static function allScalar(mixed $value, string $message = ''): ...
method allNullOrScalar (line 678) | public static function allNullOrScalar(mixed $value, string $message =...
method nullOrObject (line 698) | public static function nullOrObject(mixed $value, string $message = ''...
method allObject (line 714) | public static function allObject(mixed $value, string $message = ''): ...
method allNullOrObject (line 734) | public static function allNullOrObject(mixed $value, string $message =...
method nullOrObjectish (line 754) | public static function nullOrObjectish(mixed $value, string $message =...
method allObjectish (line 770) | public static function allObjectish(mixed $value, string $message = ''...
method allNullOrObjectish (line 790) | public static function allNullOrObjectish(mixed $value, string $messag...
method nullOrResource (line 812) | public static function nullOrResource(mixed $value, ?string $type = nu...
method allResource (line 830) | public static function allResource(mixed $value, ?string $type = null,...
method allNullOrResource (line 852) | public static function allNullOrResource(mixed $value, ?string $type =...
method nullOrIsCallable (line 872) | public static function nullOrIsCallable(mixed $value, string $message ...
method allIsCallable (line 888) | public static function allIsCallable(mixed $value, string $message = '...
method allNullOrIsCallable (line 908) | public static function allNullOrIsCallable(mixed $value, string $messa...
method nullOrIsArray (line 928) | public static function nullOrIsArray(mixed $value, string $message = '...
method allIsArray (line 944) | public static function allIsArray(mixed $value, string $message = ''):...
method allNullOrIsArray (line 964) | public static function allNullOrIsArray(mixed $value, string $message ...
method nullOrIsArrayAccessible (line 984) | public static function nullOrIsArrayAccessible(mixed $value, string $m...
method allIsArrayAccessible (line 1000) | public static function allIsArrayAccessible(mixed $value, string $mess...
method allNullOrIsArrayAccessible (line 1020) | public static function allNullOrIsArrayAccessible(mixed $value, string...
method nullOrIsCountable (line 1040) | public static function nullOrIsCountable(mixed $value, string $message...
method allIsCountable (line 1056) | public static function allIsCountable(mixed $value, string $message = ...
method allNullOrIsCountable (line 1076) | public static function allNullOrIsCountable(mixed $value, string $mess...
method nullOrIsIterable (line 1096) | public static function nullOrIsIterable(mixed $value, string $message ...
method allIsIterable (line 1112) | public static function allIsIterable(mixed $value, string $message = '...
method allNullOrIsIterable (line 1132) | public static function allNullOrIsIterable(mixed $value, string $messa...
method nullOrIsInstanceOf (line 1154) | public static function nullOrIsInstanceOf(mixed $value, mixed $class, ...
method allIsInstanceOf (line 1172) | public static function allIsInstanceOf(mixed $value, mixed $class, str...
method allNullOrIsInstanceOf (line 1194) | public static function allNullOrIsInstanceOf(mixed $value, mixed $clas...
method nullOrNotInstanceOf (line 1212) | public static function nullOrNotInstanceOf(mixed $value, mixed $class,...
method allNotInstanceOf (line 1226) | public static function allNotInstanceOf(mixed $value, mixed $class, st...
method allNullOrNotInstanceOf (line 1246) | public static function allNullOrNotInstanceOf(mixed $value, mixed $cla...
method nullOrIsInstanceOfAny (line 1267) | public static function nullOrIsInstanceOfAny(mixed $value, mixed $clas...
method allIsInstanceOfAny (line 1284) | public static function allIsInstanceOfAny(mixed $value, mixed $classes...
method allNullOrIsInstanceOfAny (line 1305) | public static function allNullOrIsInstanceOfAny(mixed $value, mixed $c...
method nullOrIsAOf (line 1326) | public static function nullOrIsAOf(mixed $value, mixed $class, string ...
method allIsAOf (line 1343) | public static function allIsAOf(mixed $value, mixed $class, string $me...
method allNullOrIsAOf (line 1364) | public static function allNullOrIsAOf(mixed $value, mixed $class, stri...
method nullOrIsNotA (line 1386) | public static function nullOrIsNotA(mixed $value, mixed $class, string...
method allIsNotA (line 1404) | public static function allIsNotA(mixed $value, mixed $class, string $m...
method allNullOrIsNotA (line 1427) | public static function allNullOrIsNotA(mixed $value, mixed $class, str...
method nullOrIsAnyOf (line 1450) | public static function nullOrIsAnyOf(mixed $value, mixed $classes, str...
method allIsAnyOf (line 1469) | public static function allIsAnyOf(mixed $value, mixed $classes, string...
method allNullOrIsAnyOf (line 1492) | public static function allNullOrIsAnyOf(mixed $value, mixed $classes, ...
method nullOrIsEmpty (line 1512) | public static function nullOrIsEmpty(mixed $value, string $message = '...
method allIsEmpty (line 1528) | public static function allIsEmpty(mixed $value, string $message = ''):...
method allNullOrIsEmpty (line 1548) | public static function allNullOrIsEmpty(mixed $value, string $message ...
method nullOrNotEmpty (line 1566) | public static function nullOrNotEmpty(mixed $value, string $message = ...
method allNotEmpty (line 1580) | public static function allNotEmpty(mixed $value, string $message = '')...
method allNullOrNotEmpty (line 1600) | public static function allNullOrNotEmpty(mixed $value, string $message...
method allNull (line 1620) | public static function allNull(mixed $value, string $message = ''): it...
method allNotNull (line 1638) | public static function allNotNull(mixed $value, string $message = ''):...
method nullOrTrue (line 1658) | public static function nullOrTrue(mixed $value, string $message = ''):...
method allTrue (line 1674) | public static function allTrue(mixed $value, string $message = ''): it...
method allNullOrTrue (line 1694) | public static function allNullOrTrue(mixed $value, string $message = '...
method nullOrFalse (line 1714) | public static function nullOrFalse(mixed $value, string $message = '')...
method allFalse (line 1730) | public static function allFalse(mixed $value, string $message = ''): i...
method allNullOrFalse (line 1750) | public static function allNullOrFalse(mixed $value, string $message = ...
method nullOrNotFalse (line 1768) | public static function nullOrNotFalse(mixed $value, string $message = ...
method allNotFalse (line 1782) | public static function allNotFalse(mixed $value, string $message = '')...
method allNullOrNotFalse (line 1802) | public static function allNullOrNotFalse(mixed $value, string $message...
method nullOrIp (line 1821) | public static function nullOrIp(mixed $value, string $message = ''): m...
method allIp (line 1836) | public static function allIp(mixed $value, string $message = ''): iter...
method allNullOrIp (line 1855) | public static function allNullOrIp(mixed $value, string $message = '')...
method nullOrIpv4 (line 1874) | public static function nullOrIpv4(mixed $value, string $message = ''):...
method allIpv4 (line 1889) | public static function allIpv4(mixed $value, string $message = ''): it...
method allNullOrIpv4 (line 1908) | public static function allNullOrIpv4(mixed $value, string $message = '...
method nullOrIpv6 (line 1927) | public static function nullOrIpv6(mixed $value, string $message = ''):...
method allIpv6 (line 1942) | public static function allIpv6(mixed $value, string $message = ''): it...
method allNullOrIpv6 (line 1961) | public static function allNullOrIpv6(mixed $value, string $message = '...
method nullOrEmail (line 1980) | public static function nullOrEmail(mixed $value, string $message = '')...
method allEmail (line 1995) | public static function allEmail(mixed $value, string $message = ''): i...
method allNullOrEmail (line 2014) | public static function allNullOrEmail(mixed $value, string $message = ...
method nullOrUniqueValues (line 2030) | public static function nullOrUniqueValues(mixed $values, string $messa...
method allUniqueValues (line 2042) | public static function allUniqueValues(mixed $values, string $message ...
method allNullOrUniqueValues (line 2058) | public static function allNullOrUniqueValues(mixed $values, string $me...
method nullOrEq (line 2074) | public static function nullOrEq(mixed $value, mixed $expect, string $m...
method allEq (line 2086) | public static function allEq(mixed $value, mixed $expect, string $mess...
method allNullOrEq (line 2102) | public static function allNullOrEq(mixed $value, mixed $expect, string...
method nullOrNotEq (line 2118) | public static function nullOrNotEq(mixed $value, mixed $expect, string...
method allNotEq (line 2130) | public static function allNotEq(mixed $value, mixed $expect, string $m...
method allNullOrNotEq (line 2146) | public static function allNullOrNotEq(mixed $value, mixed $expect, str...
method nullOrSame (line 2164) | public static function nullOrSame(mixed $value, mixed $expect, string ...
method allSame (line 2178) | public static function allSame(mixed $value, mixed $expect, string $me...
method allNullOrSame (line 2196) | public static function allNullOrSame(mixed $value, mixed $expect, stri...
method nullOrNotSame (line 2214) | public static function nullOrNotSame(mixed $value, mixed $expect, stri...
method allNotSame (line 2228) | public static function allNotSame(mixed $value, mixed $expect, string ...
method allNullOrNotSame (line 2246) | public static function allNullOrNotSame(mixed $value, mixed $expect, s...
method nullOrGreaterThan (line 2264) | public static function nullOrGreaterThan(mixed $value, mixed $limit, s...
method allGreaterThan (line 2278) | public static function allGreaterThan(mixed $value, mixed $limit, stri...
method allNullOrGreaterThan (line 2296) | public static function allNullOrGreaterThan(mixed $value, mixed $limit...
method nullOrGreaterThanEq (line 2314) | public static function nullOrGreaterThanEq(mixed $value, mixed $limit,...
method allGreaterThanEq (line 2328) | public static function allGreaterThanEq(mixed $value, mixed $limit, st...
method allNullOrGreaterThanEq (line 2346) | public static function allNullOrGreaterThanEq(mixed $value, mixed $lim...
method nullOrLessThan (line 2364) | public static function nullOrLessThan(mixed $value, mixed $limit, stri...
method allLessThan (line 2378) | public static function allLessThan(mixed $value, mixed $limit, string ...
method allNullOrLessThan (line 2396) | public static function allNullOrLessThan(mixed $value, mixed $limit, s...
method nullOrLessThanEq (line 2414) | public static function nullOrLessThanEq(mixed $value, mixed $limit, st...
method allLessThanEq (line 2428) | public static function allLessThanEq(mixed $value, mixed $limit, strin...
method allNullOrLessThanEq (line 2446) | public static function allNullOrLessThanEq(mixed $value, mixed $limit,...
method nullOrRange (line 2464) | public static function nullOrRange(mixed $value, mixed $min, mixed $ma...
method allRange (line 2478) | public static function allRange(mixed $value, mixed $min, mixed $max, ...
method allNullOrRange (line 2496) | public static function allNullOrRange(mixed $value, mixed $min, mixed ...
method nullOrOneOf (line 2514) | public static function nullOrOneOf(mixed $value, mixed $values, string...
method allOneOf (line 2528) | public static function allOneOf(mixed $value, mixed $values, string $m...
method allNullOrOneOf (line 2546) | public static function allNullOrOneOf(mixed $value, mixed $values, str...
method nullOrInArray (line 2564) | public static function nullOrInArray(mixed $value, mixed $values, stri...
method allInArray (line 2578) | public static function allInArray(mixed $value, mixed $values, string ...
method allNullOrInArray (line 2596) | public static function allNullOrInArray(mixed $value, mixed $values, s...
method nullOrNotOneOf (line 2614) | public static function nullOrNotOneOf(mixed $value, mixed $values, str...
method allNotOneOf (line 2628) | public static function allNotOneOf(mixed $value, mixed $values, string...
method allNullOrNotOneOf (line 2646) | public static function allNullOrNotOneOf(mixed $value, mixed $values, ...
method nullOrNotInArray (line 2664) | public static function nullOrNotInArray(mixed $value, mixed $values, s...
method allNotInArray (line 2678) | public static function allNotInArray(mixed $value, mixed $values, stri...
method allNullOrNotInArray (line 2696) | public static function allNullOrNotInArray(mixed $value, mixed $values...
method nullOrContains (line 2714) | public static function nullOrContains(mixed $value, mixed $subString, ...
method allContains (line 2728) | public static function allContains(mixed $value, mixed $subString, str...
method allNullOrContains (line 2746) | public static function allNullOrContains(mixed $value, mixed $subStrin...
method nullOrNotContains (line 2764) | public static function nullOrNotContains(mixed $value, mixed $subStrin...
method allNotContains (line 2778) | public static function allNotContains(mixed $value, mixed $subString, ...
method allNullOrNotContains (line 2796) | public static function allNullOrNotContains(mixed $value, mixed $subSt...
method nullOrNotWhitespaceOnly (line 2814) | public static function nullOrNotWhitespaceOnly(mixed $value, string $m...
method allNotWhitespaceOnly (line 2828) | public static function allNotWhitespaceOnly(mixed $value, string $mess...
method allNullOrNotWhitespaceOnly (line 2846) | public static function allNullOrNotWhitespaceOnly(mixed $value, string...
method nullOrStartsWith (line 2864) | public static function nullOrStartsWith(mixed $value, mixed $prefix, s...
method allStartsWith (line 2878) | public static function allStartsWith(mixed $value, mixed $prefix, stri...
method allNullOrStartsWith (line 2896) | public static function allNullOrStartsWith(mixed $value, mixed $prefix...
method nullOrNotStartsWith (line 2914) | public static function nullOrNotStartsWith(mixed $value, mixed $prefix...
method allNotStartsWith (line 2928) | public static function allNotStartsWith(mixed $value, mixed $prefix, s...
method allNullOrNotStartsWith (line 2946) | public static function allNullOrNotStartsWith(mixed $value, mixed $pre...
method nullOrStartsWithLetter (line 2964) | public static function nullOrStartsWithLetter(mixed $value, string $me...
method allStartsWithLetter (line 2978) | public static function allStartsWithLetter(mixed $value, string $messa...
method allNullOrStartsWithLetter (line 2996) | public static function allNullOrStartsWithLetter(mixed $value, string ...
method nullOrEndsWith (line 3014) | public static function nullOrEndsWith(mixed $value, mixed $suffix, str...
method allEndsWith (line 3028) | public static function allEndsWith(mixed $value, mixed $suffix, string...
method allNullOrEndsWith (line 3046) | public static function allNullOrEndsWith(mixed $value, mixed $suffix, ...
method nullOrNotEndsWith (line 3064) | public static function nullOrNotEndsWith(mixed $value, mixed $suffix, ...
method allNotEndsWith (line 3078) | public static function allNotEndsWith(mixed $value, mixed $suffix, str...
method allNullOrNotEndsWith (line 3096) | public static function allNullOrNotEndsWith(mixed $value, mixed $suffi...
method nullOrRegex (line 3114) | public static function nullOrRegex(mixed $value, mixed $pattern, strin...
method allRegex (line 3128) | public static function allRegex(mixed $value, mixed $pattern, string $...
method allNullOrRegex (line 3146) | public static function allNullOrRegex(mixed $value, mixed $pattern, st...
method nullOrNotRegex (line 3164) | public static function nullOrNotRegex(mixed $value, mixed $pattern, st...
method allNotRegex (line 3178) | public static function allNotRegex(mixed $value, mixed $pattern, strin...
method allNullOrNotRegex (line 3196) | public static function allNullOrNotRegex(mixed $value, mixed $pattern,...
method nullOrUnicodeLetters (line 3214) | public static function nullOrUnicodeLetters(mixed $value, string $mess...
method allUnicodeLetters (line 3228) | public static function allUnicodeLetters(mixed $value, string $message...
method allNullOrUnicodeLetters (line 3246) | public static function allNullOrUnicodeLetters(mixed $value, string $m...
method nullOrAlpha (line 3264) | public static function nullOrAlpha(mixed $value, string $message = '')...
method allAlpha (line 3278) | public static function allAlpha(mixed $value, string $message = ''): i...
method allNullOrAlpha (line 3296) | public static function allNullOrAlpha(mixed $value, string $message = ...
method nullOrDigits (line 3314) | public static function nullOrDigits(mixed $value, string $message = ''...
method allDigits (line 3328) | public static function allDigits(mixed $value, string $message = ''): ...
method allNullOrDigits (line 3346) | public static function allNullOrDigits(mixed $value, string $message =...
method nullOrAlnum (line 3364) | public static function nullOrAlnum(mixed $value, string $message = '')...
method allAlnum (line 3378) | public static function allAlnum(mixed $value, string $message = ''): i...
method allNullOrAlnum (line 3396) | public static function allNullOrAlnum(mixed $value, string $message = ...
method nullOrLower (line 3416) | public static function nullOrLower(mixed $value, string $message = '')...
method allLower (line 3432) | public static function allLower(mixed $value, string $message = ''): i...
method allNullOrLower (line 3452) | public static function allNullOrLower(mixed $value, string $message = ...
method nullOrUpper (line 3470) | public static function nullOrUpper(mixed $value, string $message = '')...
method allUpper (line 3484) | public static function allUpper(mixed $value, string $message = ''): i...
method allNullOrUpper (line 3504) | public static function allNullOrUpper(mixed $value, string $message = ...
method nullOrLength (line 3522) | public static function nullOrLength(mixed $value, mixed $length, strin...
method allLength (line 3536) | public static function allLength(mixed $value, mixed $length, string $...
method allNullOrLength (line 3554) | public static function allNullOrLength(mixed $value, mixed $length, st...
method nullOrMinLength (line 3572) | public static function nullOrMinLength(mixed $value, mixed $min, strin...
method allMinLength (line 3586) | public static function allMinLength(mixed $value, mixed $min, string $...
method allNullOrMinLength (line 3604) | public static function allNullOrMinLength(mixed $value, mixed $min, st...
method nullOrMaxLength (line 3622) | public static function nullOrMaxLength(mixed $value, mixed $max, strin...
method allMaxLength (line 3636) | public static function allMaxLength(mixed $value, mixed $max, string $...
method allNullOrMaxLength (line 3654) | public static function allNullOrMaxLength(mixed $value, mixed $max, st...
method nullOrLengthBetween (line 3672) | public static function nullOrLengthBetween(mixed $value, mixed $min, m...
method allLengthBetween (line 3686) | public static function allLengthBetween(mixed $value, mixed $min, mixe...
method allNullOrLengthBetween (line 3704) | public static function allNullOrLengthBetween(mixed $value, mixed $min...
method nullOrFileExists (line 3720) | public static function nullOrFileExists(mixed $value, string $message ...
method allFileExists (line 3732) | public static function allFileExists(mixed $value, string $message = '...
method allNullOrFileExists (line 3748) | public static function allNullOrFileExists(mixed $value, string $messa...
method nullOrFile (line 3764) | public static function nullOrFile(mixed $value, string $message = ''):...
method allFile (line 3776) | public static function allFile(mixed $value, string $message = ''): it...
method allNullOrFile (line 3792) | public static function allNullOrFile(mixed $value, string $message = '...
method nullOrDirectory (line 3808) | public static function nullOrDirectory(mixed $value, string $message =...
method allDirectory (line 3820) | public static function allDirectory(mixed $value, string $message = ''...
method allNullOrDirectory (line 3836) | public static function allNullOrDirectory(mixed $value, string $messag...
method nullOrReadable (line 3852) | public static function nullOrReadable(mixed $value, string $message = ...
method allReadable (line 3864) | public static function allReadable(mixed $value, string $message = '')...
method allNullOrReadable (line 3880) | public static function allNullOrReadable(mixed $value, string $message...
method nullOrWritable (line 3896) | public static function nullOrWritable(mixed $value, string $message = ...
method allWritable (line 3908) | public static function allWritable(mixed $value, string $message = '')...
method allNullOrWritable (line 3924) | public static function allNullOrWritable(mixed $value, string $message...
method nullOrClassExists (line 3942) | public static function nullOrClassExists(mixed $value, string $message...
method allClassExists (line 3956) | public static function allClassExists(mixed $value, string $message = ...
method allNullOrClassExists (line 3974) | public static function allNullOrClassExists(mixed $value, string $mess...
method nullOrSubclassOf (line 3997) | public static function nullOrSubclassOf(mixed $value, mixed $class, st...
method allSubclassOf (line 4016) | public static function allSubclassOf(mixed $value, mixed $class, strin...
method allNullOrSubclassOf (line 4039) | public static function allNullOrSubclassOf(mixed $value, mixed $class,...
method nullOrInterfaceExists (line 4057) | public static function nullOrInterfaceExists(mixed $value, string $mes...
method allInterfaceExists (line 4071) | public static function allInterfaceExists(mixed $value, string $messag...
method allNullOrInterfaceExists (line 4089) | public static function allNullOrInterfaceExists(mixed $value, string $...
method nullOrImplementsInterface (line 4113) | public static function nullOrImplementsInterface(mixed $value, mixed $...
method allImplementsInterface (line 4133) | public static function allImplementsInterface(mixed $value, mixed $int...
method allNullOrImplementsInterface (line 4157) | public static function allNullOrImplementsInterface(mixed $value, mixe...
method nullOrPropertyExists (line 4177) | public static function nullOrPropertyExists(mixed $classOrObject, mixe...
method allPropertyExists (line 4193) | public static function allPropertyExists(mixed $classOrObject, mixed $...
method allNullOrPropertyExists (line 4213) | public static function allNullOrPropertyExists(mixed $classOrObject, m...
method nullOrPropertyNotExists (line 4235) | public static function nullOrPropertyNotExists(mixed $classOrObject, m...
method allPropertyNotExists (line 4253) | public static function allPropertyNotExists(mixed $classOrObject, mixe...
method allNullOrPropertyNotExists (line 4275) | public static function allNullOrPropertyNotExists(mixed $classOrObject...
method nullOrMethodExists (line 4297) | public static function nullOrMethodExists(mixed $classOrObject, mixed ...
method allMethodExists (line 4315) | public static function allMethodExists(mixed $classOrObject, mixed $me...
method allNullOrMethodExists (line 4337) | public static function allNullOrMethodExists(mixed $classOrObject, mix...
method nullOrMethodNotExists (line 4359) | public static function nullOrMethodNotExists(mixed $classOrObject, mix...
method allMethodNotExists (line 4377) | public static function allMethodNotExists(mixed $classOrObject, mixed ...
method allNullOrMethodNotExists (line 4399) | public static function allNullOrMethodNotExists(mixed $classOrObject, ...
method nullOrKeyExists (line 4419) | public static function nullOrKeyExists(mixed $array, string|int $key, ...
method allKeyExists (line 4435) | public static function allKeyExists(mixed $array, string|int $key, str...
method allNullOrKeyExists (line 4455) | public static function allNullOrKeyExists(mixed $array, string|int $ke...
method nullOrKeyNotExists (line 4475) | public static function nullOrKeyNotExists(mixed $array, string|int $ke...
method allKeyNotExists (line 4491) | public static function allKeyNotExists(mixed $array, string|int $key, ...
method allNullOrKeyNotExists (line 4511) | public static function allNullOrKeyNotExists(mixed $array, string|int ...
method nullOrValidArrayKey (line 4531) | public static function nullOrValidArrayKey(mixed $value, string $messa...
method allValidArrayKey (line 4547) | public static function allValidArrayKey(mixed $value, string $message ...
method allNullOrValidArrayKey (line 4567) | public static function allNullOrValidArrayKey(mixed $value, string $me...
method nullOrCount (line 4583) | public static function nullOrCount(mixed $array, mixed $number, string...
method allCount (line 4595) | public static function allCount(mixed $array, mixed $number, string $m...
method allNullOrCount (line 4611) | public static function allNullOrCount(mixed $array, mixed $number, str...
method nullOrMinCount (line 4627) | public static function nullOrMinCount(mixed $array, mixed $min, string...
method allMinCount (line 4639) | public static function allMinCount(mixed $array, mixed $min, string $m...
method allNullOrMinCount (line 4655) | public static function allNullOrMinCount(mixed $array, mixed $min, str...
method nullOrMaxCount (line 4671) | public static function nullOrMaxCount(mixed $array, mixed $max, string...
method allMaxCount (line 4683) | public static function allMaxCount(mixed $array, mixed $max, string $m...
method allNullOrMaxCount (line 4699) | public static function allNullOrMaxCount(mixed $array, mixed $max, str...
method nullOrCountBetween (line 4715) | public static function nullOrCountBetween(mixed $array, mixed $min, mi...
method allCountBetween (line 4727) | public static function allCountBetween(mixed $array, mixed $min, mixed...
method allNullOrCountBetween (line 4743) | public static function allNullOrCountBetween(mixed $array, mixed $min,...
method nullOrIsList (line 4763) | public static function nullOrIsList(mixed $array, string $message = ''...
method allIsList (line 4779) | public static function allIsList(mixed $array, string $message = ''): ...
method allNullOrIsList (line 4799) | public static function allNullOrIsList(mixed $array, string $message =...
method nullOrIsNonEmptyList (line 4819) | public static function nullOrIsNonEmptyList(mixed $array, string $mess...
method allIsNonEmptyList (line 4835) | public static function allIsNonEmptyList(mixed $array, string $message...
method allNullOrIsNonEmptyList (line 4855) | public static function allNullOrIsNonEmptyList(mixed $array, string $m...
method nullOrIsMap (line 4878) | public static function nullOrIsMap(mixed $array, string $message = '')...
method allIsMap (line 4897) | public static function allIsMap(mixed $array, string $message = ''): m...
method allNullOrIsMap (line 4920) | public static function allNullOrIsMap(mixed $array, string $message = ...
method nullOrIsStatic (line 4940) | public static function nullOrIsStatic(mixed $callable, string $message...
method allIsStatic (line 4956) | public static function allIsStatic(mixed $callable, string $message = ...
method allNullOrIsStatic (line 4976) | public static function allNullOrIsStatic(mixed $callable, string $mess...
method nullOrNotStatic (line 4996) | public static function nullOrNotStatic(mixed $callable, string $messag...
method allNotStatic (line 5012) | public static function allNotStatic(mixed $callable, string $message =...
method allNullOrNotStatic (line 5032) | public static function allNullOrNotStatic(mixed $callable, string $mes...
method nullOrIsNonEmptyMap (line 5054) | public static function nullOrIsNonEmptyMap(mixed $array, string $messa...
method allIsNonEmptyMap (line 5072) | public static function allIsNonEmptyMap(mixed $array, string $message ...
method allNullOrIsNonEmptyMap (line 5096) | public static function allNullOrIsNonEmptyMap(mixed $array, string $me...
method nullOrUuid (line 5114) | public static function nullOrUuid(mixed $value, string $message = ''):...
method allUuid (line 5128) | public static function allUuid(mixed $value, string $message = ''): it...
method allNullOrUuid (line 5146) | public static function allNullOrUuid(mixed $value, string $message = '...
method nullOrThrows (line 5163) | public static function nullOrThrows(mixed $expression, string $class =...
method allThrows (line 5176) | public static function allThrows(mixed $expression, string $class = 'T...
method allNullOrThrows (line 5193) | public static function allNullOrThrows(mixed $expression, string $clas...
FILE: tests/AssertTest.php
class AssertTest (line 35) | class AssertTest extends TestCase
method getResource (line 41) | public static function getResource()
method getTests (line 48) | public static function getTests(): array
method getMethods (line 633) | public static function getMethods(): array
method testAssert (line 644) | #[DataProvider('getTests')]
method testNullOr (line 659) | #[DataProvider('getTests')]
method testNullOrAcceptsNull (line 682) | #[DataProvider('getMethods')]
method testAllArray (line 697) | #[DataProvider('getTests')]
method testAllNullOrArray (line 719) | #[DataProvider('getTests')]
method testAllTraversable (line 752) | #[DataProvider('getTests')]
method getStringConversions (line 774) | public static function getStringConversions(): array
method testConvertValuesToStrings (line 799) | #[DataProvider('getStringConversions')]
method getInvalidInstanceOfCases (line 808) | public static function getInvalidInstanceOfCases(): iterable
method testInstanceOfExceptionMessages (line 831) | #[DataProvider('getInvalidInstanceOfCases')]
method getInvalidIsAOfCases (line 840) | public static function getInvalidIsAOfCases(): iterable
method testIsAOfExceptionMessages (line 868) | #[DataProvider('getInvalidIsAOfCases')]
method testResourceOfTypeCustomMessage (line 877) | public function testResourceOfTypeCustomMessage(): void
method testEnumAssertionErrorMessage (line 885) | public function testEnumAssertionErrorMessage(): void
method testMessageIsPassedToInternalCalls (line 893) | #[DataProvider('getMethodsThatUseOtherMethods')]
method getMethodsThatUseOtherMethods (line 902) | public static function getMethodsThatUseOtherMethods(): array
class ToStringClass (line 1012) | class ToStringClass
method __construct (line 1019) | public function __construct(string $value)
method __toString (line 1024) | public function __toString(): string
FILE: tests/ProjectCodeTest.php
class ProjectCodeTest (line 15) | #[CoversNothing]
method scanStaticContent (line 32) | #[BeforeClass]
method testHasNullOr (line 46) | #[DataProvider('providesMethodNames')]
method testHasAll (line 75) | #[DataProvider('providesMethodNames')]
method testIsInReadme (line 99) | #[DataProvider('providesMethodNames')]
method testHasThrowsAnnotation (line 113) | #[DataProvider('provideMethods')]
method testHasCorrespondingStaticAnalysisFile (line 136) | #[DataProvider('provideMethods')]
method testMixinIsUpToDateVersion (line 152) | public function testMixinIsUpToDateVersion(): void
method providesMethodNames (line 172) | public static function providesMethodNames(): array
method provideMethods (line 182) | public static function provideMethods(): array
method getMethods (line 192) | private static function getMethods(): array
FILE: tests/static-analysis/assert-alnum.php
function alnum (line 12) | function alnum(string $value): string
function nullOrAlnum (line 22) | function nullOrAlnum(?string $value): ?string
function allAlnum (line 34) | function allAlnum(iterable $value): iterable
function allNullOrAlnum (line 46) | function allNullOrAlnum(iterable $value): iterable
FILE: tests/static-analysis/assert-alpha.php
function alpha (line 14) | function alpha(mixed $value): mixed
function nullOrAlpha (line 26) | function nullOrAlpha(mixed $value): mixed
function allAlpha (line 38) | function allAlpha(mixed $value): mixed
function allNullOrAlpha (line 50) | function allNullOrAlpha(mixed $value): mixed
FILE: tests/static-analysis/assert-boolean.php
function boolean (line 14) | function boolean(mixed $value): bool
function nullOrBoolean (line 26) | function nullOrBoolean(mixed $value): ?bool
function allBoolean (line 38) | function allBoolean(mixed $value): iterable
function allNullOrBoolean (line 50) | function allNullOrBoolean(mixed $value): iterable
FILE: tests/static-analysis/assert-classExists.php
function classExists (line 14) | function classExists(mixed $value): string
function nullOrClassExists (line 26) | function nullOrClassExists(mixed $value): ?string
function allClassExists (line 36) | function allClassExists(mixed $value): iterable
function allNullOrClassExists (line 46) | function allNullOrClassExists(mixed $value): iterable
FILE: tests/static-analysis/assert-contains.php
function contains (line 12) | function contains(string $value, string $subString): string
function nullOrContains (line 22) | function nullOrContains(?string $value, string $subString): ?string
function allContains (line 34) | function allContains(iterable $value, string $subString): iterable
function allNullOrContains (line 46) | function allNullOrContains(iterable $value, string $subString): iterable
FILE: tests/static-analysis/assert-count.php
function count (line 13) | function count(Countable|array $value, int $number): Countable|array
function nullOrCount (line 23) | function nullOrCount(Countable|array|null $value, int $number): Countabl...
function allCount (line 33) | function allCount(iterable $value, int $number): iterable
function allNullOrCount (line 43) | function allNullOrCount(iterable $value, int $number): iterable
FILE: tests/static-analysis/assert-countBetween.php
function countBetween (line 15) | function countBetween($value, $min, $max): Countable|array
function nullOrCountBetween (line 27) | function nullOrCountBetween($value, $min, $max): Countable|array|null
function allCountBetween (line 39) | function allCountBetween(iterable $value, $min, $max): iterable
function allNullOrCountBetween (line 51) | function allNullOrCountBetween(iterable $value, $min, $max): iterable
FILE: tests/static-analysis/assert-digits.php
function digits (line 12) | function digits(string $value): string
function nullOrDigits (line 22) | function nullOrDigits(?string $value): ?string
function allDigits (line 34) | function allDigits(iterable $value): iterable
function allNullOrDigits (line 46) | function allNullOrDigits(iterable $value): iterable
FILE: tests/static-analysis/assert-directory.php
function directory (line 12) | function directory(mixed $value): mixed
function nullOrDirectory (line 22) | function nullOrDirectory(mixed $value): mixed
function allDirectory (line 32) | function allDirectory(mixed $value): mixed
function allNullOrDirectory (line 42) | function allNullOrDirectory(mixed $value): mixed
FILE: tests/static-analysis/assert-email.php
function email (line 12) | function email(mixed $value): mixed
function nullOrEmail (line 22) | function nullOrEmail(mixed $value): mixed
function allEmail (line 32) | function allEmail(mixed $value): mixed
function allNullOrEmail (line 42) | function allNullOrEmail(mixed $value): mixed
FILE: tests/static-analysis/assert-endsWith.php
function endsWith (line 12) | function endsWith(string $value, string $suffix): string
function nullOrEndsWith (line 22) | function nullOrEndsWith(?string $value, string $suffix): ?string
function allEndsWith (line 34) | function allEndsWith(iterable $value, string $suffix): iterable
function allNullOrEndsWith (line 46) | function allNullOrEndsWith(iterable $value, string $suffix): iterable
FILE: tests/static-analysis/assert-eq.php
function eq (line 13) | function eq($value, $expect): mixed
function nullOrEq (line 24) | function nullOrEq($value, $expect): mixed
function allEq (line 35) | function allEq($value, $expect): mixed
function allNullOrEq (line 46) | function allNullOrEq($value, $expect): mixed
FILE: tests/static-analysis/assert-false.php
function false (line 16) | function false(mixed $value): bool
function nullOrFalse (line 30) | function nullOrFalse(mixed $value): ?bool
function allFalse (line 42) | function allFalse(mixed $value): iterable
function allNullOrFalse (line 54) | function allNullOrFalse(mixed $value): iterable
FILE: tests/static-analysis/assert-file.php
function file (line 12) | function file(mixed $value): mixed
function nullOrFile (line 22) | function nullOrFile(mixed $value): mixed
function allFile (line 32) | function allFile(mixed $value): mixed
function allNullOrFile (line 42) | function allNullOrFile(mixed $value): mixed
FILE: tests/static-analysis/assert-fileExists.php
function fileExists (line 12) | function fileExists(mixed $value): mixed
function nullOrFileExists (line 22) | function nullOrFileExists(mixed $value): mixed
function allFileExists (line 32) | function allFileExists(mixed $value): mixed
function allNullOrFileExists (line 42) | function allNullOrFileExists(mixed $value): mixed
FILE: tests/static-analysis/assert-float.php
function float (line 14) | function float(mixed $value): float
function nullOrFloat (line 26) | function nullOrFloat(mixed $value): ?float
function allFloat (line 38) | function allFloat(mixed $value): iterable
function allNullOrFloat (line 50) | function allNullOrFloat(mixed $value): iterable
FILE: tests/static-analysis/assert-greaterThan.php
function greaterThan (line 15) | function greaterThan($value, $limit): mixed
function nullOrGreaterThan (line 28) | function nullOrGreaterThan($value, $limit): mixed
function allGreaterThan (line 41) | function allGreaterThan($value, $limit): mixed
function allNullOrGreaterThan (line 54) | function allNullOrGreaterThan($value, $limit): mixed
FILE: tests/static-analysis/assert-greaterThanEq.php
function greaterThanEq (line 15) | function greaterThanEq($value, $limit): mixed
function nullOrGreaterThanEq (line 28) | function nullOrGreaterThanEq($value, $limit): mixed
function allGreaterThanEq (line 41) | function allGreaterThanEq($value, $limit): mixed
function allNullOrGreaterThanEq (line 54) | function allNullOrGreaterThanEq($value, $limit): mixed
FILE: tests/static-analysis/assert-implementsInterface.php
function implementsInterface (line 17) | function implementsInterface(mixed $value)
function nullOrImplementsInterface (line 31) | function nullOrImplementsInterface(mixed $value)
function allImplementsInterface (line 43) | function allImplementsInterface(mixed $value): iterable
function allNullOrImplementsInterface (line 55) | function allNullOrImplementsInterface(mixed $value): iterable
FILE: tests/static-analysis/assert-inArray.php
function inArray (line 14) | function inArray($value, array $values): mixed
function nullOrInArray (line 26) | function nullOrInArray($value, array $values): mixed
function allInArray (line 38) | function allInArray($value, array $values): mixed
function allNullOrInArray (line 50) | function allNullOrInArray($value, array $values): mixed
FILE: tests/static-analysis/assert-integer.php
function integer (line 14) | function integer(mixed $value): int
function nullOrInteger (line 26) | function nullOrInteger(mixed $value): ?int
function allInteger (line 38) | function allInteger(mixed $value): iterable
function allNullOrInteger (line 50) | function allNullOrInteger(mixed $value): iterable
FILE: tests/static-analysis/assert-integerish.php
function integerish (line 16) | function integerish(mixed $value)
function nullOrIntegerish (line 30) | function nullOrIntegerish(mixed $value)
function allIntegerish (line 42) | function allIntegerish(mixed $value): iterable
function allNullOrIntegerish (line 54) | function allNullOrIntegerish(mixed $value): iterable
FILE: tests/static-analysis/assert-interfaceExists.php
function interfaceExists (line 14) | function interfaceExists(mixed $value): string
function nullOrInterfaceExists (line 26) | function nullOrInterfaceExists(mixed $value): ?string
function allInterfaceExists (line 36) | function allInterfaceExists(mixed $value): iterable
function allNullOrInterfaceExists (line 46) | function allNullOrInterfaceExists(mixed $value): iterable
FILE: tests/static-analysis/assert-ip.php
function ip (line 12) | function ip(mixed $value): mixed
function nullOrIp (line 22) | function nullOrIp(mixed $value): mixed
function allIp (line 32) | function allIp(mixed $value): mixed
function allNullOrIp (line 42) | function allNullOrIp(mixed $value): mixed
FILE: tests/static-analysis/assert-ipv4.php
function ipv4 (line 12) | function ipv4($value): mixed
function nullOrIpv4 (line 22) | function nullOrIpv4($value): mixed
function allIpv4 (line 32) | function allIpv4($value): mixed
function allNullOrIpv4 (line 42) | function allNullOrIpv4($value): mixed
FILE: tests/static-analysis/assert-ipv6.php
function ipv6 (line 12) | function ipv6($value): mixed
function nullOrIpv6 (line 22) | function nullOrIpv6($value): mixed
function allIpv6 (line 32) | function allIpv6($value): mixed
function allNullOrIpv6 (line 42) | function allNullOrIpv6($value): mixed
FILE: tests/static-analysis/assert-isAOf.php
function isAOf (line 17) | function isAOf(mixed $value): mixed
function nullOrIsAOf (line 31) | function nullOrIsAOf(mixed $value): mixed
function allIsAOf (line 45) | function allIsAOf(mixed $value): iterable
function allNullOrIsAOf (line 59) | function allNullOrIsAOf(mixed $value): iterable
FILE: tests/static-analysis/assert-isAnyOf.php
function isAnyOf (line 15) | function isAnyOf($value, array $classes): object|string
function nullOrIsAnyOf (line 28) | function nullOrIsAnyOf($value, array $classes): object|string|null
function allIsAnyOf (line 41) | function allIsAnyOf($value, array $classes): iterable
function allNullOrIsAnyOf (line 54) | function allNullOrIsAnyOf($value, array $classes): iterable
FILE: tests/static-analysis/assert-isArray.php
function isArray (line 14) | function isArray(mixed $value): array
function nullOrIsArray (line 26) | function nullOrIsArray(mixed $value): ?array
function allIsArray (line 38) | function allIsArray(mixed $value): iterable
function allNullOrIsArray (line 50) | function allNullOrIsArray(mixed $value): iterable
FILE: tests/static-analysis/assert-isArrayAccessible.php
function isArrayAccessible (line 15) | function isArrayAccessible(mixed $value): array|ArrayAccess
function nullOrIsArrayAccessible (line 27) | function nullOrIsArrayAccessible(mixed $value): array|ArrayAccess|null
function allIsArrayAccessible (line 39) | function allIsArrayAccessible(mixed $value): iterable
function allNullOrIsArrayAccessible (line 51) | function allNullOrIsArrayAccessible(mixed $value): iterable
FILE: tests/static-analysis/assert-isCallable.php
function isCallable (line 14) | function isCallable(mixed $value): callable
function nullOrIsCallable (line 26) | function nullOrIsCallable(mixed $value): ?callable
function allIsCallable (line 38) | function allIsCallable(mixed $value): iterable
function allNullOrIsCallable (line 50) | function allNullOrIsCallable(mixed $value): iterable
FILE: tests/static-analysis/assert-isCountable.php
function isCountable (line 15) | function isCountable(mixed $value): Countable
function nullOrIsCountable (line 27) | function nullOrIsCountable(mixed $value): ?Countable
function allIsCountable (line 41) | function allIsCountable(mixed $value)
function allNullOrIsCountable (line 55) | function allNullOrIsCountable(mixed $value)
FILE: tests/static-analysis/assert-isEmpty.php
function isEmptyNullableObject (line 12) | function isEmptyNullableObject(?object $value): null
function isEmptyString (line 24) | function isEmptyString(string $value)
function isEmptyInt (line 36) | function isEmptyInt(int $value)
function isEmptyBool (line 48) | function isEmptyBool(bool $value)
function isEmptyArray (line 60) | function isEmptyArray(array $value)
function nullOrIsEmpty (line 72) | function nullOrIsEmpty(?object $value)
function allIsEmpty (line 84) | function allIsEmpty(mixed $value): iterable
function allNullOrIsEmpty (line 96) | function allNullOrIsEmpty(mixed $value): iterable
FILE: tests/static-analysis/assert-isInitialized.php
function isInitialized (line 14) | function isInitialized(mixed $value, string $property): object
FILE: tests/static-analysis/assert-isInstanceOf.php
function isInstanceOf (line 15) | function isInstanceOf(mixed $value): Serializable
function nullOrIsInstanceOf (line 27) | function nullOrIsInstanceOf(mixed $value): ?Serializable
function allIsInstanceOf (line 39) | function allIsInstanceOf(mixed $value): iterable
function allNullOrIsInstanceOf (line 51) | function allNullOrIsInstanceOf(mixed $value): iterable
FILE: tests/static-analysis/assert-isInstanceOfAny.php
function isInstanceOfAny (line 13) | function isInstanceOfAny($value, array $classes): mixed
function nullOrIsInstanceOfAny (line 24) | function nullOrIsInstanceOfAny($value, array $classes): mixed
function allIsInstanceOfAny (line 35) | function allIsInstanceOfAny($value, array $classes): mixed
function allNullOrIsInstanceOfAny (line 46) | function allNullOrIsInstanceOfAny($value, array $classes): mixed
FILE: tests/static-analysis/assert-isIterable.php
function isIterable (line 14) | function isIterable(mixed $value): iterable
function nullOrIsIterable (line 26) | function nullOrIsIterable(mixed $value): ?iterable
function allIsIterable (line 38) | function allIsIterable(mixed $value): iterable
function allNullOrIsIterable (line 50) | function allNullOrIsIterable(mixed $value): iterable
FILE: tests/static-analysis/assert-isList.php
function isList (line 17) | function isList(mixed $value): array
function isListWithKnownType (line 31) | function isListWithKnownType(array $value): array
function nullOrIsList (line 45) | function nullOrIsList(mixed $value): ?array
function allIsList (line 57) | function allIsList(mixed $value): iterable
function allNullOrIsList (line 69) | function allNullOrIsList(mixed $value): iterable
FILE: tests/static-analysis/assert-isMap.php
function isMap (line 17) | function isMap(mixed $value): array
function isMapWithKnownType (line 33) | function isMapWithKnownType(array $value): array
function isMapWithEmptyArray (line 47) | function isMapWithEmptyArray(array $value): array
function nullOrIsMap (line 62) | function nullOrIsMap(mixed $value): ?array
function allIsMap (line 74) | function allIsMap(iterable $value): iterable
function allNullOrIsMap (line 86) | function allNullOrIsMap(iterable $value): iterable
FILE: tests/static-analysis/assert-isNonEmptyList.php
function isNonEmptyList (line 16) | function isNonEmptyList(mixed $value): array
function isNonEmptyListWithRange (line 26) | function isNonEmptyListWithRange(): mixed
function nullOrIsNonEmptyList (line 42) | function nullOrIsNonEmptyList(mixed $value): ?array
function allIsNonEmptyList (line 54) | function allIsNonEmptyList(mixed $value): iterable
function allNullOrIsNonEmptyList (line 66) | function allNullOrIsNonEmptyList(mixed $value): iterable
FILE: tests/static-analysis/assert-isNonEmptyMap.php
function isNonEmptyMap (line 17) | function isNonEmptyMap(mixed $value): array
function isNonEmptyMapWithKnownType (line 33) | function isNonEmptyMapWithKnownType(array $value): array
function nullOrIsNonEmptyMap (line 45) | function nullOrIsNonEmptyMap(mixed $value): mixed
function allIsNonEmptyMap (line 57) | function allIsNonEmptyMap(iterable $value): iterable
function allNullOrIsNonEmptyMap (line 69) | function allNullOrIsNonEmptyMap(iterable $value): iterable
FILE: tests/static-analysis/assert-isNotA.php
function isNotA (line 16) | function isNotA(object $value): stdClass
function nullOrIsNotA (line 29) | function nullOrIsNotA($value, $class): object|string|null
function allIsNotA (line 42) | function allIsNotA($value, $class): iterable
function allNullOrIsNotA (line 55) | function allNullOrIsNotA($value, $class): iterable
FILE: tests/static-analysis/assert-isStatic.php
function isStatic (line 11) | function isStatic(mixed $closure): Closure|string
FILE: tests/static-analysis/assert-keyExists.php
function keyExists (line 14) | function keyExists(array $array, $key): array
function nullOrKeyExists (line 26) | function nullOrKeyExists(?array $array, $key): ?array
function allKeyExists (line 39) | function allKeyExists(iterable $array, $key): iterable
function allNullOrKeyExists (line 52) | function allNullOrKeyExists(iterable $array, $key): iterable
FILE: tests/static-analysis/assert-keyNotExists.php
function keyNotExists (line 14) | function keyNotExists(array $array, $key): array
function nullOrKeyNotExists (line 26) | function nullOrKeyNotExists(?array $array, $key): ?array
function allKeyNotExists (line 39) | function allKeyNotExists(iterable $array, $key): iterable
function allNullOrKeyNotExists (line 52) | function allNullOrKeyNotExists(iterable $array, $key): iterable
FILE: tests/static-analysis/assert-length.php
function length (line 12) | function length(string $value, int $length): string
function nullOrLength (line 22) | function nullOrLength(?string $value, int $length): ?string
function allLength (line 34) | function allLength(iterable $value, int $length): iterable
function allNullOrLength (line 46) | function allNullOrLength(iterable $value, int $length): iterable
FILE: tests/static-analysis/assert-lengthBetween.php
function lengthBetween (line 12) | function lengthBetween(string $value, int $min, int $max): string
function nullOrLengthBetween (line 22) | function nullOrLengthBetween(?string $value, int $min, int $max): ?string
function allLengthBetween (line 36) | function allLengthBetween(iterable $value, int $min, int $max): iterable
function allNullOrLengthBetween (line 50) | function allNullOrLengthBetween(iterable $value, int $min, int $max): it...
FILE: tests/static-analysis/assert-lessThan.php
function lessThan (line 15) | function lessThan($value, $limit): mixed
function nullOrLessThan (line 28) | function nullOrLessThan($value, $limit): mixed
function allLessThan (line 41) | function allLessThan($value, $limit): mixed
function allNullOrLessThan (line 54) | function allNullOrLessThan($value, $limit): mixed
FILE: tests/static-analysis/assert-lessThanEq.php
function lessThanEq (line 15) | function lessThanEq($value, $limit): mixed
function nullOrLessThanEq (line 28) | function nullOrLessThanEq($value, $limit): mixed
function allLessThanEq (line 41) | function allLessThanEq($value, $limit): mixed
function allNullOrLessThanEq (line 54) | function allNullOrLessThanEq($value, $limit): mixed
FILE: tests/static-analysis/assert-lower.php
function lower (line 14) | function lower(string $value): string
function nullOrLower (line 26) | function nullOrLower(?string $value): ?string
function allLower (line 38) | function allLower(iterable $value): iterable
function allNullOrLower (line 50) | function allNullOrLower(iterable $value): iterable
FILE: tests/static-analysis/assert-maxCount.php
function maxCount (line 14) | function maxCount($array, $max): Countable|array
function nullOrMaxCount (line 25) | function nullOrMaxCount($array, $max): Countable|array|null
function allMaxCount (line 36) | function allMaxCount(iterable $array, $max): iterable
function allNullOrMaxCount (line 47) | function allNullOrMaxCount(iterable $array, $max): iterable
FILE: tests/static-analysis/assert-maxLength.php
function maxLength (line 12) | function maxLength(string $value, int $max): string
function nullOrMaxLength (line 22) | function nullOrMaxLength(?string $value, int $max): ?string
function allMaxLength (line 36) | function allMaxLength(iterable $value, int $max): iterable
function allNullOrMaxLength (line 50) | function allNullOrMaxLength(iterable $value, int $max): iterable
FILE: tests/static-analysis/assert-methodExists.php
function methodExists (line 15) | function methodExists($classOrObject, $method): string|object
function nullOrMethodExists (line 28) | function nullOrMethodExists($classOrObject, $method): string|object|null
function allMethodExists (line 41) | function allMethodExists(iterable $classOrObject, $method): iterable
function allNullOrMethodExists (line 54) | function allNullOrMethodExists(iterable $classOrObject, $method): iterable
FILE: tests/static-analysis/assert-methodNotExists.php
function methodNotExists (line 15) | function methodNotExists($classOrObject, $method): string|object
function nullOrMethodNotExists (line 28) | function nullOrMethodNotExists($classOrObject, $method): string|object|null
function allMethodNotExists (line 41) | function allMethodNotExists(iterable $classOrObject, $method): iterable
function allNullOrMethodNotExists (line 54) | function allNullOrMethodNotExists(iterable $classOrObject, $method): ite...
FILE: tests/static-analysis/assert-minCount.php
function minCount (line 14) | function minCount($array, $min): Countable|array
function nullOrMinCount (line 25) | function nullOrMinCount($array, $min): Countable|array|null
function allMinCount (line 38) | function allMinCount($array, $min)
function allNullOrMinCount (line 51) | function allNullOrMinCount($array, $min)
FILE: tests/static-analysis/assert-minLength.php
function minLength (line 14) | function minLength(string $value, $min): string
function nullOrMinLength (line 26) | function nullOrMinLength(?string $value, $min): ?string
function allMinLength (line 39) | function allMinLength(iterable $value, $min): iterable
function allNullOrMinLength (line 52) | function allNullOrMinLength(iterable $value, $min): iterable
FILE: tests/static-analysis/assert-natural.php
function natural (line 16) | function natural(mixed $value): int
function nullOrNatural (line 30) | function nullOrNatural(mixed $value): ?int
function allNatural (line 45) | function allNatural(mixed $value): iterable
function allNullOrNatural (line 60) | function allNullOrNatural(mixed $value): iterable
FILE: tests/static-analysis/assert-negativeInteger.php
function negativeInteger (line 16) | function negativeInteger(mixed $value): int
function nullOrNegativeInteger (line 30) | function nullOrNegativeInteger(mixed $value): ?int
function allNegativeInteger (line 44) | function allNegativeInteger(mixed $value): iterable
function allNullOrNegativeInteger (line 58) | function allNullOrNegativeInteger(mixed $value): iterable
FILE: tests/static-analysis/assert-notContains.php
function notContains (line 12) | function notContains(string $value, string $subString): string
function nullOrNotContains (line 22) | function nullOrNotContains(?string $value, string $subString): ?string
function allNotContains (line 34) | function allNotContains(iterable $value, string $subString): iterable
function allNullOrNotContains (line 46) | function allNullOrNotContains(iterable $value, string $subString): iterable
FILE: tests/static-analysis/assert-notEmpty.php
function notEmptyNullableObject (line 12) | function notEmptyNullableObject(?object $value): object
function notEmptyString (line 24) | function notEmptyString(string $value)
function notEmptyBool (line 36) | function notEmptyBool(bool $value)
function notEmptyArray (line 48) | function notEmptyArray(array $value)
function nullOrNotEmpty (line 60) | function nullOrNotEmpty(mixed $value): mixed
function allNotEmpty (line 72) | function allNotEmpty(mixed $value): mixed
function allNullOrNotEmpty (line 84) | function allNullOrNotEmpty(mixed $value): mixed
FILE: tests/static-analysis/assert-notEq.php
function notEq (line 13) | function notEq($value, $expect): mixed
function nullOrNotEq (line 24) | function nullOrNotEq($value, $expect): mixed
function allNotEq (line 35) | function allNotEq($value, $expect): mixed
function allNullOrNotEq (line 46) | function allNullOrNotEq($value, $expect): mixed
FILE: tests/static-analysis/assert-notFalse.php
function notFalseBool (line 14) | function notFalseBool(bool $value): bool
function notFalseUnion (line 26) | function notFalseUnion(mixed $value): string
function nullOrNotFalse (line 38) | function nullOrNotFalse(mixed $value): mixed
function allNotFalse (line 50) | function allNotFalse(mixed $value): mixed
function allNullOrNotFalse (line 62) | function allNullOrNotFalse(mixed $value): mixed
FILE: tests/static-analysis/assert-notInArray.php
function notInArray (line 10) | function notInArray(mixed $value, array $values): mixed
function nullOrNotInArray (line 20) | function nullOrNotInArray(mixed $value, array $values): mixed
function allNotInArray (line 30) | function allNotInArray(mixed $value, array $values): mixed
FILE: tests/static-analysis/assert-notInstanceOf.php
function notInstanceOf (line 14) | function notInstanceOf(mixed $value): DateTime
function nullOrNotInstanceOf (line 27) | function nullOrNotInstanceOf($value, $class): mixed
function allNotInstanceOf (line 40) | function allNotInstanceOf($value, $class): mixed
function allNullOrNotInstanceOf (line 53) | function allNullOrNotInstanceOf($value, $class): mixed
FILE: tests/static-analysis/assert-notNegativeInteger.php
function nonNegativeInteger (line 16) | function nonNegativeInteger(mixed $value): int
function nullOrNonNegativeInteger (line 32) | function nullOrNonNegativeInteger(mixed $value): ?int
function allNonNegativeInteger (line 46) | function allNonNegativeInteger(mixed $value): iterable
function allNullOrNonNegativeInteger (line 60) | function allNullOrNonNegativeInteger(mixed $value): iterable
FILE: tests/static-analysis/assert-notNull.php
function notNull (line 12) | function notNull(?object $value): object
function allNotNull (line 24) | function allNotNull(mixed $value): mixed
FILE: tests/static-analysis/assert-notOneOf.php
function notOneOf (line 10) | function notOneOf(mixed $value, array $values): mixed
function nullOrNotOneOf (line 20) | function nullOrNotOneOf(mixed $value, array $values): mixed
function allNotOneOf (line 30) | function allNotOneOf(mixed $value, array $values): mixed
FILE: tests/static-analysis/assert-notRegex.php
function notRegex (line 12) | function notRegex(string $value, string $pattern): string
function nullOrNotRegex (line 22) | function nullOrNotRegex(?string $value, string $pattern): ?string
function allNotRegex (line 34) | function allNotRegex(iterable $value, string $pattern): iterable
function allNullOrNotRegex (line 46) | function allNullOrNotRegex(iterable $value, string $pattern): iterable
FILE: tests/static-analysis/assert-notSame.php
function notSame (line 15) | function notSame($value, $expect): mixed
function nullOrNotSame (line 28) | function nullOrNotSame($value, $expect): mixed
function allNotSame (line 41) | function allNotSame($value, $expect): mixed
function allNullOrNotSame (line 54) | function allNullOrNotSame($value, $expect): mixed
FILE: tests/static-analysis/assert-notStatic.php
function notStatic (line 11) | function notStatic(mixed $closure): Closure|string
FILE: tests/static-analysis/assert-notWhitespaceOnly.php
function notWhitespaceOnly (line 12) | function notWhitespaceOnly(string $value): string
function nullOrNotWhitespaceOnly (line 22) | function nullOrNotWhitespaceOnly(?string $value): ?string
function allNotWhitespaceOnly (line 34) | function allNotWhitespaceOnly(iterable $value): iterable
function allNullOrNotWhitespaceOnly (line 46) | function allNullOrNotWhitespaceOnly(iterable $value): iterable
FILE: tests/static-analysis/assert-null.php
function null (line 14) | function null(mixed $value): null
function allNull (line 26) | function allNull(mixed $value): iterable
FILE: tests/static-analysis/assert-numeric.php
function numeric (line 16) | function numeric(mixed $value)
function nullOrNumeric (line 30) | function nullOrNumeric(mixed $value)
function allNumeric (line 42) | function allNumeric(mixed $value): iterable
function allNullOrNumeric (line 54) | function allNullOrNumeric(mixed $value): iterable
FILE: tests/static-analysis/assert-object.php
function object (line 14) | function object(mixed $value): object
function nullOrObject (line 26) | function nullOrObject(mixed $value): ?object
function allObject (line 38) | function allObject(mixed $value): iterable
function allNullOrObject (line 50) | function allNullOrObject(mixed $value): iterable
FILE: tests/static-analysis/assert-objectish.php
function objectish (line 14) | function objectish(mixed $value): object|string
function nullOrObjectish (line 26) | function nullOrObjectish(mixed $value): object|string|null
function allObjectish (line 38) | function allObjectish(mixed $value): iterable
function allNullOrObjectish (line 50) | function allNullOrObjectish(mixed $value): iterable
FILE: tests/static-analysis/assert-oneOf.php
function oneOf (line 14) | function oneOf($value, array $values): mixed
function nullOrOneOf (line 26) | function nullOrOneOf($value, array $values): mixed
function allOneOf (line 38) | function allOneOf($value, array $values): mixed
function allNullOrOneOf (line 50) | function allNullOrOneOf($value, array $values): mixed
FILE: tests/static-analysis/assert-positiveInteger.php
function positiveInteger (line 16) | function positiveInteger(mixed $value): int
function positiveIntegerFiltersOutZero (line 30) | function positiveIntegerFiltersOutZero(mixed $value): int
function nullOrPositiveInteger (line 44) | function nullOrPositiveInteger(mixed $value): ?int
function allPositiveInteger (line 56) | function allPositiveInteger(mixed $value): iterable
function allNullOrPositiveInteger (line 68) | function allNullOrPositiveInteger(mixed $value): iterable
FILE: tests/static-analysis/assert-propertyExists.php
function propertyExists (line 15) | function propertyExists($classOrObject, $property): string|object
function nullOrPropertyExists (line 28) | function nullOrPropertyExists($classOrObject, $property): string|object|...
function allPropertyExists (line 41) | function allPropertyExists(iterable $classOrObject, $property): iterable
function allNullOrPropertyExists (line 54) | function allNullOrPropertyExists(iterable $classOrObject, $property): it...
FILE: tests/static-analysis/assert-propertyNotExists.php
function propertyNotExists (line 15) | function propertyNotExists($classOrObject, $property): string|object
function nullOrPropertyNotExists (line 28) | function nullOrPropertyNotExists($classOrObject, $property): string|obje...
function allPropertyNotExists (line 41) | function allPropertyNotExists(iterable $classOrObject, $property): iterable
function allNullOrPropertyNotExists (line 54) | function allNullOrPropertyNotExists(iterable $classOrObject, $property):...
FILE: tests/static-analysis/assert-psalm-notRedundant.php
function stringWillNotBeRedundantIfAssertingAndNotUsingEither (line 18) | function stringWillNotBeRedundantIfAssertingAndNotUsingEither(mixed $val...
FILE: tests/static-analysis/assert-psalm-preserveContainerType.php
function preserveContainerAllArray (line 17) | function preserveContainerAllArray(mixed $value): iterable
function preserveContainerAllArrayIterator (line 31) | function preserveContainerAllArrayIterator(mixed $value)
FILE: tests/static-analysis/assert-psalm-preserveStringType.php
function lowerPreservesTypes (line 16) | function lowerPreservesTypes(string $value): string
FILE: tests/static-analysis/assert-range.php
function range (line 16) | function range($value, $min, $max): mixed
function nullOrRange (line 30) | function nullOrRange($value, $min, $max): mixed
function allRange (line 44) | function allRange($value, $min, $max): mixed
function allNullOrRange (line 58) | function allNullOrRange($value, $min, $max): mixed
FILE: tests/static-analysis/assert-readable.php
function readable (line 9) | function readable(string $value): string
function nullOrReadable (line 16) | function nullOrReadable(?string $value): ?string
function allReadable (line 26) | function allReadable(iterable $value): iterable
function allNullOrReadable (line 36) | function allNullOrReadable(iterable $value): iterable
FILE: tests/static-analysis/assert-regex.php
function regex (line 12) | function regex(string $value, string $pattern): string
function nullOrRegex (line 22) | function nullOrRegex(?string $value, string $pattern): ?string
function allRegex (line 34) | function allRegex(iterable $value, string $pattern): iterable
function allNullOrRegex (line 46) | function allNullOrRegex(iterable $value, string $pattern): iterable
FILE: tests/static-analysis/assert-resource.php
function resource (line 15) | function resource(mixed $value, ?string $type): mixed
function nullOrResource (line 28) | function nullOrResource(mixed $value, ?string $type): mixed
function allResource (line 41) | function allResource($value, $type): iterable
function allNullOrResource (line 54) | function allNullOrResource($value, $type): iterable
FILE: tests/static-analysis/assert-same.php
function same (line 15) | function same($value, $expect): mixed
function nullOrSame (line 28) | function nullOrSame($value, $expect): mixed
function allSame (line 41) | function allSame($value, $expect): mixed
function allNullOrSame (line 54) | function allNullOrSame($value, $expect): mixed
FILE: tests/static-analysis/assert-scalar.php
function scalar (line 14) | function scalar(mixed $value): int|float|string|bool
function nullOrScalar (line 26) | function nullOrScalar(mixed $value): int|float|string|bool|null
function allScalar (line 38) | function allScalar(mixed $value): iterable
function allNullOrScalar (line 50) | function allNullOrScalar(mixed $value): iterable
FILE: tests/static-analysis/assert-startsWith.php
function startsWith (line 12) | function startsWith(string $value, string $prefix): string
function nullOrStartsWith (line 22) | function nullOrStartsWith(?string $value, string $prefix): ?string
function allStartsWith (line 34) | function allStartsWith(iterable $value, string $prefix): iterable
function allNullOrStartsWith (line 46) | function allNullOrStartsWith(iterable $value, string $prefix): iterable
FILE: tests/static-analysis/assert-startsWithLetter.php
function startsWithLetter (line 14) | function startsWithLetter($value, string $prefix): mixed
function nullOrStartsWithLetter (line 26) | function nullOrStartsWithLetter($value, string $prefix): mixed
function allStartsWithLetter (line 38) | function allStartsWithLetter($value, string $prefix): mixed
function allNullOrStartsWithLetter (line 50) | function allNullOrStartsWithLetter($value, string $prefix): mixed
FILE: tests/static-analysis/assert-string.php
function string (line 14) | function string(mixed $value): string
function nullOrString (line 26) | function nullOrString(mixed $value): ?string
function allString (line 38) | function allString(mixed $value): iterable
function allNullOrString (line 50) | function allNullOrString(mixed $value): iterable
FILE: tests/static-analysis/assert-stringNotEmpty.php
function stringNotEmpty (line 16) | function stringNotEmpty(mixed $value): string
function nullOrStringNotEmpty (line 30) | function nullOrStringNotEmpty(mixed $value): ?string
function allStringNotEmpty (line 42) | function allStringNotEmpty(mixed $value): iterable
function allNullOrStringNotEmpty (line 54) | function allNullOrStringNotEmpty(mixed $value): iterable
FILE: tests/static-analysis/assert-subclassOf.php
function subclassOf (line 17) | function subclassOf(mixed $value)
function nullOrSubclassOf (line 31) | function nullOrSubclassOf(mixed $value)
function allSubclassOf (line 43) | function allSubclassOf(mixed $value): iterable
function allNullOrSubclassOf (line 55) | function allNullOrSubclassOf(mixed $value): iterable
FILE: tests/static-analysis/assert-throws.php
function throws (line 14) | function throws(Closure $value, $class): Closure
function nullOrThrows (line 24) | function nullOrThrows(?Closure $value, $class): ?Closure
function allThrows (line 35) | function allThrows(iterable $value, $class): iterable
function allNullOrThrows (line 45) | function allNullOrThrows(iterable $value, $class): iterable
FILE: tests/static-analysis/assert-true.php
function true (line 16) | function true(mixed $value): bool
function nullOrTrue (line 30) | function nullOrTrue(mixed $value): ?bool
function allTrue (line 42) | function allTrue(mixed $value): iterable
function allNullOrTrue (line 54) | function allNullOrTrue(mixed $value): iterable
FILE: tests/static-analysis/assert-unicodeLetters.php
function unicodeLetters (line 14) | function unicodeLetters(mixed $value): mixed
function nullOrUnicodeLetters (line 26) | function nullOrUnicodeLetters(mixed $value): mixed
function allUnicodeLetters (line 38) | function allUnicodeLetters(mixed $value): mixed
function allNullOrUnicodeLetters (line 50) | function allNullOrUnicodeLetters(mixed $value): mixed
FILE: tests/static-analysis/assert-uniqueValues.php
function uniqueValues (line 9) | function uniqueValues(array $values): array
function nullOrUniqueValues (line 16) | function nullOrUniqueValues(?array $values): ?array
function allUniqueValues (line 26) | function allUniqueValues(iterable $values): iterable
function allNullOrUniqueValues (line 36) | function allNullOrUniqueValues(iterable $values): iterable
FILE: tests/static-analysis/assert-upper.php
function upper (line 12) | function upper(mixed $value): string
function nullOrUpper (line 22) | function nullOrUpper(?string $value): ?string
function allUpper (line 34) | function allUpper(iterable $value): iterable
function allNullOrUpper (line 46) | function allNullOrUpper(iterable $value): iterable
FILE: tests/static-analysis/assert-uuid.php
function uuid (line 12) | function uuid(string $value): string
function nullOrUuid (line 22) | function nullOrUuid(?string $value): ?string
function allUuid (line 34) | function allUuid(iterable $value): iterable
function allNullOrUuid (line 46) | function allNullOrUuid(iterable $value): iterable
FILE: tests/static-analysis/assert-validArrayKey.php
function validArrayKey (line 16) | function validArrayKey(mixed $value)
function nullOrValidArrayKey (line 30) | function nullOrValidArrayKey(mixed $value)
function allValidArrayKey (line 42) | function allValidArrayKey(mixed $value): iterable
function allNullOrValidArrayKey (line 54) | function allNullOrValidArrayKey(mixed $value): iterable
FILE: tests/static-analysis/assert-writable.php
function writable (line 9) | function writable(string $value): string
function nullOrWritable (line 16) | function nullOrWritable(?string $value): ?string
function allWritable (line 26) | function allWritable(iterable $value): iterable
function allNullOrWritable (line 36) | function allNullOrWritable(iterable $value): iterable
Condensed preview — 124 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (390K chars).
[
{
"path": ".editorconfig",
"chars": 165,
"preview": "root = true\n\n[*]\ncharset=utf-8\nend_of_line=lf\ntrim_trailing_whitespace=true\ninsert_final_newline=true\nindent_style=space"
},
{
"path": ".gitattributes",
"chars": 396,
"preview": "/.gitattributes export-ignore\n/.gitignore export-ignore\n/.github export-ignore\n/.php-cs-fix"
},
{
"path": ".github/workflows/ci.yaml",
"chars": 2366,
"preview": "# https://docs.github.com/en/actions\n\nname: CI\n\non:\n pull_request: ~\n push:\n branches:\n - master\n\njobs:\n\n sta"
},
{
"path": ".gitignore",
"chars": 65,
"preview": "vendor/\n/composer.lock\n.php-cs-fixer.cache\n.phpunit.result.cache\n"
},
{
"path": ".php-cs-fixer.php",
"chars": 784,
"preview": "<?php\n\n$finder = PhpCsFixer\\Finder::create()\n ->in(__DIR__.'/src')\n ->in(__DIR__.'/tests')\n;\n\nreturn (new PhpCsFix"
},
{
"path": "CHANGELOG.md",
"chars": 7690,
"preview": "Changelog\n=========\n\n## 2.1.6\n\n### Fixed\n\n- Corrected docblocks for `list*` methods.\n\n## 2.1.5\n\n### Fixed\n\n- Fixed regre"
},
{
"path": "LICENSE",
"chars": 1084,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2014 Bernhard Schussek\n\nPermission is hereby granted, free of charge, to any person"
},
{
"path": "README.md",
"chars": 16903,
"preview": "Webmozart Assert\n================\n\n[](http"
},
{
"path": "bin/generate.php",
"chars": 378,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * this file is used by maintainers of the library to re-generate the type definiti"
},
{
"path": "bin/src/MixinGenerator.php",
"chars": 18742,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Bin;\n\nuse ArrayAccess;\nuse Countable;\nuse ReflectionClass;\nu"
},
{
"path": "composer.json",
"chars": 2052,
"preview": "{\n \"name\": \"webmozart/assert\",\n \"description\": \"Assertions to validate method input/output with nice error message"
},
{
"path": "phpunit.xml.dist",
"chars": 544,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:noNam"
},
{
"path": "psalm.xml",
"chars": 409,
"preview": "<?xml version=\"1.0\"?>\n<psalm\n errorLevel=\"8\"\n resolveFromConfigFile=\"true\"\n xmlns:xsi=\"http://www.w3.org/2001/X"
},
{
"path": "src/Assert.php",
"chars": 59930,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/*\n * This file is part of the webmozart/assert package.\n *\n * (c) Bernhard Schussek <b"
},
{
"path": "src/InvalidArgumentException.php",
"chars": 372,
"preview": "<?php\n\ndeclare(strict_types=1);\n/*\n * This file is part of the webmozart/assert package.\n *\n * (c) Bernhard Schussek <bs"
},
{
"path": "src/Mixin.php",
"chars": 119803,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert;\n\nuse ArrayAccess;\nuse Countable;\nuse Throwable;\n\n/**\n * Thi"
},
{
"path": "tests/AssertTest.php",
"chars": 45147,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/*\n * This file is part of the webmozart/assert package.\n *\n * (c) Bernhard Schussek <b"
},
{
"path": "tests/DummyEnum.php",
"chars": 210,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests;\n\n// The filename must be different from the class nam"
},
{
"path": "tests/ProjectCodeTest.php",
"chars": 6263,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests;\n\nuse PHPUnit\\Framework\\Attributes\\BeforeClass;\nuse PH"
},
{
"path": "tests/static-analysis/assert-alnum.php",
"chars": 689,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-alpha.php",
"chars": 696,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-boolean.php",
"chars": 717,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-classExists.php",
"chars": 740,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-contains.php",
"chars": 837,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-count.php",
"chars": 853,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Countable;\nuse Webmozart\\Assert\\A"
},
{
"path": "tests/static-analysis/assert-countBetween.php",
"chars": 1086,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Countable;\nuse Webmozart\\Assert\\A"
},
{
"path": "tests/static-analysis/assert-digits.php",
"chars": 697,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-directory.php",
"chars": 656,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-email.php",
"chars": 624,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-endsWith.php",
"chars": 813,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-eq.php",
"chars": 744,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-false.php",
"chars": 740,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-file.php",
"chars": 616,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-fileExists.php",
"chars": 664,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-float.php",
"chars": 703,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-greaterThan.php",
"chars": 876,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-greaterThanEq.php",
"chars": 892,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-implementsInterface.php",
"chars": 1015,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Serializable;\nuse Webmozart\\Asser"
},
{
"path": "tests/static-analysis/assert-inArray.php",
"chars": 784,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-integer.php",
"chars": 715,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-integerish.php",
"chars": 777,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-interfaceExists.php",
"chars": 772,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-ip.php",
"chars": 600,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-ipv4.php",
"chars": 592,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-ipv6.php",
"chars": 592,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-isAOf.php",
"chars": 1124,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Serializable;\nuse Webmozart\\Asser"
},
{
"path": "tests/static-analysis/assert-isAnyOf.php",
"chars": 1037,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-isArray.php",
"chars": 719,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-isArrayAccessible.php",
"chars": 844,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse ArrayAccess;\nuse Webmozart\\Assert"
},
{
"path": "tests/static-analysis/assert-isCallable.php",
"chars": 749,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-isCountable.php",
"chars": 827,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse countable;\nuse Webmozart\\Assert\\A"
},
{
"path": "tests/static-analysis/assert-isEmpty.php",
"chars": 1242,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-isInitialized.php",
"chars": 296,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-isInstanceOf.php",
"chars": 875,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Serializable;\nuse Webmozart\\Asser"
},
{
"path": "tests/static-analysis/assert-isInstanceOfAny.php",
"chars": 940,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-isIterable.php",
"chars": 749,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-isList.php",
"chars": 973,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse stdClass;\nuse Webmozart\\Assert\\As"
},
{
"path": "tests/static-analysis/assert-isMap.php",
"chars": 1376,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse stdClass;\nuse Webmozart\\Assert\\As"
},
{
"path": "tests/static-analysis/assert-isNonEmptyList.php",
"chars": 1010,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-isNonEmptyMap.php",
"chars": 1192,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse stdClass;\nuse Webmozart\\Assert\\As"
},
{
"path": "tests/static-analysis/assert-isNotA.php",
"chars": 982,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse DateTime;\nuse stdClass;\nuse Webmo"
},
{
"path": "tests/static-analysis/assert-isStatic.php",
"chars": 236,
"preview": "<?php\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Closure;\nuse Webmozart\\Assert\\Assert;\n\n/**\n * @return Closu"
},
{
"path": "tests/static-analysis/assert-keyExists.php",
"chars": 869,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-keyNotExists.php",
"chars": 893,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-length.php",
"chars": 785,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-lengthBetween.php",
"chars": 948,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-lessThan.php",
"chars": 852,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-lessThanEq.php",
"chars": 868,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-lower.php",
"chars": 756,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-maxCount.php",
"chars": 906,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Countable;\nuse Webmozart\\Assert\\A"
},
{
"path": "tests/static-analysis/assert-maxLength.php",
"chars": 846,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-methodExists.php",
"chars": 1155,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-methodNotExists.php",
"chars": 1179,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-minCount.php",
"chars": 953,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Countable;\nuse Webmozart\\Assert\\A"
},
{
"path": "tests/static-analysis/assert-minLength.php",
"chars": 875,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-natural.php",
"chars": 1138,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-negativeInteger.php",
"chars": 929,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-notContains.php",
"chars": 861,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-notEmpty.php",
"chars": 1136,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-notEq.php",
"chars": 768,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-notFalse.php",
"chars": 871,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-notInArray.php",
"chars": 539,
"preview": "<?php\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * @psalm-pure\n */\nfunction n"
},
{
"path": "tests/static-analysis/assert-notInstanceOf.php",
"chars": 979,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse DateTime;\nuse stdClass;\nuse Webmo"
},
{
"path": "tests/static-analysis/assert-notNegativeInteger.php",
"chars": 985,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-notNull.php",
"chars": 377,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-notOneOf.php",
"chars": 527,
"preview": "<?php\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * @psalm-pure\n */\nfunction n"
},
{
"path": "tests/static-analysis/assert-notRegex.php",
"chars": 815,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-notSame.php",
"chars": 856,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-notStatic.php",
"chars": 238,
"preview": "<?php\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Closure;\nuse Webmozart\\Assert\\Assert;\n\n/**\n * @return Closu"
},
{
"path": "tests/static-analysis/assert-notWhitespaceOnly.php",
"chars": 785,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-null.php",
"chars": 390,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-numeric.php",
"chars": 753,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-object.php",
"chars": 713,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-objectish.php",
"chars": 755,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-oneOf.php",
"chars": 768,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-positiveInteger.php",
"chars": 1037,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-propertyExists.php",
"chars": 1189,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-propertyNotExists.php",
"chars": 1219,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-psalm-notRedundant.php",
"chars": 511,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-psalm-preserveContainerType.php",
"chars": 549,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse ArrayIterator;\nuse Webmozart\\Asse"
},
{
"path": "tests/static-analysis/assert-psalm-preserveStringType.php",
"chars": 307,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-range.php",
"chars": 936,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-readable.php",
"chars": 631,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\nfunctio"
},
{
"path": "tests/static-analysis/assert-regex.php",
"chars": 791,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-resource.php",
"chars": 898,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-same.php",
"chars": 832,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-scalar.php",
"chars": 747,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-startsWith.php",
"chars": 829,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-startsWithLetter.php",
"chars": 860,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-string.php",
"chars": 713,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-stringNotEmpty.php",
"chars": 844,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-subclassOf.php",
"chars": 907,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse stdClass;\nuse Webmozart\\Assert\\As"
},
{
"path": "tests/static-analysis/assert-throws.php",
"chars": 892,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Closure;\nuse Throwable;\nuse Webmo"
},
{
"path": "tests/static-analysis/assert-true.php",
"chars": 736,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-unicodeLetters.php",
"chars": 768,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-uniqueValues.php",
"chars": 671,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\nfunctio"
},
{
"path": "tests/static-analysis/assert-upper.php",
"chars": 688,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-uuid.php",
"chars": 681,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-validArrayKey.php",
"chars": 805,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\n/**\n * "
},
{
"path": "tests/static-analysis/assert-writable.php",
"chars": 631,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Webmozart\\Assert\\Tests\\StaticAnalysis;\n\nuse Webmozart\\Assert\\Assert;\n\nfunctio"
},
{
"path": "tools/php-cs-fixer/composer.json",
"chars": 122,
"preview": "{\n \"require\": {\n \"php\": \"^8.2\"\n },\n \"require-dev\": {\n \"friendsofphp/php-cs-fixer\": \"^3.64\"\n }\n"
},
{
"path": "tools/phpunit/composer.json",
"chars": 112,
"preview": "{\n \"require\": {\n \"php\": \"^8.2\"\n },\n \"require-dev\": {\n \"phpunit/phpunit\": \"^11.0\"\n }\n}\n"
},
{
"path": "tools/psalm/composer.json",
"chars": 107,
"preview": "{\n \"require\": {\n \"php\": \"^8.2\"\n },\n \"require-dev\": {\n \"vimeo/psalm\": \"^6.0\"\n }\n}\n"
},
{
"path": "tools/roave-bc-check/composer.json",
"chars": 131,
"preview": "{\n \"require\": {\n \"php\": \"^8.2\"\n },\n \"require-dev\": {\n \"roave/backward-compatibility-check\": \"^8.1"
}
]
About this extraction
This page contains the full source code of the webmozarts/assert GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 124 files (356.6 KB), approximately 96.5k tokens, and a symbol index with 849 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.