Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions system/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use CodeIgniter\I18n\Time;
use CodeIgniter\Pager\Pager;
use CodeIgniter\Validation\Validation;
use CodeIgniter\Validation\ValidationInterface;
use Config\Services;
use InvalidArgumentException;
use ReflectionClass;
Expand Down Expand Up @@ -319,7 +318,7 @@ abstract class BaseModel
*/
protected bool $allowEmptyInserts = false;

public function __construct(?ValidationInterface $validation = null)
public function __construct(?Validation $validation = null)
{
$this->tempReturnType = $this->returnType;
$this->tempUseSoftDeletes = $this->useSoftDeletes;
Expand Down
4 changes: 2 additions & 2 deletions system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use CodeIgniter\Database\Query;
use CodeIgniter\Exceptions\ModelException;
use CodeIgniter\I18n\Time;
use CodeIgniter\Validation\ValidationInterface;
use CodeIgniter\Validation\Validation;
use Config\Database;
use ReflectionClass;
use ReflectionException;
Expand Down Expand Up @@ -128,7 +128,7 @@ class Model extends BaseModel
'getCompiledUpdate',
];

public function __construct(?ConnectionInterface $db = null, ?ValidationInterface $validation = null)
public function __construct(?ConnectionInterface $db = null, ?Validation $validation = null)
{
/**
* @var BaseConnection|null $db
Expand Down
18 changes: 13 additions & 5 deletions system/Validation/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Validator
*/
class Validation implements ValidationInterface
class Validation
{
/**
* Files to load with validation functions.
Expand Down Expand Up @@ -344,8 +344,10 @@ protected function processRules(string $field, ?string $label, $value, $rules =
/**
* Takes a Request object and grabs the input data to use from its
* array values.
*
* @return $this
*/
public function withRequest(RequestInterface $request): ValidationInterface
public function withRequest(RequestInterface $request)
{
/** @var IncomingRequest $request */
if (strpos($request->getHeaderLine('Content-Type'), 'application/json') !== false) {
Expand Down Expand Up @@ -421,8 +423,10 @@ public function setRule(string $field, ?string $label, $rules, array $errors = [
* ]
*
* @param array $errors // An array of custom error messages
*
* @return $this
*/
public function setRules(array $rules, array $errors = []): ValidationInterface
public function setRules(array $rules, array $errors = [])
{
$this->customErrors = $errors;

Expand Down Expand Up @@ -691,8 +695,10 @@ public function getErrors(): array

/**
* Sets the error for a specific field. Used by custom validation methods.
*
* @return $this
*/
public function setError(string $field, string $error): ValidationInterface
public function setError(string $field, string $error)
{
$this->errors[$field] = $error;

Expand Down Expand Up @@ -772,8 +778,10 @@ protected function splitRules(string $rules): array
/**
* Resets the class to a blank slate. Should be called whenever
* you need to process more than one array.
*
* @return $this
*/
public function reset(): ValidationInterface
public function reset()
{
$this->data = [];
$this->rules = [];
Expand Down