ArgumentCount
- Since
- 2.0.0
- Source
wp-includes/Requests/src/Exception/ArgumentCount.php:20
Exception for when an incorrect number of arguments are passed to a method.
Description
Typically, this exception is used when all arguments for a method are optional, but certain arguments need to be passed together, i.e. a method which can be called with no arguments or with two arguments, but not with one argument.
Along the same lines, this exception is also used if a method expects an array with a certain number of elements and the provided number of elements does not comply.
Compatibility
- WordPress
- since 2.0.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Methods · 1
- create()Create a new argument count exception with a standardized text.
Source code
final class ArgumentCount extends Exception { /** * Create a new argument count exception with a standardized text. * * @param string $expected The argument count expected as a phrase. * For example: `at least 2 arguments` or `exactly 1 argument`. * @param int $received The actual argument count received. * @param string $type Exception type. * * @return \WpOrg\Requests\Exception\ArgumentCount */ 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 ); }}Changelog
Introduced in 2.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/Requests/src/Exception/ArgumentCount.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.