v1.1.1
This commit is contained in:
parent
92d56fe84d
commit
7dd3eeaa8a
97 changed files with 4912 additions and 1581 deletions
13
vendor/nette/schema/src/Schema/Helpers.php
vendored
13
vendor/nette/schema/src/Schema/Helpers.php
vendored
|
|
@ -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;
|
||||
|
|
@ -74,9 +72,9 @@ final class Helpers
|
|||
|
||||
/**
|
||||
* Returns an annotation value.
|
||||
* @param \ReflectionProperty $ref
|
||||
* @param \ReflectionClass<object>|\ReflectionProperty $ref
|
||||
*/
|
||||
public static function parseAnnotation(\Reflector $ref, string $name): ?string
|
||||
public static function parseAnnotation(\ReflectionClass|\ReflectionProperty $ref, string $name): ?string
|
||||
{
|
||||
if (!Reflection::areCommentsAvailable()) {
|
||||
throw new Nette\InvalidStateException('You have to enable phpDoc comments in opcode cache.');
|
||||
|
|
@ -121,12 +119,13 @@ final class Helpers
|
|||
}
|
||||
|
||||
|
||||
/** @param array{?float, ?float} $range */
|
||||
public static function validateRange(mixed $value, array $range, Context $context, string $types = ''): void
|
||||
{
|
||||
if (is_array($value) || is_string($value)) {
|
||||
[$length, $label] = is_array($value)
|
||||
? [count($value), 'items']
|
||||
: (in_array('unicode', explode('|', $types), true)
|
||||
: (in_array('unicode', explode('|', $types), strict: true)
|
||||
? [Nette\Utils\Strings::length($value), 'characters']
|
||||
: [strlen($value), 'bytes']);
|
||||
|
||||
|
|
@ -147,6 +146,7 @@ final class Helpers
|
|||
}
|
||||
|
||||
|
||||
/** @param array{?float, ?float} $range */
|
||||
public static function isInRange(mixed $value, array $range): bool
|
||||
{
|
||||
return ($range[0] === null || $value >= $range[0])
|
||||
|
|
@ -166,6 +166,7 @@ final class Helpers
|
|||
}
|
||||
|
||||
|
||||
/** @return \Closure(mixed): mixed */
|
||||
public static function getCastStrategy(string $type): \Closure
|
||||
{
|
||||
if (Nette\Utils\Validators::isBuiltinType($type)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue