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

Create a new invalid argument exception with a standardized text.


Parameters

$position

(Required) The argument position in the function signature. 1-based.

$name

(Required) The argument name in the function signature.

$expected

(Required) The argument type expected as a string.

$received

(Required) The actual argument type received.


Return

(WpOrgRequestsExceptionInvalidArgument)


Source

File: wp-includes/Requests/src/Exception/InvalidArgument.php

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