update lock clucknut
All checks were successful
All checks were successful
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Nette\Schema\Elements;
|
||||
|
||||
use Nette;
|
||||
use Nette\Schema\Context;
|
||||
use Nette\Schema\Helpers;
|
||||
use Nette\Schema\Schema;
|
||||
use function array_diff_key, array_fill_keys, array_key_exists, array_keys, array_map, array_merge, array_pop, array_values, is_array, is_object;
|
||||
use function array_diff_key, array_fill_keys, array_key_exists, array_keys, array_map, array_merge, array_pop, array_values, is_array, is_object, strval;
|
||||
|
||||
|
||||
final class Structure implements Schema
|
||||
@@ -31,9 +29,7 @@ final class Structure implements Schema
|
||||
private bool $skipDefaults = false;
|
||||
|
||||
|
||||
/**
|
||||
* @param Schema[] $shape
|
||||
*/
|
||||
/** @param Schema[] $shape */
|
||||
public function __construct(array $shape)
|
||||
{
|
||||
(function (Schema ...$items) {})(...array_values($shape));
|
||||
@@ -77,6 +73,7 @@ public function skipDefaults(bool $state = true): self
|
||||
}
|
||||
|
||||
|
||||
/** @param Schema[]|self $shape */
|
||||
public function extend(array|self $shape): self
|
||||
{
|
||||
$shape = $shape instanceof self ? $shape->items : $shape;
|
||||
@@ -84,6 +81,7 @@ public function extend(array|self $shape): self
|
||||
}
|
||||
|
||||
|
||||
/** @return Schema[] */
|
||||
public function getShape(): array
|
||||
{
|
||||
return $this->items;
|
||||
@@ -167,6 +165,7 @@ public function complete(mixed $value, Context $context): mixed
|
||||
}
|
||||
|
||||
|
||||
/** @param array<mixed> $value */
|
||||
private function validateItems(array &$value, Context $context): void
|
||||
{
|
||||
$items = $this->items;
|
||||
@@ -174,7 +173,7 @@ private function validateItems(array &$value, Context $context): void
|
||||
if ($this->otherItems) {
|
||||
$items += array_fill_keys($extraKeys, $this->otherItems);
|
||||
} else {
|
||||
$keys = array_map('strval', array_keys($items));
|
||||
$keys = array_map(strval(...), array_keys($items));
|
||||
foreach ($extraKeys as $key) {
|
||||
$hint = Nette\Utils\Helpers::getSuggestion($keys, (string) $key);
|
||||
$context->addError(
|
||||
|
||||
Reference in New Issue
Block a user