1: <?php declare(strict_types=1);
2:
3: namespace Salient\Utility\Exception;
4:
5: use Salient\Utility\Get;
6: use InvalidArgumentException;
7:
8: /**
9: * @api
10: */
11: class InvalidArgumentTypeException extends InvalidArgumentException
12: {
13: /**
14: * @api
15: *
16: * @param int<1,max> $number Argument number (1-based).
17: * @param string $name Argument name (leading `'$'` removed if present).
18: * @param string $type Expected type, e.g. `"string[]|null"`.
19: * @param mixed $value Value given.
20: */
21: public function __construct(int $number, string $name, string $type, $value)
22: {
23: parent::__construct(sprintf(
24: 'Argument #%d ($%s) must be of type %s, %s given',
25: $number,
26: ltrim($name, '$'),
27: $type,
28: Get::type($value),
29: ));
30: }
31: }
32: