| @@ 438-446 (lines=9) @@ | ||
| 435 | * @param mixed $value |
|
| 436 | * @param string $message |
|
| 437 | */ |
|
| 438 | public static function isArrayAccessible($value, $message = '') |
|
| 439 | { |
|
| 440 | if (!\is_array($value) && !($value instanceof ArrayAccess)) { |
|
| 441 | static::reportInvalidArgument(\sprintf( |
|
| 442 | $message ?: 'Expected an array accessible. Got: %s', |
|
| 443 | static::typeToString($value) |
|
| 444 | )); |
|
| 445 | } |
|
| 446 | } |
|
| 447 | ||
| 448 | /** |
|
| 449 | * @psalm-assert countable $value |
|
| @@ 454-462 (lines=9) @@ | ||
| 451 | * @param mixed $value |
|
| 452 | * @param string $message |
|
| 453 | */ |
|
| 454 | public static function isCountable($value, $message = '') |
|
| 455 | { |
|
| 456 | if (!\is_array($value) && !($value instanceof Countable)) { |
|
| 457 | static::reportInvalidArgument(\sprintf( |
|
| 458 | $message ?: 'Expected a countable. Got: %s', |
|
| 459 | static::typeToString($value) |
|
| 460 | )); |
|
| 461 | } |
|
| 462 | } |
|
| 463 | ||
| 464 | /** |
|
| 465 | * @psalm-assert iterable $value |
|
| @@ 470-478 (lines=9) @@ | ||
| 467 | * @param mixed $value |
|
| 468 | * @param string $message |
|
| 469 | */ |
|
| 470 | public static function isIterable($value, $message = '') |
|
| 471 | { |
|
| 472 | if (!\is_array($value) && !($value instanceof Traversable)) { |
|
| 473 | static::reportInvalidArgument(\sprintf( |
|
| 474 | $message ?: 'Expected an iterable. Got: %s', |
|
| 475 | static::typeToString($value) |
|
| 476 | )); |
|
| 477 | } |
|
| 478 | } |
|
| 479 | ||
| 480 | /** |
|
| 481 | * @psalm-template ExpectedType of object |
|