Skip to content

Commit 34fb76c

Browse files
committed
cs
1 parent b28556d commit 34fb76c

6 files changed

Lines changed: 20 additions & 27 deletions

File tree

src/Schema/Context.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ final class Context
3131
public array $dynamics = [];
3232

3333

34+
/**
35+
* @param string[] $variables
36+
*/
3437
public function addError(string $message, string $code, array $variables = []): Message
3538
{
3639
$variables['isKey'] = $this->isKey;

src/Schema/Elements/AnyOf.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ final class AnyOf implements Schema
2020
{
2121
use Base;
2222

23+
/** @var mixed[] */
2324
private array $set;
2425

2526

src/Schema/Elements/Structure.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public function extend(array|self $shape): self
8484
}
8585

8686

87+
/** @return Schema[] */
8788
public function getShape(): array
8889
{
8990
return $this->items;
@@ -174,7 +175,7 @@ private function validateItems(array &$value, Context $context): void
174175
if ($this->otherItems) {
175176
$items += array_fill_keys($extraKeys, $this->otherItems);
176177
} else {
177-
$keys = array_map('strval', array_keys($items));
178+
$keys = array_map(strval(...), array_keys($items));
178179
foreach ($extraKeys as $key) {
179180
$hint = Nette\Utils\Helpers::getSuggestion($keys, (string) $key);
180181
$context->addError(

src/Schema/Helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public static function validateRange(mixed $value, array $range, Context $contex
126126
if (is_array($value) || is_string($value)) {
127127
[$length, $label] = is_array($value)
128128
? [count($value), 'items']
129-
: (in_array('unicode', explode('|', $types), true)
129+
: (in_array('unicode', explode('|', $types), strict: true)
130130
? [Nette\Utils\Strings::length($value), 'characters']
131131
: [strlen($value), 'bytes']);
132132

src/Schema/Message.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,15 @@ final class Message
6363
/** @deprecated use Message::Deprecated */
6464
public const DEPRECATED = self::Deprecated;
6565

66-
public string $message;
67-
public string $code;
6866

69-
/** @var string[] */
70-
public array $path;
71-
72-
/** @var string[] */
73-
public array $variables;
74-
75-
76-
public function __construct(string $message, string $code, array $path, array $variables = [])
77-
{
78-
$this->message = $message;
79-
$this->code = $code;
80-
$this->path = $path;
81-
$this->variables = $variables;
67+
public function __construct(
68+
public string $message,
69+
public string $code,
70+
/** @var string[] */
71+
public array $path,
72+
/** @var string[] */
73+
public array $variables = [],
74+
) {
8275
}
8376

8477

src/Schema/ValidationException.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,12 @@
1717
*/
1818
class ValidationException extends Nette\InvalidStateException
1919
{
20-
/** @var Message[] */
21-
private array $messages;
22-
23-
24-
/**
25-
* @param Message[] $messages
26-
*/
27-
public function __construct(?string $message, array $messages = [])
28-
{
20+
public function __construct(
21+
?string $message,
22+
/** @var Message[] */
23+
private array $messages = [],
24+
) {
2925
parent::__construct($message ?? $messages[0]->toString());
30-
$this->messages = $messages;
3126
}
3227

3328

0 commit comments

Comments
 (0)