/** * Execute the command. * * @param string $pattern * @param string $usageType Find tags of type 'reference' or 'definition' (default) * @param bool $ignoreCase Case sentitive search (optional) * @param string $tagType Filter by tag type (optional) * @param string $format Output format * @return string */ public function findByPattern($pattern, $usageType = PhpTags\Tag::DEFINITION, $ignoreCase = true, $tagType = null, $format = null) { if ($tagType === 'any') { $tagType = null; } $tags = $this->database->findByPattern($pattern, $usageType, $ignoreCase, $tagType); foreach ($tags as $index => $tag) { // Usage type is part of the query, no need to return it. unset($tag['usage_type']); foreach ($tag as $field => $value) { $tag[$field] = $this->escapeString($tag[$field]); } $tags[$index] = $tag; } switch ($format) { case self::FORMAT_CTAGS: return $this->formatCtags($tags); case self::FORMAT_LISP: return $this->formatLisp($tags); default: return $this->formatTabSeparated($tags); } }