Create a new argument count exception with a standardized text.
Parameters
$expected
stringrequired- The argument count expected as a phrase.
For example:at least 2 arguments
orexactly 1 argument
. $received
intrequired- The actual argument count received.
$type
stringrequired- Exception type.
Source
public static function create($expected, $received, $type) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
return new self(
sprintf(
'%s::%s() expects %s, %d given',
$stack[1]['class'],
$stack[1]['function'],
$expected,
$received
),
$type
);
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.