Skip to content

Commit b613d62

Browse files
committed
cs
1 parent 383c7a0 commit b613d62

5 files changed

Lines changed: 17 additions & 29 deletions

File tree

src/Schema/Elements/Base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function transform(callable $handler): self
7070
/** @param callable(mixed): bool $handler */
7171
public function assert(callable $handler, ?string $description = null): self
7272
{
73-
$expected = $description ?: (is_string($handler) ? "$handler()" : '#' . count($this->transforms));
73+
$expected = $description ?? (is_string($handler) ? "$handler()" : '#' . count($this->transforms));
7474
return $this->transform(function ($value, Context $context) use ($handler, $description, $expected) {
7575
if ($handler($value)) {
7676
return $value;

src/Schema/Elements/Structure.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private function validateItems(array &$value, Context $context): void
175175
if ($this->otherItems) {
176176
$items += array_fill_keys($extraKeys, $this->otherItems);
177177
} else {
178-
$keys = array_map('strval', array_keys($items));
178+
$keys = array_map(strval(...), array_keys($items));
179179
foreach ($extraKeys as $key) {
180180
$hint = Nette\Utils\Helpers::getSuggestion($keys, (string) $key);
181181
$context->addError(

src/Schema/Helpers.php

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

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 list<int|string> */
71+
public array $path,
72+
/** @var array<string, mixed> */
73+
public array $variables = [],
74+
) {
8275
}
8376

8477

src/Schema/ValidationException.php

Lines changed: 6 additions & 11 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-
{
29-
parent::__construct($message ?: $messages[0]->toString());
30-
$this->messages = $messages;
20+
public function __construct(
21+
?string $message,
22+
/** @var list<Message> */
23+
private array $messages = [],
24+
) {
25+
parent::__construct($message ?? $messages[0]->toString());
3126
}
3227

3328

0 commit comments

Comments
 (0)