li3_docs\doc\Docblock::_parseTags()

protected method

Parses @<tagname> docblock tags and their descriptions from a docblock.

See the $tags property for the list of supported tags.

Parameters

  • string $string

    The string to be parsed for tags

Returns

array

Returns an array where each docblock tag is a key name, and the corresponding values are either strings (if one of each tag), or arrays (if multiple of the same tag).

Source

	protected function _parseTags($string) {
		$string = trim($string);

		$result = preg_split('/\n@(?P<type>[a-z]+)/msi', "\n$string", -1, PREG_SPLIT_DELIM_CAPTURE);
		$tags = array();

		for ($i = 1; $i < count($result) - 1; $i += 2) {
			$tag = trim(strtolower($result[$i]));
			$description = trim($result[$i + 1]);

			switch ($tag) {
				case 'param':
					$tags[$tag][] = $this->_parseTag($description, [
						'type', 'name', 'description'
					]);
				break;
				case 'return':
					$tags[$tag][] = $this->_parseTag($description, [
						'type', 'description'
					]);
				break;
				case 'see':
					$tags[$tag][] = $this->_parseTag($description, [
						'symbol', 'description'
					]);
				break;
				case 'link':
					$tags[$tag][] = $this->_parseTag($description, [
						'url', 'description'
					]);
				break;
				default:
					$tags[$tag][] = compact('description');
				break;
			}
		}
		return $tags;
	}