Final Class yii\apidoc\helpers\TypeHelper
| Inheritance | yii\apidoc\helpers\TypeHelper |
|---|---|
| Source Code | https://github.com/yiisoft/yii2-apidoc/blob/master/helpers/TypeHelper.php |
An auxiliary class for working with types.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| getPossibleTypesByConditionalType() | yii\apidoc\helpers\TypeHelper | |
| getTypesByAggregatedType() | yii\apidoc\helpers\TypeHelper |
Method Details
| 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);
}
| 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;
}