Final Class yii\apidoc\helpers\TypeHelper

Inheritanceyii\apidoc\helpers\TypeHelper
Source Code https://github.com/yiisoft/yii2-apidoc/blob/master/helpers/TypeHelper.php

An auxiliary class for working with types.

Method Details

Hide inherited methods

getPossibleTypesByConditionalType() public static method

public static \phpDocumentor\Reflection\Type[] getPossibleTypesByConditionalType ( \phpDocumentor\Reflection\PseudoTypes\Conditional|\phpDocumentor\Reflection\PseudoTypes\ConditionalForParameter $type )
$type \phpDocumentor\Reflection\PseudoTypes\Conditional|\phpDocumentor\Reflection\PseudoTypes\ConditionalForParameter
return \phpDocumentor\Reflection\Type[]

Possible unique types.

                public static function getPossibleTypesByConditionalType(Type $type): array
{
    $types = [];
    foreach ([$type->getIf(), $type->getElse()] as $innerType) {
        if ($innerType instanceof Conditional || $innerType instanceof ConditionalForParameter) {
            $types = array_merge($types, self::getPossibleTypesByConditionalType($innerType));
        } elseif ($innerType instanceof AggregatedType) {
            $types = array_merge($types, self::getTypesByAggregatedType($innerType));
        } else {
            $types[] = $innerType;
        }
    }
    $uniqueTypes = [];
    foreach ($types as $innerType) {
        $uniqueTypes[(string) $innerType] = $innerType;
    }
    return array_values($uniqueTypes);
}

            
getTypesByAggregatedType() public static method

public static \phpDocumentor\Reflection\Type[] getTypesByAggregatedType ( \phpDocumentor\Reflection\Types\AggregatedType $compound )
$compound \phpDocumentor\Reflection\Types\AggregatedType

                public static function getTypesByAggregatedType(AggregatedType $compound): array
{
    $types = [];
    foreach ($compound as $type) {
        $types[] = $type;
    }
    return $types;
}