CoreFiles by mySites.guru
InvalidArgument.php41 lines, 1,106 bytes, from wordpress-6.7.7.zip
Raw History Compare with 6.7.6
md5
be0bb752251cba0fe639482619469992
sha1
51d516025dbd23886310bfecc7b1c55fdd9c6bfa
sha256
e07fece0cd8cb70aaacb9f6aea251041cd5706a711122bf947c24242d780da3b
<?php

namespace WpOrg\Requests\Exception;

use InvalidArgumentException;

/**
 * Exception for an invalid argument passed.
 *
 * @package Requests\Exceptions
 * @since   2.0.0
 */
final class InvalidArgument extends InvalidArgumentException {

	/**
	 * Create a new invalid argument exception with a standardized text.
	 *
	 * @param int    $position The argument position in the function signature. 1-based.
	 * @param string $name     The argument name in the function signature.
	 * @param string $expected The argument type expected as a string.
	 * @param string $received The actual argument type received.
	 *
	 * @return \WpOrg\Requests\Exception\InvalidArgument
	 */
	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
			)
		);
	}
}

The same content is in 229 releases, WordPress 6.2-beta1 to 7.2-beta5. See them all, or every version of this file.