Skip to content

Commit

Permalink
ctype_*() functions can operate with integer ranges -128~256 too
Browse files Browse the repository at this point in the history
These are extremely fucky interfaces, but PHP is a shitty language anyway.

We need to support an input of `string|int` when validating for the
`ctype_*()` of an input, but at least we can assert for the value to
not be `empty()` when it passes such validation.

Ref: vimeo/psalm#2452
  • Loading branch information
Ocramius committed Dec 10, 2019
1 parent e8473e4 commit 4e28a31
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ public static function startsWith($value, $prefix, $message = '')

/**
* @psalm-assert string $value
* @psalm-assert !empty $value
*
* @param mixed $value
* @param string $message
Expand Down Expand Up @@ -1163,6 +1164,7 @@ public static function unicodeLetters($value, $message = '')

/**
* @psalm-assert string $value
* @psalm-assert !empty $value
*
* @param mixed $value
* @param string $message
Expand All @@ -1189,8 +1191,8 @@ public static function alpha($value, $message = '')
/**
* @psalm-assert !empty $value
*
* @param string $value
* @param string $message
* @param string|int $value can be an integer, since ctype_* functions accept ASCII integers -128 ~ +256
* @param string $message
*
* @throws InvalidArgumentException
*/
Expand All @@ -1212,8 +1214,8 @@ public static function digits($value, $message = '')
/**
* @psalm-assert !empty $value
*
* @param string $value
* @param string $message
* @param string|int $value can be an integer, since ctype_* functions accept ASCII integers -128 ~ +256
* @param string $message
*
* @throws InvalidArgumentException
*/
Expand All @@ -1235,8 +1237,8 @@ public static function alnum($value, $message = '')
/**
* @psalm-assert !empty $value
*
* @param string $value
* @param string $message
* @param string|int $value can be an integer, since ctype_* functions accept ASCII integers -128 ~ +256
* @param string $message
*
* @throws InvalidArgumentException
*/
Expand All @@ -1258,8 +1260,8 @@ public static function lower($value, $message = '')
/**
* @psalm-assert !empty $value
*
* @param string $value
* @param string $message
* @param string|int $value can be an integer, since ctype_* functions accept ASCII integers -128 ~ +256
* @param string $message
*
* @throws InvalidArgumentException
*/
Expand Down

0 comments on commit 4e28a31

Please sign in to comment.