reduce phpdocumentor/reflection-dockblock version
This commit is contained in:
parent
91c6940d42
commit
a6c994d8e3
5 changed files with 193 additions and 205 deletions
|
|
@ -3,7 +3,7 @@
|
|||
namespace Icefox\Data;
|
||||
|
||||
use Icefox\Data\Factories\RuleFactory;
|
||||
use phpDocumentor\Reflection\PseudoTypes\Generic;
|
||||
use phpDocumentor\Reflection\Types\Collection;
|
||||
|
||||
class CustomHandlers
|
||||
{
|
||||
|
|
@ -17,17 +17,11 @@ class CustomHandlers
|
|||
}
|
||||
|
||||
$type = $parameter->tag->getType();
|
||||
if (!$type instanceof Generic) {
|
||||
if (!$type instanceof Collection) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$subtypes = $type->getTypes();
|
||||
|
||||
if (count($subtypes) == 0) {
|
||||
return ['' => ['array']];
|
||||
}
|
||||
|
||||
$subtype = count($subtypes) == 1 ? $subtypes[0] : $subtypes[1];
|
||||
$subtype = $type->getValueType();
|
||||
|
||||
return $factory->mergeRules(
|
||||
['' => ['array']],
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ use Icefox\Data\Attributes\Flat;
|
|||
use Icefox\Data\ReflectionHelper;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use ReflectionNamedType;
|
||||
use phpDocumentor\Reflection\PseudoTypes\Generic;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\Types\AbstractList;
|
||||
use phpDocumentor\Reflection\Types\Collection;
|
||||
use phpDocumentor\Reflection\Types\Boolean;
|
||||
use phpDocumentor\Reflection\Types\Float_;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
|
|
@ -26,18 +26,8 @@ class ValueFactory
|
|||
$type = $type->getActualType();
|
||||
}
|
||||
|
||||
if ($type instanceof AbstractList) {
|
||||
if ($type instanceof Collection) {
|
||||
$innerType = $type->getValueType();
|
||||
$result = [];
|
||||
foreach ($rawValue as $key => $value) {
|
||||
$result[$key] = self::resolveAnnotatedValue($innerType, $value);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($type instanceof Generic) {
|
||||
$types = $type->getTypes();
|
||||
$innerType = count($types) === 2 ? $types[1] : $types[0];
|
||||
if (is_array($rawValue)) {
|
||||
$innerValues = [];
|
||||
foreach ($rawValue as $key => $value) {
|
||||
|
|
@ -51,6 +41,15 @@ class ValueFactory
|
|||
return new ($type->getFqsen()->__toString())($value);
|
||||
}
|
||||
|
||||
if ($type instanceof AbstractList) {
|
||||
$innerType = $type->getValueType();
|
||||
$result = [];
|
||||
foreach ($rawValue as $key => $value) {
|
||||
$result[$key] = self::resolveAnnotatedValue($innerType, $value);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($type instanceof Boolean) {
|
||||
return boolval($rawValue);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use ReflectionNamedType;
|
|||
use ReflectionParameter;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Param;
|
||||
use phpDocumentor\Reflection\PseudoTypes\Generic;
|
||||
use phpDocumentor\Reflection\Types\AbstractList;
|
||||
use phpDocumentor\Reflection\Types\ContextFactory;
|
||||
use phpDocumentor\Reflection\DocBlockFactory;
|
||||
|
|
@ -56,12 +55,7 @@ class ReflectionHelper
|
|||
return $type->getValueType()->__toString();
|
||||
}
|
||||
|
||||
if (!$type instanceof Generic) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$subtypes = $type->getTypes();
|
||||
return count($subtypes) > 1 ? $subtypes[1]->__toString() : $subtypes[0]->__toString();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function isListType(ParameterMeta $parameter): bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue