update lock clucknut
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 14s
Build, Push and Deploy / build-and-push (push) Successful in 3m14s
Build, Push and Deploy / deploy-staging (push) Successful in 25s
Build, Push and Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-18 20:32:18 +07:00
parent 4554035227
commit dcaf267458
3359 changed files with 153185 additions and 205489 deletions

View File

@@ -1,12 +1,10 @@
<?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;
use Nette;
@@ -32,6 +30,7 @@
*/
final class Expect
{
/** @param list<mixed> $args */
public static function __callStatic(string $name, array $args): Type
{
$type = new Type($name);
@@ -55,15 +54,14 @@ public static function anyOf(mixed ...$set): AnyOf
}
/**
* @param Schema[] $shape
*/
/** @param Schema[] $shape */
public static function structure(array $shape): Structure
{
return new Structure($shape);
}
/** @param array<string, Schema> $items */
public static function from(object $object, array $items = []): Structure
{
$ro = new \ReflectionObject($object);
@@ -72,8 +70,8 @@ public static function from(object $object, array $items = []): Structure
: $ro->getProperties();
foreach ($props as $prop) {
$item = &$items[$prop->getName()];
if (!$item) {
$name = $prop->getName();
if (!isset($items[$name])) {
$type = Helpers::getPropertyType($prop) ?? 'mixed';
$item = new Type($type);
if ($prop instanceof \ReflectionProperty ? $prop->isInitialized($object) : $prop->isOptional()) {
@@ -88,6 +86,7 @@ public static function from(object $object, array $items = []): Structure
} else {
$item->required();
}
$items[$name] = $item;
}
}
@@ -100,7 +99,8 @@ public static function from(object $object, array $items = []): Structure
*/
public static function array(?array $shape = []): Structure|Type
{
return Nette\Utils\Arrays::first($shape ?? []) instanceof Schema
$shape ??= [];
return Nette\Utils\Arrays::first($shape) instanceof Schema
? (new Structure($shape))->castTo('array')
: (new Type('array'))->default($shape);
}