@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | /** |
| 338 | 338 | * @param array $serializedBlocks |
| 339 | 339 | * |
| 340 | - * @return array |
|
| 340 | + * @return integer[] |
|
| 341 | 341 | * |
| 342 | 342 | * @SuppressWarnings(PHPMD.StaticAccess) |
| 343 | 343 | */ |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | /** |
| 358 | 358 | * @param array $serializedBlocks |
| 359 | 359 | * |
| 360 | - * @return array |
|
| 360 | + * @return integer[] |
|
| 361 | 361 | * |
| 362 | 362 | * @SuppressWarnings(PHPMD.StaticAccess) |
| 363 | 363 | */ |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | * @param string $input |
| 97 | 97 | * @param string $format |
| 98 | 98 | * |
| 99 | - * @return DateTimeInterface|null |
|
| 99 | + * @return DateTimeImmutable|null |
|
| 100 | 100 | * |
| 101 | 101 | * @SuppressWarnings(PHPMD.StaticAccess) |
| 102 | 102 | */ |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | public function __construct(array $scalars) |
| 32 | 32 | { |
| 33 | - assert(call_user_func(function () use ($scalars) { |
|
| 33 | + assert(call_user_func(function() use ($scalars) { |
|
| 34 | 34 | foreach ($scalars as $scalar) { |
| 35 | 35 | assert(static::isValidType($scalar) === true); |
| 36 | 36 | } |
@@ -128,7 +128,7 @@ |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | - * @param callable|null $endCallable |
|
| 131 | + * @param callable $endCallable |
|
| 132 | 132 | * |
| 133 | 133 | * @return self |
| 134 | 134 | */ |
@@ -23,15 +23,15 @@ |
||
| 23 | 23 | { |
| 24 | 24 | /** |
| 25 | 25 | * @param int $key |
| 26 | - * @param mixed $default |
|
| 26 | + * @param boolean $default |
|
| 27 | 27 | * |
| 28 | - * @return mixed |
|
| 28 | + * @return ContextInterface |
|
| 29 | 29 | */ |
| 30 | 30 | public function getState(int $key, $default = null); |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * @param int $key |
| 34 | - * @param mixed $value |
|
| 34 | + * @param boolean $value |
|
| 35 | 35 | * |
| 36 | 36 | * @return self |
| 37 | 37 | */ |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php namespace Sample; |
| 2 | 2 | |
| 3 | -require_once __DIR__ . '/vendor/autoload.php'; |
|
| 3 | +require_once __DIR__.'/vendor/autoload.php'; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Copyright 2015-2017 [email protected] |
@@ -105,8 +105,7 @@ discard block |
||
| 105 | 105 | protected static function lessThan($value, RuleInterface $next = null): RuleInterface |
| 106 | 106 | { |
| 107 | 107 | return $next === null ? |
| 108 | - $value instanceof DateTimeInterface ? new DateTimeLessThan($value) : new NumericLessThan($value) : |
|
| 109 | - new AndOperator(static::lessThan($value), $next); |
|
| 108 | + $value instanceof DateTimeInterface ? new DateTimeLessThan($value) : new NumericLessThan($value) : new AndOperator(static::lessThan($value), $next); |
|
| 110 | 109 | } |
| 111 | 110 | |
| 112 | 111 | /** |
@@ -118,8 +117,7 @@ discard block |
||
| 118 | 117 | protected static function lessOrEquals($value, RuleInterface $next = null): RuleInterface |
| 119 | 118 | { |
| 120 | 119 | return $next === null ? |
| 121 | - $value instanceof DateTimeInterface ? new DateTimeLessOrEquals($value) : new NumericLessOrEquals($value) : |
|
| 122 | - new AndOperator(static::lessOrEquals($value), $next); |
|
| 120 | + $value instanceof DateTimeInterface ? new DateTimeLessOrEquals($value) : new NumericLessOrEquals($value) : new AndOperator(static::lessOrEquals($value), $next); |
|
| 123 | 121 | } |
| 124 | 122 | |
| 125 | 123 | /** |
@@ -131,8 +129,7 @@ discard block |
||
| 131 | 129 | protected static function moreThan($value, RuleInterface $next = null): RuleInterface |
| 132 | 130 | { |
| 133 | 131 | return $next === null ? |
| 134 | - $value instanceof DateTimeInterface ? new DateTimeMoreThan($value) : new NumericMoreThan($value) : |
|
| 135 | - new AndOperator(static::moreThan($value), $next); |
|
| 132 | + $value instanceof DateTimeInterface ? new DateTimeMoreThan($value) : new NumericMoreThan($value) : new AndOperator(static::moreThan($value), $next); |
|
| 136 | 133 | } |
| 137 | 134 | |
| 138 | 135 | /** |
@@ -145,8 +142,7 @@ discard block |
||
| 145 | 142 | { |
| 146 | 143 | return $next === null ? |
| 147 | 144 | ($value instanceof DateTimeInterface ? |
| 148 | - new DateTimeMoreOrEquals($value) : new NumericMoreOrEqualsThan($value)) : |
|
| 149 | - new AndOperator(static::moreOrEquals($value), $next); |
|
| 145 | + new DateTimeMoreOrEquals($value) : new NumericMoreOrEqualsThan($value)) : new AndOperator(static::moreOrEquals($value), $next); |
|
| 150 | 146 | } |
| 151 | 147 | |
| 152 | 148 | /** |
@@ -162,8 +158,7 @@ discard block |
||
| 162 | 158 | |
| 163 | 159 | return $next === null ? |
| 164 | 160 | ($areLimitsDates ? |
| 165 | - new DateTimeBetween($lowerLimit, $upperLimit) : new NumericBetween($lowerLimit, $upperLimit)) : |
|
| 166 | - new AndOperator(static::between($lowerLimit, $upperLimit), $next); |
|
| 161 | + new DateTimeBetween($lowerLimit, $upperLimit) : new NumericBetween($lowerLimit, $upperLimit)) : new AndOperator(static::between($lowerLimit, $upperLimit), $next); |
|
| 167 | 162 | } |
| 168 | 163 | |
| 169 | 164 | /** |
@@ -176,8 +171,7 @@ discard block |
||
| 176 | 171 | protected static function stringLengthBetween(int $min, int $max, RuleInterface $next = null): RuleInterface |
| 177 | 172 | { |
| 178 | 173 | return $next === null ? |
| 179 | - new StringLengthBetween($min, $max) : |
|
| 180 | - new AndOperator(static::stringLengthBetween($min, $max), $next); |
|
| 174 | + new StringLengthBetween($min, $max) : new AndOperator(static::stringLengthBetween($min, $max), $next); |
|
| 181 | 175 | } |
| 182 | 176 | |
| 183 | 177 | /** |
@@ -189,8 +183,7 @@ discard block |
||
| 189 | 183 | protected static function stringLengthMin(int $min, RuleInterface $next = null): RuleInterface |
| 190 | 184 | { |
| 191 | 185 | return $next === null ? |
| 192 | - new StringLengthMin($min) : |
|
| 193 | - new AndOperator(static::stringLengthMin($min), $next); |
|
| 186 | + new StringLengthMin($min) : new AndOperator(static::stringLengthMin($min), $next); |
|
| 194 | 187 | } |
| 195 | 188 | |
| 196 | 189 | /** |
@@ -202,8 +195,7 @@ discard block |
||
| 202 | 195 | protected static function stringLengthMax(int $max, RuleInterface $next = null): RuleInterface |
| 203 | 196 | { |
| 204 | 197 | return $next === null ? |
| 205 | - new StringLengthMax($max) : |
|
| 206 | - new AndOperator(static::stringLengthMax($max), $next); |
|
| 198 | + new StringLengthMax($max) : new AndOperator(static::stringLengthMax($max), $next); |
|
| 207 | 199 | } |
| 208 | 200 | |
| 209 | 201 | /** |
@@ -215,8 +207,7 @@ discard block |
||
| 215 | 207 | protected static function regexp(string $pattern, RuleInterface $next = null): RuleInterface |
| 216 | 208 | { |
| 217 | 209 | return $next === null ? |
| 218 | - new StringRegExp($pattern) : |
|
| 219 | - new AndOperator(static::regexp($pattern), $next); |
|
| 210 | + new StringRegExp($pattern) : new AndOperator(static::regexp($pattern), $next); |
|
| 220 | 211 | } |
| 221 | 212 | |
| 222 | 213 | /** |
@@ -114,7 +114,7 @@ |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | - * @param iterable $errors |
|
| 117 | + * @param ErrorInterface[] $errors |
|
| 118 | 118 | * |
| 119 | 119 | * @return void |
| 120 | 120 | */ |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | // 'address1' => 'Dow 1', // missed required parameter |
| 67 | 67 | 'accepted' => 'false', |
| 68 | 68 | ]; |
| 69 | - $this->console('Invalid data (errors)' . PHP_EOL); |
|
| 69 | + $this->console('Invalid data (errors)'.PHP_EOL); |
|
| 70 | 70 | $validator->validate($invalidInput); |
| 71 | 71 | $this->printErrors($validator->getErrors()); |
| 72 | - $this->console('Invalid data (captures)' . PHP_EOL); |
|
| 72 | + $this->console('Invalid data (captures)'.PHP_EOL); |
|
| 73 | 73 | $this->printCaptures($validator->getCaptures()); |
| 74 | 74 | |
| 75 | 75 | // Check with valid data |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | 'address2' => null, |
| 83 | 83 | 'accepted' => 'true', |
| 84 | 84 | ]; |
| 85 | - $this->console(PHP_EOL . 'Valid data (errors)' . PHP_EOL); |
|
| 85 | + $this->console(PHP_EOL.'Valid data (errors)'.PHP_EOL); |
|
| 86 | 86 | $validator->validate($validInput); |
| 87 | 87 | $this->printErrors($validator->getErrors()); |
| 88 | - $this->console('Valid data (captures)' . PHP_EOL); |
|
| 88 | + $this->console('Valid data (captures)'.PHP_EOL); |
|
| 89 | 89 | $this->printCaptures($validator->getCaptures()); |
| 90 | 90 | |
| 91 | 91 | // The output would be |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | $context = $error->getMessageContext(); |
| 134 | 134 | $errorMsg = MessageFormatter::formatMessage('en', $errorMsg, $context !== null ? $context : []); |
| 135 | 135 | |
| 136 | - $this->console("$entry failed for `$paramValue` with: $errorMsg" . PHP_EOL); |
|
| 136 | + $this->console("$entry failed for `$paramValue` with: $errorMsg".PHP_EOL); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | if ($hasErrors === false) { |
| 140 | - $this->console('No errors' . PHP_EOL); |
|
| 140 | + $this->console('No errors'.PHP_EOL); |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | $hasCaptures = true; |
| 155 | 155 | $type = gettype($value); |
| 156 | 156 | $value = $value instanceof DateTimeInterface ? $value->format(DateTime::ISO8601) : $value; |
| 157 | - $this->console("`$name` = `$value` ($type)" . PHP_EOL); |
|
| 157 | + $this->console("`$name` = `$value` ($type)".PHP_EOL); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if ($hasCaptures === false) { |
| 161 | - $this->console('No captures' . PHP_EOL); |
|
| 161 | + $this->console('No captures'.PHP_EOL); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
@@ -36,7 +36,6 @@ |
||
| 36 | 36 | public static function execute($value, ContextInterface $context): array |
| 37 | 37 | { |
| 38 | 38 | return is_array($value) === true ? |
| 39 | - static::createSuccessReply($value) : |
|
| 40 | - static::createErrorReply($context, $value, ErrorCodes::IS_ARRAY); |
|
| 39 | + static::createSuccessReply($value) : static::createErrorReply($context, $value, ErrorCodes::IS_ARRAY); |
|
| 41 | 40 | } |
| 42 | 41 | } |