Factory method for generating FileTokens instances for all feature files in a plugin.

@param array $tags

@return FileTokens[]
960822
protected function behatTagsFactory(array $tags)
    {
        $fileTokens = [];

        $files = Finder::create()->files()->in($this->plugin->directory)->path('tests/behat')->name('*.feature')->getIterator();
        foreach ($files as $file) {
            $fileTokens[] = FileTokens::create($file->getRelativePathname())->mustHaveAll($tags);
        }

        return $fileTokens;
    }
1212675
protected function createSegments(array $tokens) : array
    {
        // Stack of opened tags.
        $active = new TagStack();

        return array_reduce($tokens, function (array $segments, $token) use ($active) {
            if ($token instanceof TagToken) {
                /** @var TagToken $token */
                if ($token->isOpening()) {
                    // If tag token is opening, add tag to the stack.
                    $active->push(Tag::createFromToken($token));
                } else {
                    // If tag token is closing, find matching tag in the stack.
                    $tagName = $token->getTagName();
                    $isFound = $active->removeLast($tagName);
                    if (!$isFound) {
                        // If not found, return tag token as a text.
                        $text = $token->getRawText();
                        $tags = $active->asArray();
                        $segments[] = new TextSegment($text, $tags);
                    }
                }
            } else {
                // Return text segment with currently active tags.
                /** @var TextToken $token */
                $text = $token->getRawText();
                $tags = $active->asArray();
                $segments[] = new TextSegment($text, $tags);
            }

            return $segments;
        }, []);
    }
324596
public static function parseDelimitedTags($tags): array
    {
        if (is_string($tags) && mb_strpos($tags, static::$tagsDelimiter) !== false) {
            $delimiter = preg_quote(static::$tagsDelimiter, '#');
            $tags = array_map('trim', preg_split("#[{$delimiter}]#", $tags, -1, PREG_SPLIT_NO_EMPTY));
        }

        return array_unique(array_filter((array) $tags));
    }
666001
private function getContextFromTags(array $tags)
    {
        return array_filter(array_map(static function (array $attribute) {
            if (\array_key_exists('context', $attribute) && \is_string($attribute['context'])) {
                return $attribute['context'];
            }

            return null;
        }, $tags));
    }
681518
public function getEvents(array $tags = []): array
    {
        if ($tags === []) {
            return $this->events;
        }

        return array_filter($this->events, function (ScheduleEvent $event) use ($tags) {
            return array_intersect($event->getTags(), $tags) === $tags;
        });
    }
582747
private function _mangleTags($tags)
    {
        foreach ($tags as $i => $tag) {
            $tags[$i] = $this->_mangleTag($tag);
        }
        return $tags;
    }
1032108
public function transform($tags)
    {
        // die(var_dump($tags));
        if (null === $tags) {
            return null;
        }
        $texts = [];

        foreach ($tags as $tag) {
            $texts[] = $tag->getText();
        }

        return $texts;
    }
351174
protected function getFileResponses(array $tags)
    {
        // avoid "holes" in the keys of the filtered array, by using array_values on the filtered array
        $responseFileTags = array_values(
            array_filter($tags, function ($tag) {
                return $tag instanceof Tag && strtolower($tag->getName()) === 'responsefile';
            })
        );

        if (empty($responseFileTags)) {
            return;
        }

        return array_map(function (Tag $responseFileTag) {
            preg_match('/^(\d{3})?\s?([\S]*[\s]*?)(\{.*\})?$/', $responseFileTag->getContent(), $result);
            $status = $result[1] ?: 200;
            $content = $result[2] ? file_get_contents(storage_path(trim($result[2])), true) : '{}';
            $json = ! empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}';
            $merged = array_merge(json_decode($content, true), json_decode($json, true));

            return new JsonResponse($merged, (int) $status);
        }, $responseFileTags);
    }
165880
public function findIdentifiersByTag($tag)
    {
        $tagsFiles = \glob(GeneralUtility::getFileAbsFileName(self::RELATIVE_STORAGE_FOLDER) . '*/*/*' . self::FILE_EXTENSION_TAG);
        $identifiers = [];
        foreach ($tagsFiles as $tagsFile) {
            if (false !== \mb_strpos(\file_get_contents($tagsFile), '|' . $tag . '|')) {
                $identifiers[] = \file_get_contents(\str_replace(self::FILE_EXTENSION_TAG, self::FILE_EXTENSION_IDENTIFIER, $tagsFile));
            }
        }

        return $identifiers;
    }
1202141
public static function indexableString(array $tags) {
        $tagstr = '';

        for ($i = 0; $i < func_num_args(); $i++) {
            $tags = func_get_arg($i);

            if (is_array($tags))
                foreach($tags as $tag)
                    $tagstr .= $tag->getTagSlug().' '.$tag->getTagRoleDisplay().' '.$tag->getTagValueDisplay().' '.$tag->getTagLinkTitle().' ';
        }

        return trim($tagstr);
    }
1301825
protected function checkCacheTags(array $tags)
    {
        $invalidTags = array_diff(array_keys($tags), ['tagId', 'tagKeyword']);
        if (count($invalidTags) > 0) {
            throw new InvalidArgumentException(
                'cacheTags',
                'Unknown cache tag(s): ' . implode(', ', $invalidTags)
            );
        }

        return $tags;
    }
812188
public static function implode($tags) {
    $encoded_tags = array();
    foreach ($tags as $tag) {
      $encoded_tags[] = self::encode($tag);
    }
    return implode(', ', $encoded_tags);
  }
99011
public static function addTags(array $tags)
    {
        if (count($tags) === 0)
            return;

        $found = Tag::whereIn('tag', $tags)->pluck('tag')->all();

        foreach (array_diff($tags, $found) as $tag) {
            if (empty(trim($tag)) || strlen($tag) < 3)
                continue;

            try {
                $model = new Tag;
                $model->tag = trim($tag);
                $model->save();
            } catch (\Illuminate\Database\QueryException $e) {
                $context = [];
                $context['file'] = $e->getFile() ?: '';
                $context['line'] = $e->getLine() ?: '';
                $context['code'] = $e->getCode() ?: '';

                logger()->warning($e->getMessage(), $context);
            }
        }
    }
1172500
public static function getTokens(string $filename): array
    {
        $tokens = token_get_all(file_get_contents($filename));

        $line = 0;
        foreach ($tokens as &$token) {
            if (isset($token[self::LINE])) {
                $line = $token[self::LINE];
            }

            if (!is_array($token)) {
                $token = [$token, $token, $line];
            }

            unset($token);
        }

        return $tokens;
    }
990561
public function createForDocumentation(array $files): array
    {
        if (in_array(Constants::TEST_TYPE_DOCUMENTATION, $this->types)) {
            $definitions = [];
            foreach ($files as $file) {
                $key = $this->getTestGroupNameForDocumentationFile($file);
                $definitions[$key] = $this->collectDefinitionsForFile($file);
            }

            return $definitions;
        }

        return [];
    }
1240728
private function preProcessTags($tags): array
    {
        if (!$tags) {
            return $this->getRegistered();
        }

        if (is_string($tags)) {
            $tags = explode('|', $tags);
        }

        return array_filter($tags, [$this, 'isRegistered']);
    }
102651
protected function getTagInspectors(TagCollection $tags)
	{
		$tagInspectors = [];
		foreach ($tags as $tagName => $tag)
		{
			// Use the tag's template if applicable or XSLT's implicit default otherwise
			$template = (isset($tag->template)) ? $tag->template : '<xsl:apply-templates/>';
			$tagInspectors[$tagName] = new TemplateInspector($template);
		}

		return $tagInspectors;
	}