InvalidArgument::create( int $position, string $name, string $expected, string $received ): WpOrgRequestsExceptionInvalidArgument

In this article

Create a new invalid argument exception with a standardized text.

Parameters

$positionintrequired
The argument position in the function signature. 1-based.
$namestringrequired
The argument name in the function signature.
$expectedstringrequired
The argument type expected as a string.
$receivedstringrequired
The actual argument type received.

Return

WpOrgRequestsExceptionInvalidArgument

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.