fix: replace \TypeError with InvalidArgumentException

This commit is contained in:
kenjis 2024-01-27 22:43:09 +09:00
parent 3a35769b19
commit d33d3c7fd6
No known key found for this signature in database
GPG Key ID: BD254878922AF198

View File

@ -25,7 +25,6 @@ use CodeIgniter\Validation\Exceptions\ValidationException;
use CodeIgniter\View\RendererInterface; use CodeIgniter\View\RendererInterface;
use Config\Services; use Config\Services;
use Config\Validation as ValidationConfig; use Config\Validation as ValidationConfig;
use TypeError;
/** /**
* Validator * Validator
@ -540,12 +539,12 @@ class Validation implements ValidationInterface
* *
* @return $this * @return $this
* *
* @throws TypeError * @throws InvalidArgumentException
*/ */
public function setRule(string $field, ?string $label, $rules, array $errors = []) public function setRule(string $field, ?string $label, $rules, array $errors = [])
{ {
if (! is_array($rules) && ! is_string($rules)) { if (! is_array($rules) && ! is_string($rules)) {
throw new TypeError('$rules must be of type string|array'); throw new InvalidArgumentException('$rules must be of type string|array');
} }
$ruleSet = [ $ruleSet = [