Skip to content

Commit 7e4560a

Browse files
authored
Merge pull request #94 from niden/master
5.4.0 Release
2 parents ec3c12f + 2516757 commit 7e4560a

File tree

12 files changed

+211
-174
lines changed

12 files changed

+211
-174
lines changed

src/DataMapper/Query/Select.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ public function appendJoin(string $condition, $value = null, int $type = -1): Se
9797
}
9898

9999
/**
100-
* The columns to select from. If a key is set in an array element, the
100+
* The columns to select from. If a key is set in the array element, the
101101
* key will be used as the alias
102102
*
103-
* @param string ...$column
103+
* @param array $columns
104104
*
105105
* @return Select
106106
*/
107-
public function columns(): Select
107+
public function columns(array $columns): Select
108108
{
109109
}
110110

src/Filter/Validation/AbstractValidator.php

+65-46
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
*/
1010
namespace Phalcon\Filter\Validation;
1111

12-
use Phalcon\Support\Helper\Arr\Whitelist;
1312
use Phalcon\Messages\Message;
1413
use Phalcon\Filter\Validation;
14+
use Phalcon\Support\Helper\Arr\Whitelist;
1515

1616
/**
1717
* This is a base class for validators
@@ -46,12 +46,25 @@ public function __construct(array $options = [])
4646
{
4747
}
4848

49+
/**
50+
* Returns an option in the validator's options
51+
* Returns null if the option hasn't set
52+
*
53+
* @param string $key
54+
* @param mixed|null $defaultValue
55+
*
56+
* @return mixed
57+
*/
58+
public function getOption(string $key, $defaultValue = null)
59+
{
60+
}
61+
4962
/**
5063
* Get the template message
5164
*
65+
* @param string|null $field
66+
*
5267
* @return string
53-
* @throw InvalidArgumentException When the field does not exists
54-
* @param string $field
5568
*/
5669
public function getTemplate(string $field = null): string
5770
{
@@ -67,110 +80,116 @@ public function getTemplates(): array
6780
}
6881

6982
/**
70-
* Clear current templates and set new from an array,
83+
* Checks if an option is defined
7184
*
72-
* @return ValidatorInterface
73-
* @param array $templates
85+
* @param string $key
86+
*
87+
* @return bool
7488
*/
75-
public function setTemplates(array $templates): ValidatorInterface
89+
public function hasOption(string $key): bool
7690
{
7791
}
7892

7993
/**
80-
* Set a new template message
94+
* Create a default message by factory
8195
*
82-
* @return ValidatorInterface
83-
* @param string $template
96+
* @param Validation $validation
97+
* @param array|string $field
98+
* @param array $replacements
99+
*
100+
* @return Message
84101
*/
85-
public function setTemplate(string $template): ValidatorInterface
102+
public function messageFactory(\Phalcon\Filter\Validation $validation, $field, array $replacements = []): Message
86103
{
87104
}
88105

89106
/**
90-
* Returns an option in the validator's options
91-
* Returns null if the option hasn't set
107+
* Sets an option in the validator
92108
*
93109
* @param string $key
94-
* @param mixed $defaultValue
95-
* @return mixed
110+
* @param mixed $value
111+
*
112+
* @return void
96113
*/
97-
public function getOption(string $key, $defaultValue = null)
114+
public function setOption(string $key, $value): void
98115
{
99116
}
100117

101118
/**
102-
* Checks if an option is defined
119+
* Set a new template message
103120
*
104-
* @param string $key
105-
* @return bool
121+
* @return ValidatorInterface
122+
* @param string $template
106123
*/
107-
public function hasOption(string $key): bool
124+
public function setTemplate(string $template): ValidatorInterface
108125
{
109126
}
110127

111128
/**
112-
* Sets an option in the validator
129+
* Clear current templates and set new from an array,
113130
*
114-
* @param string $key
115-
* @param mixed $value
116-
* @return void
131+
* @return ValidatorInterface
132+
* @param array $templates
117133
*/
118-
public function setOption(string $key, $value): void
134+
public function setTemplates(array $templates): ValidatorInterface
119135
{
120136
}
121137

122138
/**
123139
* Executes the validation
124140
*
125-
* @param \Phalcon\Filter\Validation $validation
126-
* @param mixed $field
141+
* @param Validation $validation
142+
* @param mixed $field
143+
*
127144
* @return bool
128145
*/
129146
abstract public function validate(\Phalcon\Filter\Validation $validation, $field): bool;
130147

131148
/**
132-
* Prepares a validation code.
149+
* Checks if field can be empty.
133150
*
134-
* @param string $field
135-
* @return int
151+
* @param mixed $field
152+
* @param mixed $value
153+
*
154+
* @return bool
136155
*/
137-
protected function prepareCode(string $field): int
156+
protected function allowEmpty($field, $value): bool
138157
{
139158
}
140159

141160
/**
142-
* Prepares a label for the field.
161+
* Checks if a value is an array and returns the element based on the
162+
* passed field name
143163
*
144-
* @param \Phalcon\Filter\Validation $validation
164+
* @param mixed $value
145165
* @param string $field
166+
*
146167
* @return mixed
147168
*/
148-
protected function prepareLabel(\Phalcon\Filter\Validation $validation, string $field)
169+
protected function checkArray($value, string $field)
149170
{
150171
}
151172

152173
/**
153-
* Checks if field can be empty.
174+
* Prepares a validation code.
154175
*
155-
* @param mixed $field
156-
* @param mixed $value *
157-
* @return bool
176+
* @param string $field
177+
*
178+
* @return int
158179
*/
159-
protected function allowEmpty($field, $value): bool
180+
protected function prepareCode(string $field): int
160181
{
161182
}
162183

163184
/**
164-
* Create a default message by factory
185+
* Prepares a label for the field.
165186
*
166-
* @return Message
187+
* @param Validation $validation
188+
* @param string $field
167189
*
168-
* @throw Exception
169-
* @param \Phalcon\Filter\Validation $validation
170-
* @param mixed $field
171-
* @param array $replacements
190+
* @return mixed
172191
*/
173-
public function messageFactory(\Phalcon\Filter\Validation $validation, $field, array $replacements = []): Message
192+
protected function prepareLabel(\Phalcon\Filter\Validation $validation, string $field)
174193
{
175194
}
176195
}

src/Filter/Validation/Validator/File/AbstractFile.php

+26-14
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
*/
1010
namespace Phalcon\Filter\Validation\Validator\File;
1111

12-
use Phalcon\Messages\Message;
1312
use Phalcon\Filter\Validation;
1413
use Phalcon\Filter\Validation\AbstractValidator;
14+
use Phalcon\Messages\Message;
1515

1616
/**
1717
* Checks if a value has a correct file
@@ -79,50 +79,59 @@ abstract class AbstractFile extends AbstractValidator
7979
* Check upload
8080
*
8181
* @param Validation $validation
82-
* @param mixed $field
82+
* @param string $field
83+
*
8384
* @return bool
85+
* @throws Validation\Exception
8486
*/
85-
public function checkUpload(\Phalcon\Filter\Validation $validation, $field): bool
87+
public function checkUpload(\Phalcon\Filter\Validation $validation, string $field): bool
8688
{
8789
}
8890

8991
/**
9092
* Check if upload is empty
9193
*
9294
* @param Validation $validation
93-
* @param mixed $field
94-
* @return boolean
95+
* @param string $field
96+
*
97+
* @return bool
98+
* @throws Validation\Exception
9599
*/
96-
public function checkUploadIsEmpty(\Phalcon\Filter\Validation $validation, $field): bool
100+
public function checkUploadIsEmpty(\Phalcon\Filter\Validation $validation, string $field): bool
97101
{
98102
}
99103

100104
/**
101105
* Check if upload is valid
102106
*
103107
* @param Validation $validation
104-
* @param mixed $field
105-
* @return boolean
108+
* @param string $field
109+
*
110+
* @return bool
111+
* @throws Validation\Exception
106112
*/
107-
public function checkUploadIsValid(\Phalcon\Filter\Validation $validation, $field): bool
113+
public function checkUploadIsValid(\Phalcon\Filter\Validation $validation, string $field): bool
108114
{
109115
}
110116

111117
/**
112118
* Check if uploaded file is larger than PHP allowed size
113119
*
114120
* @param Validation $validation
115-
* @param mixed $field
116-
* @return boolean
121+
* @param string $field
122+
*
123+
* @return bool
124+
* @throws Validation\Exception
117125
*/
118-
public function checkUploadMaxSize(\Phalcon\Filter\Validation $validation, $field): bool
126+
public function checkUploadMaxSize(\Phalcon\Filter\Validation $validation, string $field): bool
119127
{
120128
}
121129

122130
/**
123131
* Convert a string like "2.5MB" in bytes
124132
*
125133
* @param string $size
134+
*
126135
* @return float
127136
*/
128137
public function getFileSizeInBytes(string $size): float
@@ -160,8 +169,10 @@ public function getMessageValid(): string
160169
* Check on empty
161170
*
162171
* @param Validation $validation
163-
* @param string $field
172+
* @param string $field
173+
*
164174
* @return bool
175+
* @throws Validation\Exception
165176
*/
166177
public function isAllowEmpty(\Phalcon\Filter\Validation $validation, string $field): bool
167178
{
@@ -202,9 +213,10 @@ public function setMessageValid(string $message): void
202213

203214
/**
204215
* Checks if a file has been uploaded; Internal check that can be
205-
* overriden in a subclass if you do not want to check uploaded files
216+
* overridden in a subclass if you do not want to check uploaded files
206217
*
207218
* @param string $name
219+
*
208220
* @return bool
209221
*/
210222
protected function checkIsUploadedFile(string $name): bool

src/Filter/Validation/Validator/File/Size/Equal.php

+16-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010
namespace Phalcon\Filter\Validation\Validator\File\Size;
1111

12-
use Phalcon\Messages\Message;
1312
use Phalcon\Filter\Validation;
1413
use Phalcon\Filter\Validation\Validator\File\AbstractFile;
1514

@@ -59,29 +58,34 @@
5958
*/
6059
class Equal extends AbstractFile
6160
{
61+
/**
62+
* @var string|null
63+
*/
6264
protected $template = 'File :field does not have the exact :size file size';
6365

6466
/**
65-
* Constructor
67+
* Executes the validation
6668
*
67-
* @param array $options = [
68-
* 'message' => '',
69-
* 'template' => '',
70-
* 'size' => '2.5MB'
71-
* ]
69+
* @param Validation $validation
70+
* @param mixed $field
71+
*
72+
* @return bool
73+
* @throws Validation\Exception
7274
*/
73-
public function __construct(array $options = [])
75+
public function validate(\Phalcon\Filter\Validation $validation, $field): bool
7476
{
7577
}
7678

7779
/**
78-
* Executes the validation
80+
* Executes the conditional
81+
*
82+
* @param float $source
83+
* @param float $target
84+
* @param bool $included
7985
*
80-
* @param \Phalcon\Filter\Validation $validation
81-
* @param mixed $field
8286
* @return bool
8387
*/
84-
public function validate(\Phalcon\Filter\Validation $validation, $field): bool
88+
protected function getConditional(float $source, float $target, bool $included = false)
8589
{
8690
}
8791
}

0 commit comments

Comments
 (0)