本文整理匯總了PHP中Type::getItemType方法的典型用法代碼示例。如果您正苦於以下問題:PHP Type::getItemType方法的具體用法?PHP Type::getItemType怎麽用?PHP Type::getItemType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Type
的用法示例。
在下文中一共展示了Type::getItemType方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: accepts
public function accepts(Type $type) : bool
{
if ($type instanceof self) {
return $this->getItemType()->accepts($type->getItemType());
}
if ($type instanceof MixedType) {
return true;
}
if ($this->isNullable() && $type instanceof NullType) {
return true;
}
return false;
}
示例2: accepts
public function accepts(Type $type) : bool
{
if ($type instanceof IterableType) {
return $this->getItemType()->accepts($type->getItemType());
}
if ($type->getClass() !== null && $this->exists($type->getClass())) {
$classReflection = new \ReflectionClass($type->getClass());
return $classReflection->implementsInterface(\Traversable::class);
}
if ($type instanceof MixedType) {
return true;
}
if ($this->isNullable() && $type instanceof NullType) {
return true;
}
return false;
}
示例3: decideType
public static function decideType(\ReflectionType $reflectionType = null, Type $phpDocType = null, string $selfClass = null, bool $isVariadic = false) : Type
{
if ($reflectionType === null) {
return $phpDocType !== null ? $phpDocType : new MixedType(true);
}
$reflectionTypeString = (string) $reflectionType;
if ($isVariadic) {
$reflectionTypeString .= '[]';
}
$type = self::getTypeObjectFromTypehint($reflectionTypeString, $reflectionType->allowsNull(), $selfClass);
if ($phpDocType !== null) {
if ($type instanceof ArrayType && $phpDocType instanceof ArrayType) {
$type = new ArrayType($phpDocType->getItemType(), $type->isNullable() || $phpDocType->isNullable());
}
if ($type->accepts($phpDocType)) {
return $phpDocType;
}
}
return $type;
}