This commit is contained in:
Javier Casares 2026-06-08 12:31:51 +00:00
commit 7dd3eeaa8a
97 changed files with 4912 additions and 1581 deletions

View file

@ -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 @@ final class Structure implements Schema
}
/** @param Schema[]|self $shape */
public function extend(array|self $shape): self
{
$shape = $shape instanceof self ? $shape->items : $shape;
@ -84,6 +81,7 @@ final class Structure implements Schema
}
/** @return Schema[] */
public function getShape(): array
{
return $this->items;
@ -167,6 +165,7 @@ final class Structure implements Schema
}
/** @param array<mixed> $value */
private function validateItems(array &$value, Context $context): void
{
$items = $this->items;
@ -174,7 +173,7 @@ final class Structure implements Schema
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(