Skip to content

Commit 40cd806

Browse files
committed
Merge branch 'new' into 2.1.x
2 parents 75ed6d9 + 66d372e commit 40cd806

File tree

7 files changed

+31
-29
lines changed

7 files changed

+31
-29
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ indent_style = space
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11-
[*.{md, rst}]
11+
[*.{md,rst}]
1212
trim_trailing_whitespace = false
1313

1414
[*.yml]

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"require-dev": {
4242
"ext-xdebug": "*",
43-
"aplus/coding-standard": "^1.14",
43+
"aplus/coding-standard": "^2.0",
4444
"ergebnis/composer-normalize": "^2.25",
4545
"jetbrains/phpstorm-attributes": "^1.0",
4646
"phpmd/phpmd": "^2.13",

guide/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ To validate only one field is possible to use only the Validator:
133133
Working with Arrays
134134
-------------------
135135

136-
Validator uses the `ArraySimple <https://gitlab.com/aplus-framework/libraries/helpers>`_
136+
Validator uses the `ArraySimple <https://github.com/aplus-framework/helpers>`_
137137
class to extract fields and get the correct data value.
138138

139139
.. code-block:: php
@@ -758,5 +758,5 @@ The more you use it, the more you will learn.
758758
.. note::
759759
Did you find something wrong?
760760
Be sure to let us know about it with an
761-
`issue <https://gitlab.com/aplus-framework/libraries/validation/issues>`_.
761+
`issue <https://github.com/aplus-framework/validation/issues>`_.
762762
Thank you!

src/Debug/ValidationCollector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getActivities() : array
4949

5050
public function getContents() : string
5151
{
52-
if ( ! isset($this->validation)) {
52+
if (!isset($this->validation)) {
5353
return '<p>A Validation instance has not been set in this collector.</p>';
5454
}
5555
\ob_start(); ?>
@@ -65,7 +65,7 @@ public function getContents() : string
6565

6666
protected function renderValidations() : string
6767
{
68-
if ( ! $this->hasData()) {
68+
if (!$this->hasData()) {
6969
return '<p>Validation did not run.</p>';
7070
}
7171
$count = \count($this->getData());
@@ -116,7 +116,7 @@ protected function renderValidations() : string
116116

117117
protected function renderRuleset() : string
118118
{
119-
if ( ! $this->validation->getRules()) {
119+
if (!$this->validation->getRules()) {
120120
return '<p>No rules have been set.</p>';
121121
}
122122
\ob_start(); ?>

src/FilesValidator.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static function uploaded(string $field, array $data = []) : bool
7676
public static function maxSize(string $field, array $data, int $kilobytes) : bool
7777
{
7878
$uploaded = static::uploaded($field);
79-
if ( ! $uploaded) {
79+
if (!$uploaded) {
8080
return false;
8181
}
8282
$file = static::getFile($field);
@@ -95,7 +95,7 @@ public static function maxSize(string $field, array $data, int $kilobytes) : boo
9595
public static function mimes(string $field, array $data, string ...$allowedTypes) : bool
9696
{
9797
$uploaded = static::uploaded($field);
98-
if ( ! $uploaded) {
98+
if (!$uploaded) {
9999
return false;
100100
}
101101
$file = static::getFile($field);
@@ -118,7 +118,7 @@ public static function mimes(string $field, array $data, string ...$allowedTypes
118118
public static function ext(string $field, array $data, string ...$allowedExtensions) : bool
119119
{
120120
$uploaded = static::uploaded($field);
121-
if ( ! $uploaded) {
121+
if (!$uploaded) {
122122
return false;
123123
}
124124
$file = static::getFile($field);
@@ -141,7 +141,7 @@ public static function ext(string $field, array $data, string ...$allowedExtensi
141141
public static function image(string $field, array $data = [])
142142
{
143143
$uploaded = static::uploaded($field);
144-
if ( ! $uploaded) {
144+
if (!$uploaded) {
145145
return false;
146146
}
147147
$file = static::getFile($field);
@@ -162,12 +162,12 @@ public static function image(string $field, array $data = [])
162162
public static function maxDim(string $field, array $data, int $width, int $height)
163163
{
164164
$isImage = static::image($field);
165-
if ( ! $isImage) {
165+
if (!$isImage) {
166166
return false;
167167
}
168168
$file = static::getFile($field);
169169
$sizes = \getimagesize($file['tmp_name']);
170-
return ! ($sizes === false || $sizes[0] > $width || $sizes[1] > $height);
170+
return !($sizes === false || $sizes[0] > $width || $sizes[1] > $height);
171171
}
172172

173173
/**
@@ -183,12 +183,12 @@ public static function maxDim(string $field, array $data, int $width, int $heigh
183183
public static function minDim(string $field, array $data, int $width, int $height)
184184
{
185185
$isImage = static::image($field);
186-
if ( ! $isImage) {
186+
if (!$isImage) {
187187
return false;
188188
}
189189
$file = static::getFile($field);
190190
$sizes = \getimagesize($file['tmp_name']);
191-
return ! ($sizes === false || $sizes[0] < $width || $sizes[1] < $height);
191+
return !($sizes === false || $sizes[0] < $width || $sizes[1] < $height);
192192
}
193193

194194
/**
@@ -204,11 +204,11 @@ public static function minDim(string $field, array $data, int $width, int $heigh
204204
public static function dim(string $field, array $data, int $width, int $height)
205205
{
206206
$isImage = static::image($field);
207-
if ( ! $isImage) {
207+
if (!$isImage) {
208208
return false;
209209
}
210210
$file = static::getFile($field);
211211
$sizes = \getimagesize($file['tmp_name']);
212-
return ! ($sizes === false || $sizes[0] !== $width || $sizes[1] !== $height);
212+
return !($sizes === false || $sizes[0] !== $width || $sizes[1] !== $height);
213213
}
214214
}

src/Validation.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function setLanguage(Language $language = null) : static
9696

9797
public function getLanguage() : Language
9898
{
99-
if ( ! isset($this->language)) {
99+
if (!isset($this->language)) {
100100
$this->setLanguage();
101101
}
102102
return $this->language;
@@ -468,7 +468,7 @@ protected function validateField(string $field, array $rules, array $data) : boo
468468
foreach ($rules as $key => $rule) {
469469
if ($rule['rule'] === 'optional') {
470470
$removeKeys[] = $key;
471-
if ( ! \array_key_exists($field, $data)) {
471+
if (!\array_key_exists($field, $data)) {
472472
return true;
473473
}
474474
}
@@ -539,7 +539,7 @@ protected function run(array $fieldRules, array $data) : bool
539539
$result = true;
540540
foreach ($fieldRules as $field => $rules) {
541541
$status = $this->validateField($field, $rules, $data);
542-
if ( ! $status) {
542+
if (!$status) {
543543
$result = false;
544544
}
545545
}

src/Validator.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ public static function json(string $field, array $data) : bool
204204
public static function regex(
205205
string $field,
206206
array $data,
207-
#[Language('RegExp')] string $pattern
207+
#[Language('RegExp')]
208+
string $pattern
208209
) : bool {
209210
$data = static::getData($field, $data);
210211
return $data !== null && \preg_match($pattern, $data) === 1;
@@ -222,9 +223,10 @@ public static function regex(
222223
public static function notRegex(
223224
string $field,
224225
array $data,
225-
#[Language('RegExp')] string $pattern
226+
#[Language('RegExp')]
227+
string $pattern
226228
) : bool {
227-
return ! static::regex($field, $data, $pattern);
229+
return !static::regex($field, $data, $pattern);
228230
}
229231

230232
/**
@@ -239,11 +241,11 @@ public static function notRegex(
239241
public static function equals(string $field, array $data, string $equalsField) : bool
240242
{
241243
$field = ArraySimple::value($field, $data);
242-
if ($field === null || ! \is_scalar($field)) {
244+
if ($field === null || !\is_scalar($field)) {
243245
return false;
244246
}
245247
$equalsField = ArraySimple::value($equalsField, $data);
246-
if ($equalsField === null || ! \is_scalar($equalsField)) {
248+
if ($equalsField === null || !\is_scalar($equalsField)) {
247249
return false;
248250
}
249251
return (string) $field === (string) $equalsField;
@@ -260,7 +262,7 @@ public static function equals(string $field, array $data, string $equalsField) :
260262
*/
261263
public static function notEquals(string $field, array $data, string $diffField) : bool
262264
{
263-
return ! static::equals($field, $data, $diffField);
265+
return !static::equals($field, $data, $diffField);
264266
}
265267

266268
/**
@@ -299,7 +301,7 @@ public static function notBetween(
299301
int | string $min,
300302
int | string $max
301303
) : bool {
302-
return ! static::between($field, $data, $min, $max);
304+
return !static::between($field, $data, $min, $max);
303305
}
304306

305307
/**
@@ -330,7 +332,7 @@ public static function in(string $field, array $data, string $in, string ...$oth
330332
*/
331333
public static function notIn(string $field, array $data, string $notIn, string ...$others) : bool
332334
{
333-
return ! static::in($field, $data, $notIn, ...$others);
335+
return !static::in($field, $data, $notIn, ...$others);
334336
}
335337

336338
/**
@@ -376,7 +378,7 @@ public static function url(string $field, array $data) : bool
376378
return false;
377379
}
378380
if (\preg_match('/^(?:([^:]*)\:)?\/\/(.+)$/', $data, $matches)) {
379-
if ( ! \in_array($matches[1], ['http', 'https'], true)) {
381+
if (!\in_array($matches[1], ['http', 'https'], true)) {
380382
return false;
381383
}
382384
$data = $matches[2];

0 commit comments

Comments
 (0)