Skip to content

Commit 2dd88a6

Browse files
committed
refactor: [BC] do not use ValidationInterface
1 parent da5470e commit 2dd88a6

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

system/BaseModel.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use CodeIgniter\I18n\Time;
2121
use CodeIgniter\Pager\Pager;
2222
use CodeIgniter\Validation\Validation;
23-
use CodeIgniter\Validation\ValidationInterface;
2423
use Config\Services;
2524
use InvalidArgumentException;
2625
use ReflectionClass;
@@ -319,7 +318,7 @@ abstract class BaseModel
319318
*/
320319
protected bool $allowEmptyInserts = false;
321320

322-
public function __construct(?ValidationInterface $validation = null)
321+
public function __construct(?Validation $validation = null)
323322
{
324323
$this->tempReturnType = $this->returnType;
325324
$this->tempUseSoftDeletes = $this->useSoftDeletes;

system/Model.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use CodeIgniter\Database\Query;
2323
use CodeIgniter\Exceptions\ModelException;
2424
use CodeIgniter\I18n\Time;
25-
use CodeIgniter\Validation\ValidationInterface;
25+
use CodeIgniter\Validation\Validation;
2626
use Config\Database;
2727
use ReflectionClass;
2828
use ReflectionException;
@@ -128,7 +128,7 @@ class Model extends BaseModel
128128
'getCompiledUpdate',
129129
];
130130

131-
public function __construct(?ConnectionInterface $db = null, ?ValidationInterface $validation = null)
131+
public function __construct(?ConnectionInterface $db = null, ?Validation $validation = null)
132132
{
133133
/**
134134
* @var BaseConnection|null $db

system/Validation/Validation.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/**
2323
* Validator
2424
*/
25-
class Validation implements ValidationInterface
25+
class Validation
2626
{
2727
/**
2828
* Files to load with validation functions.
@@ -344,8 +344,10 @@ protected function processRules(string $field, ?string $label, $value, $rules =
344344
/**
345345
* Takes a Request object and grabs the input data to use from its
346346
* array values.
347+
*
348+
* @return $this
347349
*/
348-
public function withRequest(RequestInterface $request): ValidationInterface
350+
public function withRequest(RequestInterface $request)
349351
{
350352
/** @var IncomingRequest $request */
351353
if (strpos($request->getHeaderLine('Content-Type'), 'application/json') !== false) {
@@ -421,8 +423,10 @@ public function setRule(string $field, ?string $label, $rules, array $errors = [
421423
* ]
422424
*
423425
* @param array $errors // An array of custom error messages
426+
*
427+
* @return $this
424428
*/
425-
public function setRules(array $rules, array $errors = []): ValidationInterface
429+
public function setRules(array $rules, array $errors = [])
426430
{
427431
$this->customErrors = $errors;
428432

@@ -691,8 +695,10 @@ public function getErrors(): array
691695

692696
/**
693697
* Sets the error for a specific field. Used by custom validation methods.
698+
*
699+
* @return $this
694700
*/
695-
public function setError(string $field, string $error): ValidationInterface
701+
public function setError(string $field, string $error)
696702
{
697703
$this->errors[$field] = $error;
698704

@@ -772,8 +778,10 @@ protected function splitRules(string $rules): array
772778
/**
773779
* Resets the class to a blank slate. Should be called whenever
774780
* you need to process more than one array.
781+
*
782+
* @return $this
775783
*/
776-
public function reset(): ValidationInterface
784+
public function reset()
777785
{
778786
$this->data = [];
779787
$this->rules = [];

0 commit comments

Comments
 (0)