Final Class yii\apidoc\helpers\TypeHelper
| Inheritance | yii\ |
|---|---|
| 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\ |
|
| getTypesByAggregatedType() | yii\ |
Method Details
| public static \ | ||
| $type | \ |
|
| return | \ |
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 \ | ||
| $compound | \ |
|
public static function getTypesByAggregatedType(AggregatedType $compound): array
{
$types = [];
foreach ($compound as $type) {
$types[] = $type;
}
return $types;
}