W3cubDocs

/WordPress

ArgumentCount::create( string $expected, int $received, string $type ): WpOrgRequestsExceptionArgumentCount

Create a new argument count exception with a standardized text.

Parameters

$expectedstringrequired
The argument count expected as a phrase.
For example: at least 2 arguments or exactly 1 argument.
$receivedintrequired
The actual argument count received.
$typestringrequired
Exception type.

Return

WpOrgRequestsExceptionArgumentCount

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
	);
}

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wporg-requests-exception-argumentcount/create