Dep: update
주로 PHAN
This commit is contained in:
Vendored
+13
-9
@@ -1,9 +1,6 @@
|
||||
Webmozart Assert
|
||||
================
|
||||
|
||||
[](https://travis-ci.org/webmozart/assert)
|
||||
[](https://ci.appveyor.com/project/webmozart/assert/branch/master)
|
||||
[](https://scrutinizer-ci.com/g/webmozart/assert/?branch=master)
|
||||
[](https://packagist.org/packages/webmozart/assert)
|
||||
[](https://packagist.org/packages/webmozart/assert)
|
||||
|
||||
@@ -11,7 +8,7 @@ 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 `\InvalidArgumentException` if
|
||||
All assertions in the [`Assert`] class throw an `Webmozart\Assert\InvalidArgumentException` if
|
||||
they fail.
|
||||
|
||||
FAQ
|
||||
@@ -70,11 +67,11 @@ If you create an employee with an invalid ID, an exception is thrown:
|
||||
|
||||
```php
|
||||
new Employee('foobar');
|
||||
// => InvalidArgumentException:
|
||||
// => Webmozart\Assert\InvalidArgumentException:
|
||||
// The employee ID must be an integer. Got: string
|
||||
|
||||
new Employee(-10);
|
||||
// => InvalidArgumentException:
|
||||
// => Webmozart\Assert\InvalidArgumentException:
|
||||
// The employee ID must be a positive integer. Got: -10
|
||||
```
|
||||
|
||||
@@ -91,6 +88,7 @@ Method | Description
|
||||
`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
|
||||
`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
|
||||
@@ -104,10 +102,10 @@ Method | Description
|
||||
`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` a at least one class on the array of classes
|
||||
`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 a at least one 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
|
||||
@@ -143,7 +141,7 @@ 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 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
|
||||
@@ -251,6 +249,12 @@ Overriding the following methods in your assertion class allows you to change th
|
||||
* `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
|
||||
-------
|
||||
|
||||
Reference in New Issue
Block a user