src/Standards/BestIt/Sniffs/DocTags/AbstractRequiredTagsSniff.php
private function checkAndRegisterTagMaximumCounts(): void
    {
        $allTags = $this->getAllTags();
        $checkedTags = [];
        $tagRules = $this->getRulesWithRequirement('max');

        array_walk(
            $allTags,
            // TODO: Removed Duplicates
            function (array $tag, int $tagPos) use (&$checkedTags, $tagRules): void {
                $tagContent = substr($tag['content'], 1);

                if (!in_array($tagContent, $checkedTags)) {
                    $checkedTags[] = $tagContent;

                    $tagCount = count($this->findTokensForTag($tagContent));
                    $maxCount = @$tagRules[$tagContent]['max'] ?? 0;

                    if ($maxCount && ($tagCount > $maxCount)) {
                        $this->file->addError(
                            self::MESSAGE_TAG_OCCURRENCE_MAX,
                            $tagPos,
                            // We use an error code containing the tag name because we can't configure this rules from
                            // the outside and need  specific code to exclude the rule for this special tag.
                            static::CODE_TAG_OCCURRENCE_MAX_PREFIX . ucfirst($tagContent),
                            [
                                $tagContent,
                                $maxCount,
                                $tagCount
                            ]
                        );
                    }
                }
            }
        );
    }
private function checkAndRegisterTagMaximumCounts(): void
    {
        $allTags = $this->getAllTags();
        $checkedTags = [];
        $tagRules = $this->getRulesWithRequirement('max');

        array_walk(
            $allTags,
            // TODO: Removed Duplicates
            function (array $tag, int $tagPos) use (&$checkedTags, $tagRules): void {
                $tagContent = substr($tag['content'], 1);

                if (!in_array($tagContent, $checkedTags)) {
                    $checkedTags[] = $tagContent;

                    $tagCount = count($this->findTokensForTag($tagContent));
                    $maxCount = @$tagRules[$tagContent]['max'] ?? 0;

                    if ($maxCount && ($tagCount > $maxCount)) {
                        $this->file->addError(
                            self::MESSAGE_TAG_OCCURRENCE_MAX,
                            $tagPos,
                            // We use an error code containing the tag name because we can't configure this rules from
                            // the outside and need  specific code to exclude the rule for this special tag.
                            static::CODE_TAG_OCCURRENCE_MAX_PREFIX . ucfirst($tagContent),
                            [
                                $tagContent,
                                $maxCount,
                                $tagCount
                            ]
                        );
                    }
                }
            }
        );
    }
private function checkAndRegisterTagMaximumCounts ( ) : void { $ allTags = $ this -> getAllTags ( ) ; $ checkedTags = [ ] ; $ tagRules = $ this -> getRulesWithRequirement ( 'max' ) ; array_walk ( $ allTags , // TODO: Removed Duplicates function ( array $ tag , int $ tagPos ) use ( & $ checkedTags , $ tagRules ) : void { $ tagContent = substr ( $ tag [ 'content' ] , 1 ) ; if ( ! in_array ( $ tagContent , $ checkedTags ) ) { $ checkedTags [ ] = $ tagContent ; $ tagCount = count ( $ this -> findTokensForTag ( $ tagContent ) ) ; $ maxCount = @ $ tagRules [ $ tagContent ] [ 'max' ] ?? 0 ; if ( $ maxCount && ( $ tagCount > $ maxCount ) ) { $ this -> file -> addError ( self :: MESSAGE_TAG_OCCURRENCE_MAX , $ tagPos , // We use an error code containing the tag name because we can't configure this rules from // the outside and need  specific code to exclude the rule for this special tag. static :: CODE_TAG_OCCURRENCE_MAX_PREFIX . ucfirst ( $ tagContent ) , [ $ tagContent , $ maxCount , $ tagCount ] ) ; } } } ) ; }
Loads the rules with amax rule and checks if there are more tags than allowed.

@return void
Loads the rules with amax rule and checks if there are more tags than allowed .