芝麻web文件管理V1.00
编辑当前文件:/home/sditechnicalteam/public_html/vendor/nunomaduro/larastan/src/Support/CollectionHelper.php
isSuperTypeOf($type)->yes()) { return $this->getTypeFromEloquentCollection($type); } if ( (new ObjectType(Traversable::class))->isSuperTypeOf($type)->yes() || (new ObjectType(IteratorAggregate::class))->isSuperTypeOf($type)->yes() || (new ObjectType(Iterator::class))->isSuperTypeOf($type)->yes() ) { return $this->getTypeFromIterator($type); } } if (! $type->isArray()->yes()) { return new GenericObjectType(Collection::class, [$type->toArray()->getIterableKeyType(), $type->toArray()->getIterableValueType()]); } if ($type->isIterableAtLeastOnce()->no()) { return new GenericObjectType(Collection::class, [$keyType, new MixedType()]); } return new GenericObjectType(Collection::class, [ TypeUtils::generalizeType($type->getIterableKeyType(), GeneralizePrecision::lessSpecific()), TypeUtils::generalizeType($type->getIterableValueType(), GeneralizePrecision::lessSpecific()), ]); } private function getTypeFromEloquentCollection(TypeWithClassName $valueType): GenericObjectType { $keyType = TypeCombinator::union(new IntegerType(), new StringType()); $classReflection = $valueType->getClassReflection(); if ($classReflection === null) { return new GenericObjectType(Collection::class, [$keyType, new MixedType()]); } $innerValueType = $classReflection->getActiveTemplateTypeMap()->getType('TModel'); if ($classReflection->getName() === EloquentCollection::class || $classReflection->isSubclassOf(EloquentCollection::class)) { $keyType = new IntegerType(); } if ($innerValueType !== null) { return new GenericObjectType(Collection::class, [$keyType, $innerValueType]); } return new GenericObjectType(Collection::class, [$keyType, new MixedType()]); } private function getTypeFromIterator(TypeWithClassName $valueType): GenericObjectType { $keyType = TypeCombinator::union(new IntegerType(), new StringType()); $classReflection = $valueType->getClassReflection(); if ($classReflection === null) { return new GenericObjectType(Collection::class, [$keyType, new MixedType()]); } $templateTypes = array_values($classReflection->getActiveTemplateTypeMap()->getTypes()); if (count($templateTypes) === 1) { return new GenericObjectType(Collection::class, [$keyType, $templateTypes[0]]); } return new GenericObjectType(Collection::class, $templateTypes); } }