Create a new invalid argument exception with a standardized text.
Parameters
$position
intrequired- The argument position in the function signature. 1-based.
$name
stringrequired- The argument name in the function signature.
$expected
stringrequired- The argument type expected as a string.
$received
stringrequired- The actual argument type received.
Source
public static function create($position, $name, $expected, $received) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
return new self(
sprintf(
'%s::%s(): Argument #%d (%s) must be of type %s, %s given',
$stack[1]['class'],
$stack[1]['function'],
$position,
$name,
$expected,
$received
)
);
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.