type; } /** * @return string[] */ protected static function extractTypeFromBody(string $body) : array { $type = ''; $nestingLevel = 0; for ($i = 0, $iMax = strlen($body); $i < $iMax; $i++) { $character = $body[$i]; if ($nestingLevel === 0 && trim($character) === '') { break; } $type .= $character; if (in_array($character, ['<', '(', '[', '{'])) { $nestingLevel++; continue; } if (in_array($character, ['>', ')', ']', '}'])) { $nestingLevel--; continue; } } $description = trim(substr($body, strlen($type))); return [$type, $description]; } }