Composer data update
This commit is contained in:
61
www/vendor/phpdocumentor/type-resolver/src/PseudoTypes/IntegerRange.php
vendored
Normal file
61
www/vendor/phpdocumentor/type-resolver/src/PseudoTypes/IntegerRange.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\PseudoTypes;
|
||||
|
||||
use phpDocumentor\Reflection\PseudoType;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
|
||||
/**
|
||||
* Value Object representing the type 'int'.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class IntegerRange extends Integer implements PseudoType
|
||||
{
|
||||
/** @var string */
|
||||
private $minValue;
|
||||
|
||||
/** @var string */
|
||||
private $maxValue;
|
||||
|
||||
public function __construct(string $minValue, string $maxValue)
|
||||
{
|
||||
$this->minValue = $minValue;
|
||||
$this->maxValue = $maxValue;
|
||||
}
|
||||
|
||||
public function underlyingType(): Type
|
||||
{
|
||||
return new Integer();
|
||||
}
|
||||
|
||||
public function getMinValue(): string
|
||||
{
|
||||
return $this->minValue;
|
||||
}
|
||||
|
||||
public function getMaxValue(): string
|
||||
{
|
||||
return $this->maxValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rendered output of the Type as it would be used in a DocBlock.
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return 'int<' . $this->minValue . ', ' . $this->maxValue . '>';
|
||||
}
|
||||
}
|
||||
50
www/vendor/phpdocumentor/type-resolver/src/PseudoTypes/List_.php
vendored
Normal file
50
www/vendor/phpdocumentor/type-resolver/src/PseudoTypes/List_.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\PseudoTypes;
|
||||
|
||||
use phpDocumentor\Reflection\PseudoType;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\Types\Array_;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
use phpDocumentor\Reflection\Types\Mixed_;
|
||||
|
||||
/**
|
||||
* Value Object representing the type 'list'.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class List_ extends Array_ implements PseudoType
|
||||
{
|
||||
public function underlyingType(): Type
|
||||
{
|
||||
return new Array_();
|
||||
}
|
||||
|
||||
public function __construct(?Type $valueType = null)
|
||||
{
|
||||
parent::__construct($valueType, new Integer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rendered output of the Type as it would be used in a DocBlock.
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->valueType instanceof Mixed_) {
|
||||
return 'list';
|
||||
}
|
||||
|
||||
return 'list<' . $this->valueType . '>';
|
||||
}
|
||||
}
|
||||
39
www/vendor/phpdocumentor/type-resolver/src/PseudoTypes/NegativeInteger.php
vendored
Normal file
39
www/vendor/phpdocumentor/type-resolver/src/PseudoTypes/NegativeInteger.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\PseudoTypes;
|
||||
|
||||
use phpDocumentor\Reflection\PseudoType;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
|
||||
/**
|
||||
* Value Object representing the type 'int'.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class NegativeInteger extends Integer implements PseudoType
|
||||
{
|
||||
public function underlyingType(): Type
|
||||
{
|
||||
return new Integer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rendered output of the Type as it would be used in a DocBlock.
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return 'negative-int';
|
||||
}
|
||||
}
|
||||
47
www/vendor/phpdocumentor/type-resolver/src/PseudoTypes/Numeric_.php
vendored
Normal file
47
www/vendor/phpdocumentor/type-resolver/src/PseudoTypes/Numeric_.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\PseudoTypes;
|
||||
|
||||
use phpDocumentor\Reflection\PseudoType;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\Types\AggregatedType;
|
||||
use phpDocumentor\Reflection\Types\Compound;
|
||||
use phpDocumentor\Reflection\Types\Float_;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
|
||||
/**
|
||||
* Value Object representing the 'numeric' pseudo-type, which is either a numeric-string, integer or float.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class Numeric_ extends AggregatedType implements PseudoType
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
AggregatedType::__construct([new NumericString(), new Integer(), new Float_()], '|');
|
||||
}
|
||||
|
||||
public function underlyingType(): Type
|
||||
{
|
||||
return new Compound([new NumericString(), new Integer(), new Float_()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rendered output of the Type as it would be used in a DocBlock.
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return 'numeric';
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
|
||||
/**
|
||||
* Value Object representing the type 'string'.
|
||||
* Value Object representing the type 'int'.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace phpDocumentor\Reflection;
|
||||
|
||||
use ArrayIterator;
|
||||
use InvalidArgumentException;
|
||||
use phpDocumentor\Reflection\PseudoTypes\IntegerRange;
|
||||
use phpDocumentor\Reflection\PseudoTypes\List_;
|
||||
use phpDocumentor\Reflection\Types\Array_;
|
||||
use phpDocumentor\Reflection\Types\ArrayKey;
|
||||
use phpDocumentor\Reflection\Types\ClassString;
|
||||
@@ -37,8 +39,10 @@ use function array_values;
|
||||
use function class_exists;
|
||||
use function class_implements;
|
||||
use function count;
|
||||
use function current;
|
||||
use function end;
|
||||
use function in_array;
|
||||
use function is_numeric;
|
||||
use function key;
|
||||
use function preg_split;
|
||||
use function strpos;
|
||||
@@ -81,10 +85,12 @@ final class TypeResolver
|
||||
'non-empty-lowercase-string' => PseudoTypes\NonEmptyLowercaseString::class,
|
||||
'non-empty-string' => PseudoTypes\NonEmptyString::class,
|
||||
'numeric-string' => PseudoTypes\NumericString::class,
|
||||
'numeric' => PseudoTypes\Numeric_::class,
|
||||
'trait-string' => PseudoTypes\TraitString::class,
|
||||
'int' => Types\Integer::class,
|
||||
'integer' => Types\Integer::class,
|
||||
'positive-int' => PseudoTypes\PositiveInteger::class,
|
||||
'negative-int' => PseudoTypes\NegativeInteger::class,
|
||||
'bool' => Types\Boolean::class,
|
||||
'boolean' => Types\Boolean::class,
|
||||
'real' => Types\Float_::class,
|
||||
@@ -110,6 +116,7 @@ final class TypeResolver
|
||||
'parent' => Types\Parent_::class,
|
||||
'iterable' => Types\Iterable_::class,
|
||||
'never' => Types\Never_::class,
|
||||
'list' => PseudoTypes\List_::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -255,6 +262,8 @@ final class TypeResolver
|
||||
if ($classType !== null) {
|
||||
if ((string) $classType === 'class-string') {
|
||||
$types[] = $this->resolveClassString($tokens, $context);
|
||||
} elseif ((string) $classType === 'int') {
|
||||
$types[] = $this->resolveIntRange($tokens);
|
||||
} elseif ((string) $classType === 'interface-string') {
|
||||
$types[] = $this->resolveInterfaceString($tokens, $context);
|
||||
} else {
|
||||
@@ -271,6 +280,10 @@ final class TypeResolver
|
||||
} elseif ($token === self::OPERATOR_ARRAY) {
|
||||
end($types);
|
||||
$last = key($types);
|
||||
if ($last === null) {
|
||||
throw new InvalidArgumentException('Unexpected array operator');
|
||||
}
|
||||
|
||||
$lastItem = $types[$last];
|
||||
if ($lastItem instanceof Expression) {
|
||||
$lastItem = $lastItem->getValueType();
|
||||
@@ -315,7 +328,7 @@ final class TypeResolver
|
||||
);
|
||||
}
|
||||
} elseif (count($types) === 1) {
|
||||
return $types[0];
|
||||
return current($types);
|
||||
}
|
||||
|
||||
if ($compoundToken === '|') {
|
||||
@@ -477,6 +490,75 @@ final class TypeResolver
|
||||
return new ClassString($classType->getFqsen());
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves integer ranges
|
||||
*
|
||||
* @param ArrayIterator<int, (string|null)> $tokens
|
||||
*/
|
||||
private function resolveIntRange(ArrayIterator $tokens): Type
|
||||
{
|
||||
$tokens->next();
|
||||
|
||||
$token = '';
|
||||
$minValue = null;
|
||||
$maxValue = null;
|
||||
$commaFound = false;
|
||||
$tokenCounter = 0;
|
||||
while ($tokens->valid()) {
|
||||
$tokenCounter++;
|
||||
$token = $tokens->current();
|
||||
if ($token === null) {
|
||||
throw new RuntimeException(
|
||||
'Unexpected nullable character'
|
||||
);
|
||||
}
|
||||
|
||||
$token = trim($token);
|
||||
|
||||
if ($token === '>') {
|
||||
break;
|
||||
}
|
||||
|
||||
if ($token === ',') {
|
||||
$commaFound = true;
|
||||
}
|
||||
|
||||
if ($commaFound === false && $minValue === null) {
|
||||
if (is_numeric($token) || $token === 'max' || $token === 'min') {
|
||||
$minValue = $token;
|
||||
}
|
||||
}
|
||||
|
||||
if ($commaFound === true && $maxValue === null) {
|
||||
if (is_numeric($token) || $token === 'max' || $token === 'min') {
|
||||
$maxValue = $token;
|
||||
}
|
||||
}
|
||||
|
||||
$tokens->next();
|
||||
}
|
||||
|
||||
if ($token !== '>') {
|
||||
if (empty($token)) {
|
||||
throw new RuntimeException(
|
||||
'interface-string: ">" is missing'
|
||||
);
|
||||
}
|
||||
|
||||
throw new RuntimeException(
|
||||
'Unexpected character "' . $token . '", ">" is missing'
|
||||
);
|
||||
}
|
||||
|
||||
if (!$minValue || !$maxValue || $tokenCounter > 4) {
|
||||
throw new RuntimeException(
|
||||
'int<min,max> has not the correct format'
|
||||
);
|
||||
}
|
||||
|
||||
return new IntegerRange($minValue, $maxValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves class string
|
||||
*
|
||||
@@ -521,10 +603,11 @@ final class TypeResolver
|
||||
{
|
||||
$isArray = ((string) $classType === 'array');
|
||||
$isIterable = ((string) $classType === 'iterable');
|
||||
$isList = ((string) $classType === 'list');
|
||||
|
||||
// allow only "array", "iterable" or class name before "<"
|
||||
if (
|
||||
!$isArray && !$isIterable
|
||||
!$isArray && !$isIterable && !$isList
|
||||
&& (!$classType instanceof Object_ || $classType->getFqsen() === null)
|
||||
) {
|
||||
throw new RuntimeException(
|
||||
@@ -538,7 +621,7 @@ final class TypeResolver
|
||||
$keyType = null;
|
||||
|
||||
$token = $tokens->current();
|
||||
if ($token !== null && trim($token) === ',') {
|
||||
if ($token !== null && trim($token) === ',' && !$isList) {
|
||||
// if we have a comma, then we just parsed the key type, not the value type
|
||||
$keyType = $valueType;
|
||||
if ($isArray) {
|
||||
@@ -596,6 +679,10 @@ final class TypeResolver
|
||||
return new Iterable_($valueType, $keyType);
|
||||
}
|
||||
|
||||
if ($isList) {
|
||||
return new List_($valueType);
|
||||
}
|
||||
|
||||
if ($classType instanceof Object_) {
|
||||
return $this->makeCollectionFromObject($classType, $valueType, $keyType);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@ namespace phpDocumentor\Reflection\Types;
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class Array_ extends AbstractList
|
||||
class Array_ extends AbstractList
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user