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