Edit File by line
/home/zeestwma/richards.../wp-inclu.../Requests/src/Exceptio...
File: ArgumentCount.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace WpOrg\Requests\Exception;
[2] Fix | Delete
[3] Fix | Delete
use WpOrg\Requests\Exception;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Exception for when an incorrect number of arguments are passed to a method.
[7] Fix | Delete
*
[8] Fix | Delete
* Typically, this exception is used when all arguments for a method are optional,
[9] Fix | Delete
* but certain arguments need to be passed together, i.e. a method which can be called
[10] Fix | Delete
* with no arguments or with two arguments, but not with one argument.
[11] Fix | Delete
*
[12] Fix | Delete
* Along the same lines, this exception is also used if a method expects an array
[13] Fix | Delete
* with a certain number of elements and the provided number of elements does not comply.
[14] Fix | Delete
*
[15] Fix | Delete
* @package Requests\Exceptions
[16] Fix | Delete
* @since 2.0.0
[17] Fix | Delete
*/
[18] Fix | Delete
final class ArgumentCount extends Exception {
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Create a new argument count exception with a standardized text.
[22] Fix | Delete
*
[23] Fix | Delete
* @param string $expected The argument count expected as a phrase.
[24] Fix | Delete
* For example: `at least 2 arguments` or `exactly 1 argument`.
[25] Fix | Delete
* @param int $received The actual argument count received.
[26] Fix | Delete
* @param string $type Exception type.
[27] Fix | Delete
*
[28] Fix | Delete
* @return \WpOrg\Requests\Exception\ArgumentCount
[29] Fix | Delete
*/
[30] Fix | Delete
public static function create($expected, $received, $type) {
[31] Fix | Delete
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
[32] Fix | Delete
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
[33] Fix | Delete
[34] Fix | Delete
return new self(
[35] Fix | Delete
sprintf(
[36] Fix | Delete
'%s::%s() expects %s, %d given',
[37] Fix | Delete
$stack[1]['class'],
[38] Fix | Delete
$stack[1]['function'],
[39] Fix | Delete
$expected,
[40] Fix | Delete
$received
[41] Fix | Delete
),
[42] Fix | Delete
$type
[43] Fix | Delete
);
[44] Fix | Delete
}
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function