Skip to content

Commit

Permalink
Merge pull request #94 from niden/master
Browse files Browse the repository at this point in the history
5.4.0 Release
  • Loading branch information
niden authored Oct 25, 2023
2 parents ec3c12f + 2516757 commit 7e4560a
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 174 deletions.
6 changes: 3 additions & 3 deletions src/DataMapper/Query/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ public function appendJoin(string $condition, $value = null, int $type = -1): Se
}

/**
* The columns to select from. If a key is set in an array element, the
* The columns to select from. If a key is set in the array element, the
* key will be used as the alias
*
* @param string ...$column
* @param array $columns
*
* @return Select
*/
public function columns(): Select
public function columns(array $columns): Select
{
}

Expand Down
111 changes: 65 additions & 46 deletions src/Filter/Validation/AbstractValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*/
namespace Phalcon\Filter\Validation;

use Phalcon\Support\Helper\Arr\Whitelist;
use Phalcon\Messages\Message;
use Phalcon\Filter\Validation;
use Phalcon\Support\Helper\Arr\Whitelist;

/**
* This is a base class for validators
Expand Down Expand Up @@ -46,12 +46,25 @@ public function __construct(array $options = [])
{
}

/**
* Returns an option in the validator's options
* Returns null if the option hasn't set
*
* @param string $key
* @param mixed|null $defaultValue
*
* @return mixed
*/
public function getOption(string $key, $defaultValue = null)
{
}

/**
* Get the template message
*
* @param string|null $field
*
* @return string
* @throw InvalidArgumentException When the field does not exists
* @param string $field
*/
public function getTemplate(string $field = null): string
{
Expand All @@ -67,110 +80,116 @@ public function getTemplates(): array
}

/**
* Clear current templates and set new from an array,
* Checks if an option is defined
*
* @return ValidatorInterface
* @param array $templates
* @param string $key
*
* @return bool
*/
public function setTemplates(array $templates): ValidatorInterface
public function hasOption(string $key): bool
{
}

/**
* Set a new template message
* Create a default message by factory
*
* @return ValidatorInterface
* @param string $template
* @param Validation $validation
* @param array|string $field
* @param array $replacements
*
* @return Message
*/
public function setTemplate(string $template): ValidatorInterface
public function messageFactory(\Phalcon\Filter\Validation $validation, $field, array $replacements = []): Message
{
}

/**
* Returns an option in the validator's options
* Returns null if the option hasn't set
* Sets an option in the validator
*
* @param string $key
* @param mixed $defaultValue
* @return mixed
* @param mixed $value
*
* @return void
*/
public function getOption(string $key, $defaultValue = null)
public function setOption(string $key, $value): void
{
}

/**
* Checks if an option is defined
* Set a new template message
*
* @param string $key
* @return bool
* @return ValidatorInterface
* @param string $template
*/
public function hasOption(string $key): bool
public function setTemplate(string $template): ValidatorInterface
{
}

/**
* Sets an option in the validator
* Clear current templates and set new from an array,
*
* @param string $key
* @param mixed $value
* @return void
* @return ValidatorInterface
* @param array $templates
*/
public function setOption(string $key, $value): void
public function setTemplates(array $templates): ValidatorInterface
{
}

/**
* Executes the validation
*
* @param \Phalcon\Filter\Validation $validation
* @param mixed $field
* @param Validation $validation
* @param mixed $field
*
* @return bool
*/
abstract public function validate(\Phalcon\Filter\Validation $validation, $field): bool;

/**
* Prepares a validation code.
* Checks if field can be empty.
*
* @param string $field
* @return int
* @param mixed $field
* @param mixed $value
*
* @return bool
*/
protected function prepareCode(string $field): int
protected function allowEmpty($field, $value): bool
{
}

/**
* Prepares a label for the field.
* Checks if a value is an array and returns the element based on the
* passed field name
*
* @param \Phalcon\Filter\Validation $validation
* @param mixed $value
* @param string $field
*
* @return mixed
*/
protected function prepareLabel(\Phalcon\Filter\Validation $validation, string $field)
protected function checkArray($value, string $field)
{
}

/**
* Checks if field can be empty.
* Prepares a validation code.
*
* @param mixed $field
* @param mixed $value *
* @return bool
* @param string $field
*
* @return int
*/
protected function allowEmpty($field, $value): bool
protected function prepareCode(string $field): int
{
}

/**
* Create a default message by factory
* Prepares a label for the field.
*
* @return Message
* @param Validation $validation
* @param string $field
*
* @throw Exception
* @param \Phalcon\Filter\Validation $validation
* @param mixed $field
* @param array $replacements
* @return mixed
*/
public function messageFactory(\Phalcon\Filter\Validation $validation, $field, array $replacements = []): Message
protected function prepareLabel(\Phalcon\Filter\Validation $validation, string $field)
{
}
}
40 changes: 26 additions & 14 deletions src/Filter/Validation/Validator/File/AbstractFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
*/
namespace Phalcon\Filter\Validation\Validator\File;

use Phalcon\Messages\Message;
use Phalcon\Filter\Validation;
use Phalcon\Filter\Validation\AbstractValidator;
use Phalcon\Messages\Message;

/**
* Checks if a value has a correct file
Expand Down Expand Up @@ -79,50 +79,59 @@ abstract class AbstractFile extends AbstractValidator
* Check upload
*
* @param Validation $validation
* @param mixed $field
* @param string $field
*
* @return bool
* @throws Validation\Exception
*/
public function checkUpload(\Phalcon\Filter\Validation $validation, $field): bool
public function checkUpload(\Phalcon\Filter\Validation $validation, string $field): bool
{
}

/**
* Check if upload is empty
*
* @param Validation $validation
* @param mixed $field
* @return boolean
* @param string $field
*
* @return bool
* @throws Validation\Exception
*/
public function checkUploadIsEmpty(\Phalcon\Filter\Validation $validation, $field): bool
public function checkUploadIsEmpty(\Phalcon\Filter\Validation $validation, string $field): bool
{
}

/**
* Check if upload is valid
*
* @param Validation $validation
* @param mixed $field
* @return boolean
* @param string $field
*
* @return bool
* @throws Validation\Exception
*/
public function checkUploadIsValid(\Phalcon\Filter\Validation $validation, $field): bool
public function checkUploadIsValid(\Phalcon\Filter\Validation $validation, string $field): bool
{
}

/**
* Check if uploaded file is larger than PHP allowed size
*
* @param Validation $validation
* @param mixed $field
* @return boolean
* @param string $field
*
* @return bool
* @throws Validation\Exception
*/
public function checkUploadMaxSize(\Phalcon\Filter\Validation $validation, $field): bool
public function checkUploadMaxSize(\Phalcon\Filter\Validation $validation, string $field): bool
{
}

/**
* Convert a string like "2.5MB" in bytes
*
* @param string $size
*
* @return float
*/
public function getFileSizeInBytes(string $size): float
Expand Down Expand Up @@ -160,8 +169,10 @@ public function getMessageValid(): string
* Check on empty
*
* @param Validation $validation
* @param string $field
* @param string $field
*
* @return bool
* @throws Validation\Exception
*/
public function isAllowEmpty(\Phalcon\Filter\Validation $validation, string $field): bool
{
Expand Down Expand Up @@ -202,9 +213,10 @@ public function setMessageValid(string $message): void

/**
* Checks if a file has been uploaded; Internal check that can be
* overriden in a subclass if you do not want to check uploaded files
* overridden in a subclass if you do not want to check uploaded files
*
* @param string $name
*
* @return bool
*/
protected function checkIsUploadedFile(string $name): bool
Expand Down
28 changes: 16 additions & 12 deletions src/Filter/Validation/Validator/File/Size/Equal.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
namespace Phalcon\Filter\Validation\Validator\File\Size;

use Phalcon\Messages\Message;
use Phalcon\Filter\Validation;
use Phalcon\Filter\Validation\Validator\File\AbstractFile;

Expand Down Expand Up @@ -59,29 +58,34 @@
*/
class Equal extends AbstractFile
{
/**
* @var string|null
*/
protected $template = 'File :field does not have the exact :size file size';

/**
* Constructor
* Executes the validation
*
* @param array $options = [
* 'message' => '',
* 'template' => '',
* 'size' => '2.5MB'
* ]
* @param Validation $validation
* @param mixed $field
*
* @return bool
* @throws Validation\Exception
*/
public function __construct(array $options = [])
public function validate(\Phalcon\Filter\Validation $validation, $field): bool
{
}

/**
* Executes the validation
* Executes the conditional
*
* @param float $source
* @param float $target
* @param bool $included
*
* @param \Phalcon\Filter\Validation $validation
* @param mixed $field
* @return bool
*/
public function validate(\Phalcon\Filter\Validation $validation, $field): bool
protected function getConditional(float $source, float $target, bool $included = false)
{
}
}
Loading

0 comments on commit 7e4560a

Please sign in to comment.