From 500f5d25e82391ec327328aee622969210bef099 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 11 Dec 2019 11:49:51 +0100 Subject: [PATCH] Marking pure API with `@psalm-pure` for usage in pure downstream consumers --- src/Assert.php | 99 +++++++++++++++++++ tests/static-analysis/assert-alpha.php | 4 + tests/static-analysis/assert-boolean.php | 1 + tests/static-analysis/assert-classExists.php | 1 + tests/static-analysis/assert-false.php | 1 + tests/static-analysis/assert-float.php | 1 + .../assert-implementsInterface.php | 4 + tests/static-analysis/assert-integer.php | 1 + tests/static-analysis/assert-integerish.php | 1 + .../assert-interfaceExists.php | 2 + tests/static-analysis/assert-isArray.php | 1 + .../assert-isArrayAccessible.php | 1 + tests/static-analysis/assert-isCallable.php | 1 + tests/static-analysis/assert-isCountable.php | 1 + tests/static-analysis/assert-isEmpty.php | 3 +- tests/static-analysis/assert-isInstanceOf.php | 1 + tests/static-analysis/assert-isIterable.php | 1 + tests/static-analysis/assert-isList.php | 4 + tests/static-analysis/assert-isMap.php | 4 + .../static-analysis/assert-isNonEmptyList.php | 2 + .../static-analysis/assert-isNonEmptyMap.php | 4 + .../static-analysis/assert-isTraversable.php | 1 + tests/static-analysis/assert-natural.php | 1 + tests/static-analysis/assert-notEmpty.php | 3 + .../static-analysis/assert-notInstanceOf.php | 1 + tests/static-analysis/assert-notNull.php | 3 + tests/static-analysis/assert-null.php | 1 + tests/static-analysis/assert-numeric.php | 3 +- tests/static-analysis/assert-object.php | 1 + tests/static-analysis/assert-resource.php | 1 + tests/static-analysis/assert-same.php | 3 + tests/static-analysis/assert-scalar.php | 1 + .../assert-startsWithLetter.php | 1 + tests/static-analysis/assert-string.php | 1 + .../static-analysis/assert-stringNotEmpty.php | 1 + tests/static-analysis/assert-subclassOf.php | 2 + tests/static-analysis/assert-true.php | 1 + .../static-analysis/assert-unicodeLetters.php | 1 + .../static-analysis/assert-validArrayKey.php | 1 + 39 files changed, 163 insertions(+), 2 deletions(-) diff --git a/src/Assert.php b/src/Assert.php index 450394ed..67575050 100644 --- a/src/Assert.php +++ b/src/Assert.php @@ -201,6 +201,7 @@ class Assert { /** + * @psalm-pure * @psalm-assert string $value * * @param mixed $value @@ -219,6 +220,7 @@ public static function string($value, $message = '') } /** + * @psalm-pure * @psalm-assert string $value * @psalm-assert !empty $value * @@ -234,6 +236,7 @@ public static function stringNotEmpty($value, $message = '') } /** + * @psalm-pure * @psalm-assert int $value * * @param mixed $value @@ -252,6 +255,7 @@ public static function integer($value, $message = '') } /** + * @psalm-pure * @psalm-assert numeric $value * * @param mixed $value @@ -270,6 +274,7 @@ public static function integerish($value, $message = '') } /** + * @psalm-pure * @psalm-assert float $value * * @param mixed $value @@ -288,6 +293,7 @@ public static function float($value, $message = '') } /** + * @psalm-pure * @psalm-assert numeric $value * * @param mixed $value @@ -306,6 +312,7 @@ public static function numeric($value, $message = '') } /** + * @psalm-pure * @psalm-assert int $value * * @param mixed $value @@ -324,6 +331,7 @@ public static function natural($value, $message = '') } /** + * @psalm-pure * @psalm-assert bool $value * * @param mixed $value @@ -342,6 +350,7 @@ public static function boolean($value, $message = '') } /** + * @psalm-pure * @psalm-assert scalar $value * * @param mixed $value @@ -360,6 +369,7 @@ public static function scalar($value, $message = '') } /** + * @psalm-pure * @psalm-assert object $value * * @param mixed $value @@ -378,6 +388,7 @@ public static function object($value, $message = '') } /** + * @psalm-pure * @psalm-assert resource $value * * @param mixed $value @@ -405,6 +416,7 @@ public static function resource($value, $type = null, $message = '') } /** + * @psalm-pure * @psalm-assert callable $value * * @param mixed $value @@ -423,6 +435,7 @@ public static function isCallable($value, $message = '') } /** + * @psalm-pure * @psalm-assert array $value * * @param mixed $value @@ -441,6 +454,7 @@ public static function isArray($value, $message = '') } /** + * @psalm-pure * @psalm-assert iterable $value * * @deprecated use "isIterable" or "isInstanceOf" instead @@ -469,6 +483,7 @@ public static function isTraversable($value, $message = '') } /** + * @psalm-pure * @psalm-assert array|ArrayAccess $value * * @param mixed $value @@ -487,6 +502,7 @@ public static function isArrayAccessible($value, $message = '') } /** + * @psalm-pure * @psalm-assert countable $value * * @param mixed $value @@ -510,6 +526,7 @@ public static function isCountable($value, $message = '') } /** + * @psalm-pure * @psalm-assert iterable $value * * @param mixed $value @@ -528,6 +545,7 @@ public static function isIterable($value, $message = '') } /** + * @psalm-pure * @psalm-template ExpectedType of object * @psalm-param class-string $class * @psalm-assert ExpectedType $value @@ -550,6 +568,7 @@ public static function isInstanceOf($value, $class, $message = '') } /** + * @psalm-pure * @psalm-template ExpectedType of object * @psalm-param class-string $class * @psalm-assert !ExpectedType $value @@ -572,6 +591,8 @@ public static function notInstanceOf($value, $class, $message = '') } /** + * @psalm-pure + * * @param mixed $value * @param array $classes * @param string $message @@ -594,6 +615,7 @@ public static function isInstanceOfAny($value, array $classes, $message = '') } /** + * @psalm-pure * @psalm-assert empty $value * * @param mixed $value @@ -612,6 +634,7 @@ public static function isEmpty($value, $message = '') } /** + * @psalm-pure * @psalm-assert !empty $value * * @param mixed $value @@ -630,6 +653,7 @@ public static function notEmpty($value, $message = '') } /** + * @psalm-pure * @psalm-assert null $value * * @param mixed $value @@ -648,6 +672,7 @@ public static function null($value, $message = '') } /** + * @psalm-pure * @psalm-assert !null $value * * @param mixed $value @@ -665,6 +690,7 @@ public static function notNull($value, $message = '') } /** + * @psalm-pure * @psalm-assert true $value * * @param mixed $value @@ -683,6 +709,7 @@ public static function true($value, $message = '') } /** + * @psalm-pure * @psalm-assert false $value * * @param mixed $value @@ -775,6 +802,8 @@ public static function email($value, $message = '') /** * Does non strict comparisons on the items, so ['3', 3] will not pass the assertion. * + * @psalm-pure + * * @param array $values * @param string $message * @@ -797,6 +826,8 @@ public static function uniqueValues(array $values, $message = '') } /** + * @psalm-pure + * * @param mixed $value * @param mixed $expect * @param string $message @@ -815,6 +846,8 @@ public static function eq($value, $expect, $message = '') } /** + * @psalm-pure + * * @param mixed $value * @param mixed $expect * @param string $message @@ -832,6 +865,7 @@ public static function notEq($value, $expect, $message = '') } /** + * @psalm-pure * @psalm-template ExpectedType * @psalm-param ExpectedType $expect * @psalm-assert ExpectedType $value @@ -854,6 +888,8 @@ public static function same($value, $expect, $message = '') } /** + * @psalm-pure + * * @param mixed $value * @param mixed $expect * @param string $message @@ -871,6 +907,8 @@ public static function notSame($value, $expect, $message = '') } /** + * @psalm-pure + * * @param mixed $value * @param mixed $limit * @param string $message @@ -889,6 +927,8 @@ public static function greaterThan($value, $limit, $message = '') } /** + * @psalm-pure + * * @param mixed $value * @param mixed $limit * @param string $message @@ -907,6 +947,8 @@ public static function greaterThanEq($value, $limit, $message = '') } /** + * @psalm-pure + * * @param mixed $value * @param mixed $limit * @param string $message @@ -925,6 +967,8 @@ public static function lessThan($value, $limit, $message = '') } /** + * @psalm-pure + * * @param mixed $value * @param mixed $limit * @param string $message @@ -945,6 +989,8 @@ public static function lessThanEq($value, $limit, $message = '') /** * Inclusive range, so Assert::(3, 3, 5) passes. * + * @psalm-pure + * * @param mixed $value * @param mixed $min * @param mixed $max @@ -967,6 +1013,8 @@ public static function range($value, $min, $max, $message = '') /** * Does strict comparison, so Assert::oneOf(3, ['3']) does not pass the assertion. * + * @psalm-pure + * * @param mixed $value * @param array $values * @param string $message @@ -985,6 +1033,8 @@ public static function oneOf($value, array $values, $message = '') } /** + * @psalm-pure + * * @param string $value * @param string $subString * @param string $message @@ -1003,6 +1053,8 @@ public static function contains($value, $subString, $message = '') } /** + * @psalm-pure + * * @param string $value * @param string $subString * @param string $message @@ -1021,6 +1073,8 @@ public static function notContains($value, $subString, $message = '') } /** + * @psalm-pure + * * @param string $value * @param string $message * @@ -1037,6 +1091,8 @@ public static function notWhitespaceOnly($value, $message = '') } /** + * @psalm-pure + * * @param string $value * @param string $prefix * @param string $message @@ -1055,6 +1111,7 @@ public static function startsWith($value, $prefix, $message = '') } /** + * @psalm-pure * @psalm-assert string $value * @psalm-assert !empty $value * @@ -1085,6 +1142,8 @@ public static function startsWithLetter($value, $message = '') } /** + * @psalm-pure + * * @param string $value * @param string $suffix * @param string $message @@ -1103,6 +1162,8 @@ public static function endsWith($value, $suffix, $message = '') } /** + * @psalm-pure + * * @param string $value * @param string $pattern * @param string $message @@ -1120,6 +1181,8 @@ public static function regex($value, $pattern, $message = '') } /** + * @psalm-pure + * * @param string $value * @param string $pattern * @param string $message @@ -1139,6 +1202,7 @@ public static function notRegex($value, $pattern, $message = '') } /** + * @psalm-pure * @psalm-assert string $value * * @param mixed $value @@ -1159,6 +1223,7 @@ public static function unicodeLetters($value, $message = '') } /** + * @psalm-pure * @psalm-assert string $value * @psalm-assert !empty $value * @@ -1185,6 +1250,7 @@ public static function alpha($value, $message = '') } /** + * @psalm-pure * @psalm-assert !empty $value * * @param string|int $value can be an integer, since ctype_* functions accept ASCII integers -128 ~ +256 @@ -1208,6 +1274,7 @@ public static function digits($value, $message = '') } /** + * @psalm-pure * @psalm-assert !empty $value * * @param string|int $value can be an integer, since ctype_* functions accept ASCII integers -128 ~ +256 @@ -1231,6 +1298,7 @@ public static function alnum($value, $message = '') } /** + * @psalm-pure * @psalm-assert !empty $value * * @param string|int $value can be an integer, since ctype_* functions accept ASCII integers -128 ~ +256 @@ -1254,6 +1322,7 @@ public static function lower($value, $message = '') } /** + * @psalm-pure * @psalm-assert !empty $value * * @param string|int $value can be an integer, since ctype_* functions accept ASCII integers -128 ~ +256 @@ -1277,6 +1346,8 @@ public static function upper($value, $message = '') } /** + * @psalm-pure + * * @param string $value * @param int $length * @param string $message @@ -1297,6 +1368,8 @@ public static function length($value, $length, $message = '') /** * Inclusive min. * + * @psalm-pure + * * @param string $value * @param int $min * @param string $message @@ -1317,6 +1390,8 @@ public static function minLength($value, $min, $message = '') /** * Inclusive max. * + * @psalm-pure + * * @param string $value * @param int $max * @param string $message @@ -1337,6 +1412,8 @@ public static function maxLength($value, $max, $message = '') /** * Inclusive , so Assert::lengthBetween('asd', 3, 5); passes the assertion. * + * @psalm-pure + * * @param string $value * @param int $min * @param int $max @@ -1457,6 +1534,7 @@ public static function writable($value, $message = '') } /** + * @psalm-pure * @psalm-assert class-string $value * * @param mixed $value @@ -1475,6 +1553,7 @@ public static function classExists($value, $message = '') } /** + * @psalm-pure * @psalm-template ExpectedType of object * @psalm-param class-string $class * @psalm-assert class-string $value @@ -1497,6 +1576,7 @@ public static function subclassOf($value, $class, $message = '') } /** + * @psalm-pure * @psalm-assert class-string $value * * @param mixed $value @@ -1515,6 +1595,7 @@ public static function interfaceExists($value, $message = '') } /** + * @psalm-pure * @psalm-template ExpectedType of object * @psalm-param class-string $interface * @psalm-assert class-string $value @@ -1537,6 +1618,8 @@ public static function implementsInterface($value, $interface, $message = '') } /** + * @psalm-pure + * * @param string|object $classOrObject * @param mixed $property * @param string $message @@ -1554,6 +1637,8 @@ public static function propertyExists($classOrObject, $property, $message = '') } /** + * @psalm-pure + * * @param string|object $classOrObject * @param mixed $property * @param string $message @@ -1571,6 +1656,8 @@ public static function propertyNotExists($classOrObject, $property, $message = ' } /** + * @psalm-pure + * * @param string|object $classOrObject * @param mixed $method * @param string $message @@ -1588,6 +1675,8 @@ public static function methodExists($classOrObject, $method, $message = '') } /** + * @psalm-pure + * * @param string|object $classOrObject * @param mixed $method * @param string $message @@ -1605,6 +1694,8 @@ public static function methodNotExists($classOrObject, $method, $message = '') } /** + * @psalm-pure + * * @param array $array * @param string|int $key * @param string $message @@ -1622,6 +1713,8 @@ public static function keyExists($array, $key, $message = '') } /** + * @psalm-pure + * * @param array $array * @param string|int $key * @param string $message @@ -1641,6 +1734,7 @@ public static function keyNotExists($array, $key, $message = '') /** * Checks if a value is a valid array key (int or string). * + * @psalm-pure * @psalm-assert array-key $value * * @param mixed $value @@ -1741,6 +1835,7 @@ public static function countBetween($array, $min, $max, $message = '') } /** + * @psalm-pure * @psalm-assert list $array * * @param mixed $array @@ -1758,6 +1853,7 @@ public static function isList($array, $message = '') } /** + * @psalm-pure * @psalm-assert list $array * @psalm-assert !empty $array * @@ -1773,6 +1869,7 @@ public static function isNonEmptyList($array, $message = '') } /** + * @psalm-pure * @psalm-template T * @psalm-param mixed|array $array * @psalm-assert array $array @@ -1795,6 +1892,7 @@ public static function isMap($array, $message = '') } /** + * @psalm-pure * @psalm-template T * @psalm-param mixed|array $array * @psalm-assert array $array @@ -1812,6 +1910,7 @@ public static function isNonEmptyMap($array, $message = '') } /** + * @psalm-pure * @psalm-assert !empty $value * * @param string $value diff --git a/tests/static-analysis/assert-alpha.php b/tests/static-analysis/assert-alpha.php index 9bb908e5..0dfea503 100644 --- a/tests/static-analysis/assert-alpha.php +++ b/tests/static-analysis/assert-alpha.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): string @@ -14,6 +15,9 @@ function consume($value): string return $value; } +/** + * @psalm-pure + */ function consumeNullableString(?string $value): string { Assert::alpha($value); diff --git a/tests/static-analysis/assert-boolean.php b/tests/static-analysis/assert-boolean.php index 0ccbeaba..f1fdf2ac 100644 --- a/tests/static-analysis/assert-boolean.php +++ b/tests/static-analysis/assert-boolean.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): bool diff --git a/tests/static-analysis/assert-classExists.php b/tests/static-analysis/assert-classExists.php index 8d2dd918..f18e1b57 100644 --- a/tests/static-analysis/assert-classExists.php +++ b/tests/static-analysis/assert-classExists.php @@ -6,6 +6,7 @@ /** + * @psalm-pure * @param mixed $value * * @return string diff --git a/tests/static-analysis/assert-false.php b/tests/static-analysis/assert-false.php index 731e4cb2..b637ccae 100644 --- a/tests/static-analysis/assert-false.php +++ b/tests/static-analysis/assert-false.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @param mixed $value */ function consume($value): bool diff --git a/tests/static-analysis/assert-float.php b/tests/static-analysis/assert-float.php index 0e9f46b4..fe94fe6e 100644 --- a/tests/static-analysis/assert-float.php +++ b/tests/static-analysis/assert-float.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): float diff --git a/tests/static-analysis/assert-implementsInterface.php b/tests/static-analysis/assert-implementsInterface.php index b9dede70..84fe7208 100644 --- a/tests/static-analysis/assert-implementsInterface.php +++ b/tests/static-analysis/assert-implementsInterface.php @@ -19,6 +19,8 @@ interface ImplementsInterfaceC /** * @param mixed $value * + * @psalm-pure + * * @psalm-return class-string $value */ function consumeMixed($value): string @@ -29,6 +31,8 @@ function consumeMixed($value): string } /** + * @psalm-pure + * * @psalm-param class-string|class-string $value * * @psalm-return class-string $value diff --git a/tests/static-analysis/assert-integer.php b/tests/static-analysis/assert-integer.php index 4f9969be..b5b12052 100644 --- a/tests/static-analysis/assert-integer.php +++ b/tests/static-analysis/assert-integer.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): int diff --git a/tests/static-analysis/assert-integerish.php b/tests/static-analysis/assert-integerish.php index 067c6eb7..9151c047 100644 --- a/tests/static-analysis/assert-integerish.php +++ b/tests/static-analysis/assert-integerish.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param string|numeric $value * * @psalm-return numeric diff --git a/tests/static-analysis/assert-interfaceExists.php b/tests/static-analysis/assert-interfaceExists.php index f30cff21..2552aba6 100644 --- a/tests/static-analysis/assert-interfaceExists.php +++ b/tests/static-analysis/assert-interfaceExists.php @@ -9,6 +9,8 @@ * @param mixed $value * * @return string + * + * @psalm-pure * @psalm-return class-string */ function consume($value): string diff --git a/tests/static-analysis/assert-isArray.php b/tests/static-analysis/assert-isArray.php index 0f0d2d0e..53e2c8dc 100644 --- a/tests/static-analysis/assert-isArray.php +++ b/tests/static-analysis/assert-isArray.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): array diff --git a/tests/static-analysis/assert-isArrayAccessible.php b/tests/static-analysis/assert-isArrayAccessible.php index ea1868ae..f45624f2 100644 --- a/tests/static-analysis/assert-isArrayAccessible.php +++ b/tests/static-analysis/assert-isArrayAccessible.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value * * @return array|\ArrayAccess diff --git a/tests/static-analysis/assert-isCallable.php b/tests/static-analysis/assert-isCallable.php index a0371d14..c3f08672 100644 --- a/tests/static-analysis/assert-isCallable.php +++ b/tests/static-analysis/assert-isCallable.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): callable diff --git a/tests/static-analysis/assert-isCountable.php b/tests/static-analysis/assert-isCountable.php index 232ea0a1..9e71226b 100644 --- a/tests/static-analysis/assert-isCountable.php +++ b/tests/static-analysis/assert-isCountable.php @@ -6,6 +6,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param object $value */ function consume($value): Countable diff --git a/tests/static-analysis/assert-isEmpty.php b/tests/static-analysis/assert-isEmpty.php index 2b52b240..ff98e0ef 100644 --- a/tests/static-analysis/assert-isEmpty.php +++ b/tests/static-analysis/assert-isEmpty.php @@ -6,7 +6,8 @@ /** - + * @psalm-pure + * * @return null */ function consume(?object $value) diff --git a/tests/static-analysis/assert-isInstanceOf.php b/tests/static-analysis/assert-isInstanceOf.php index 83f11c01..ee7613d5 100644 --- a/tests/static-analysis/assert-isInstanceOf.php +++ b/tests/static-analysis/assert-isInstanceOf.php @@ -6,6 +6,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @param mixed $value */ function consume($value) : stdClass diff --git a/tests/static-analysis/assert-isIterable.php b/tests/static-analysis/assert-isIterable.php index dfdb4ed1..bf2ddd5a 100644 --- a/tests/static-analysis/assert-isIterable.php +++ b/tests/static-analysis/assert-isIterable.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): iterable diff --git a/tests/static-analysis/assert-isList.php b/tests/static-analysis/assert-isList.php index 64111868..88e704ff 100644 --- a/tests/static-analysis/assert-isList.php +++ b/tests/static-analysis/assert-isList.php @@ -5,6 +5,8 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure + * * @psalm-param mixed $value * * @psalm-return list @@ -17,6 +19,8 @@ function consume($value): array } /** + * @psalm-pure + * * @psalm-param array<\stdClass> $value * * @psalm-return list<\stdClass> diff --git a/tests/static-analysis/assert-isMap.php b/tests/static-analysis/assert-isMap.php index cf869648..6a8ec78d 100644 --- a/tests/static-analysis/assert-isMap.php +++ b/tests/static-analysis/assert-isMap.php @@ -5,6 +5,8 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure + * * @param mixed $value * * @return array @@ -19,6 +21,8 @@ function consume($value): array /** * Verifying that the type of the elements in the array is preserved by the assertion * + * @psalm-pure + * * @param array $value * * @return array diff --git a/tests/static-analysis/assert-isNonEmptyList.php b/tests/static-analysis/assert-isNonEmptyList.php index 1e8d31b5..9435386f 100644 --- a/tests/static-analysis/assert-isNonEmptyList.php +++ b/tests/static-analysis/assert-isNonEmptyList.php @@ -5,6 +5,8 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure + * * @psalm-param mixed $value * * @psalm-return non-empty-list diff --git a/tests/static-analysis/assert-isNonEmptyMap.php b/tests/static-analysis/assert-isNonEmptyMap.php index e7d825f3..5178e75e 100644 --- a/tests/static-analysis/assert-isNonEmptyMap.php +++ b/tests/static-analysis/assert-isNonEmptyMap.php @@ -5,6 +5,8 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure + * * @param mixed $value * * @return array @@ -19,6 +21,8 @@ function consume($value): array /** * Verifying that the type of the elements in the array is preserved by the assertion * + * @psalm-pure + * * @param array $value * * @return array diff --git a/tests/static-analysis/assert-isTraversable.php b/tests/static-analysis/assert-isTraversable.php index 81e20178..9b31d863 100644 --- a/tests/static-analysis/assert-isTraversable.php +++ b/tests/static-analysis/assert-isTraversable.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): iterable diff --git a/tests/static-analysis/assert-natural.php b/tests/static-analysis/assert-natural.php index a6771272..9c345478 100644 --- a/tests/static-analysis/assert-natural.php +++ b/tests/static-analysis/assert-natural.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): int diff --git a/tests/static-analysis/assert-notEmpty.php b/tests/static-analysis/assert-notEmpty.php index 27b981af..d31c0d5f 100644 --- a/tests/static-analysis/assert-notEmpty.php +++ b/tests/static-analysis/assert-notEmpty.php @@ -4,6 +4,9 @@ use Webmozart\Assert\Assert; +/** + * @psalm-pure + */ function consume(?object $value): object { Assert::notEmpty($value); diff --git a/tests/static-analysis/assert-notInstanceOf.php b/tests/static-analysis/assert-notInstanceOf.php index eecf6e2e..c9ddb9c9 100644 --- a/tests/static-analysis/assert-notInstanceOf.php +++ b/tests/static-analysis/assert-notInstanceOf.php @@ -8,6 +8,7 @@ class NotA {} class NotB {} /** + * @psalm-pure * @param NotA|NotB $value */ function consume($value): NotA diff --git a/tests/static-analysis/assert-notNull.php b/tests/static-analysis/assert-notNull.php index d79c99d3..8da5d550 100644 --- a/tests/static-analysis/assert-notNull.php +++ b/tests/static-analysis/assert-notNull.php @@ -4,6 +4,9 @@ use Webmozart\Assert\Assert; +/** + * @psalm-pure + */ function consume(?object $value): object { Assert::notNull($value); diff --git a/tests/static-analysis/assert-null.php b/tests/static-analysis/assert-null.php index 81e2ffe8..79fae0a0 100644 --- a/tests/static-analysis/assert-null.php +++ b/tests/static-analysis/assert-null.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @return null */ function consume(?object $value) diff --git a/tests/static-analysis/assert-numeric.php b/tests/static-analysis/assert-numeric.php index d1cf9149..ef2892d4 100644 --- a/tests/static-analysis/assert-numeric.php +++ b/tests/static-analysis/assert-numeric.php @@ -5,7 +5,8 @@ use Webmozart\Assert\Assert; /** - * @psalm-param string|numeric $value + * @psalm-pure + * @psalm-param mixed $value * * @psalm-return numeric */ diff --git a/tests/static-analysis/assert-object.php b/tests/static-analysis/assert-object.php index a9afbb18..e2a037f6 100644 --- a/tests/static-analysis/assert-object.php +++ b/tests/static-analysis/assert-object.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): object diff --git a/tests/static-analysis/assert-resource.php b/tests/static-analysis/assert-resource.php index 43c707e9..81338afc 100644 --- a/tests/static-analysis/assert-resource.php +++ b/tests/static-analysis/assert-resource.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value * * @return resource diff --git a/tests/static-analysis/assert-same.php b/tests/static-analysis/assert-same.php index 008aa785..9ccb3e43 100644 --- a/tests/static-analysis/assert-same.php +++ b/tests/static-analysis/assert-same.php @@ -6,6 +6,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): string @@ -16,6 +17,7 @@ function consume($value): string } /** + * @psalm-pure * @psalm-param mixed $value */ function consumeWillInferObject($value): stdClass @@ -26,6 +28,7 @@ function consumeWillInferObject($value): stdClass } /** + * @psalm-pure * @psalm-param mixed $value */ function consumeWillInferArray($value): array diff --git a/tests/static-analysis/assert-scalar.php b/tests/static-analysis/assert-scalar.php index 4f86accf..dfd69e54 100644 --- a/tests/static-analysis/assert-scalar.php +++ b/tests/static-analysis/assert-scalar.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param \Exception|bool $value */ function consume($value): bool diff --git a/tests/static-analysis/assert-startsWithLetter.php b/tests/static-analysis/assert-startsWithLetter.php index 5cc34df1..27dc9368 100644 --- a/tests/static-analysis/assert-startsWithLetter.php +++ b/tests/static-analysis/assert-startsWithLetter.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): string diff --git a/tests/static-analysis/assert-string.php b/tests/static-analysis/assert-string.php index 2fcde90d..3a4f3a2f 100644 --- a/tests/static-analysis/assert-string.php +++ b/tests/static-analysis/assert-string.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): string diff --git a/tests/static-analysis/assert-stringNotEmpty.php b/tests/static-analysis/assert-stringNotEmpty.php index 80e75109..804fd0bc 100644 --- a/tests/static-analysis/assert-stringNotEmpty.php +++ b/tests/static-analysis/assert-stringNotEmpty.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): string diff --git a/tests/static-analysis/assert-subclassOf.php b/tests/static-analysis/assert-subclassOf.php index d4f0ae11..eea6896f 100644 --- a/tests/static-analysis/assert-subclassOf.php +++ b/tests/static-analysis/assert-subclassOf.php @@ -19,6 +19,7 @@ class SubclassOfC /** * @param mixed $value * + * @psalm-pure * @psalm-return class-string $value */ function consumeMixed($value): string @@ -29,6 +30,7 @@ function consumeMixed($value): string } /** + * @psalm-pure * @psalm-param class-string|class-string $value * * @psalm-return class-string $value diff --git a/tests/static-analysis/assert-true.php b/tests/static-analysis/assert-true.php index 49999375..ada3d70b 100644 --- a/tests/static-analysis/assert-true.php +++ b/tests/static-analysis/assert-true.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @param mixed $value */ function consume($value): bool diff --git a/tests/static-analysis/assert-unicodeLetters.php b/tests/static-analysis/assert-unicodeLetters.php index 16d857b1..ea6d2595 100644 --- a/tests/static-analysis/assert-unicodeLetters.php +++ b/tests/static-analysis/assert-unicodeLetters.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value */ function consume($value): string diff --git a/tests/static-analysis/assert-validArrayKey.php b/tests/static-analysis/assert-validArrayKey.php index b9fcf1d6..07691c2e 100644 --- a/tests/static-analysis/assert-validArrayKey.php +++ b/tests/static-analysis/assert-validArrayKey.php @@ -5,6 +5,7 @@ use Webmozart\Assert\Assert; /** + * @psalm-pure * @psalm-param mixed $value * @param array $array *