<commit_before><?php declare(strict_types=1);

namespace Symplify\TokenRunner\DocBlock;

use Nette\Utils\Strings;
use phpDocumentor\Reflection\Types\Array_;
use phpDocumentor\Reflection\Types\Mixed_;
use phpDocumentor\Reflection\Types\Object_;
use phpDocumentor\Reflection\Types\String_;

final class ArrayResolver
{
    public static function resolveArrayType(string $originalContent, Array_ $arrayType, string $tagName, ?string $propertyName = null): string
    {
        if ($arrayType->getValueType() instanceof Mixed_) {
            $matched = self::matchArrayOrMixedAnnotation($originalContent, $tagName, $propertyName);
            if ($matched) {
                return $matched['type'];
            }
        }

        if ($arrayType->getValueType() instanceof Array_) {
            return self::resolveArrayType($originalContent, $arrayType->getValueType(), $tagName, $propertyName);
        }

        if ($arrayType->getValueType() instanceof String_ ||
            $arrayType->getValueType() instanceof Object_
        ) {
            return (string) $arrayType->getValueType() . '[]';
        }

        return 'array';
    }

    /**
     * Matches:
     *
     * - @_param array $propertyName
     * - @_param mixed[] $propertyName
     * - @_return array
     * - @_return mixed[]
     *
     * @return mixed[]|null
     */
    private static function matchArrayOrMixedAnnotation(
        string $originalContent,
        string $tagName,
        ?string $propertyName = null
    ): ?array {
        $mask = sprintf('@%s\s+(?<type>array\[\]|array|mixed\[\])', $tagName);
        if ($propertyName) {
            $mask .= sprintf('\s+\$%s', $propertyName);
        }

        return Strings::match($originalContent, '#' . $mask . '#');
    }
}
<commit_msg>fix cs<commit_after><?php declare(strict_types=1);

namespace Symplify\TokenRunner\DocBlock;

use Nette\Utils\Strings;
use phpDocumentor\Reflection\Types\Array_;
use phpDocumentor\Reflection\Types\Mixed_;
use phpDocumentor\Reflection\Types\Object_;
use phpDocumentor\Reflection\Types\String_;

final class ArrayResolver
{
    public static function resolveArrayType(
        string $originalContent,
        Array_ $arrayType,
        string $tagName,
        ?string $propertyName = null
    ): string {
        if ($arrayType->getValueType() instanceof Mixed_) {
            $matched = self::matchArrayOrMixedAnnotation($originalContent, $tagName, $propertyName);
            if ($matched) {
                return $matched['type'];
            }
        }

        if ($arrayType->getValueType() instanceof Array_) {
            return self::resolveArrayType($originalContent, $arrayType->getValueType(), $tagName, $propertyName);
        }

        if ($arrayType->getValueType() instanceof String_ ||
            $arrayType->getValueType() instanceof Object_
        ) {
            return (string) $arrayType->getValueType() . '[]';
        }

        return 'array';
    }

    /**
     * Matches:
     *
     * - @_param array $propertyName
     * - @_param mixed[] $propertyName
     * - @_return array
     * - @_return mixed[]
     *
     * @return mixed[]|null
     */
    private static function matchArrayOrMixedAnnotation(
        string $originalContent,
        string $tagName,
        ?string $propertyName = null
    ): ?array {
        $mask = sprintf('@%s\s+(?<type>array\[\]|array|mixed\[\])', $tagName);
        if ($propertyName) {
            $mask .= sprintf('\s+\$%s', $propertyName);
        }

        return Strings::match($originalContent, '#' . $mask . '#');
    }
}

{'fraction_non_alphanumeric': 0.1371396585502379, 'fraction_numerical': 0.000559753708368318, 'mean_word_length': 2.5668662674650697, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '3429329', 'n_tokens_mistral': 1016, 'n_tokens_neox': 993, 'n_words': 200}