<commit_before><?php

/**
 * MIT License
 * For full license information, please view the LICENSE file that was distributed with this source code.
 */

namespace Spryker\Sniffs\Commenting;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;
use Spryker\Tools\Traits\CommentingTrait;

/**
 * No invalid array/iterable tags used, and proper whitespace rules.
 * Basically type<x, y>. Also nesting, e.g. type<x, <type2<y, z>>.
 */
class DocBlockTagIterableSniff implements Sniff
{
    use CommentingTrait;

    /**
     * @inheritDoc
     */
    public function register(): array
    {
        return [
            T_DOC_COMMENT_TAG,
        ];
    }

    /**
     * @inheritDoc
     */
    public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        $content = $tokens[$stackPtr]['content'];

        $tag = $content;
        if (strpos($tag, ' ') !== false) {
            [$tag, $description] = explode(' ', $content, 2);
        }

        if (!preg_match('#^@(param|return|var)\b#i', $tag)) {
            return;
        }

        $possibleTextIndex = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $stackPtr + 1, $stackPtr + 3, false, null, true);
        if (!$possibleTextIndex) {
            return;
        }

        $this->assertType($phpcsFile, $possibleTextIndex, $tag);
    }

    /**
     * @param \PHP_CodeSniffer\Files\File $phpcsFile
     * @param int $stackPtr
     * @param string $tag
     *
     * @return void
     */
    protected function assertType(File $phpcsFile, int $stackPtr, string $tag): void
    {
        $tokens = $phpcsFile->getTokens();

        $content = $tokens[$stackPtr]['content'];
        if (!$this->containsIterableSyntax([$content])) {<commit_msg>Also allow psalm- and phpstan- ones to be fixed.<commit_after><?php

/**
 * MIT License
 * For full license information, please view the LICENSE file that was distributed with this source code.
 */

namespace Spryker\Sniffs\Commenting;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;
use Spryker\Tools\Traits\CommentingTrait;

/**
 * No invalid array/iterable tags used, and proper whitespace rules.
 * Basically type<x, y>. Also nesting, e.g. type<x, <type2<y, z>>.
 */
class DocBlockTagIterableSniff implements Sniff
{
    use CommentingTrait;

    /**
     * @inheritDoc
     */
    public function register(): array
    {
        return [
            T_DOC_COMMENT_TAG,
        ];
    }

    /**
     * @inheritDoc
     */
    public function process(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        $content = $tokens[$stackPtr]['content'];

        $tag = $content;
        if (strpos($tag, ' ') !== false) {
            [$tag, $description] = explode(' ', $content, 2);
        }

        if (!preg_match('#^@(?:[a-z]+-)?(?:param|return|var)\b#i', $tag)) {
            return;
        }

        $possibleTextIndex = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $stackPtr + 1, $stackPtr + 3, false, null, true);
        if (!$possibleTextIndex) {
            return;
        }

        $this->assertType($phpcsFile, $possibleTextIndex, $tag);
    }

    /**
     * @param \PHP_CodeSniffer\Files\File $phpcsFile
     * @param int $stackPtr
     * @param string $tag
     *
     * @return void
     */
    protected function assertType(File $phpcsFile, int $stackPtr, string $tag): void
    {
        $tokens = $phpcsFile->getTokens();

        $content = $tokens[$stackPtr]['content'];
        if (!$this->containsIterableSyntax([$content])) {
{'fraction_non_alphanumeric': 0.1447849311217318, 'fraction_numerical': 0.002249086308687096, 'mean_word_length': 2.515810276679842, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6341420', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1114, 'n_words': 254}