Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Counts all elements in an array or in a Countable object
Alias sizeof
<?php count(Countable|array $value, int $mode = COUNT_NORMAL): int
<?php         if (isset($tokens[$hasVariable]['nested_parenthesis'])

            && \count($tokens[$hasVariable]['nested_parenthesis']) !== $targetNestingLevel

        ) {

                return false;

        }
<?php         $nestingLevel = 0;

        if ($asToken !== ($opener + 1) && isset($tokens[$opener + 1]['nested_parenthesis'])) {

            $nestingLevel = \count($tokens[$opener + 1]['nested_parenthesis']);

        }



        if ($this->isVariable($phpcsFile, ($opener + 1), $asToken, $nestingLevel) === true) {
<?php             $paramNames[$param['name']] = true;

        }



        if (\count($parameters) !== \count($paramNames)) {

            $phpcsFile->addError(

                'Functions can not have multiple parameters with the same name since PHP 7.0',

                $stackPtr,
<?php         $error = 'Declaring a required parameter after an optional one is deprecated since PHP 8.0. Parameter %s is optional, while parameter %s is required.';



        $paramCount    = \count($parameters);

        $lastKey       = ($paramCount - 1);

        $firstOptional = null;
<?php     public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)

    {

        $functionLc           = \strtolower($functionName);

        $parameterCount       = \count($parameters);

        $parameterOffsetFound = $parameterCount - 1;



        foreach ($this->targetFunctions[$functionLc] as $offset => $parameterDetails) {
<?php         }



        $parameters     = PassedParameters::getParameters($phpcsFile, $stackPtr);

        $parameterCount = \count($parameters);

        if ($parameterCount === 0) {

            return;

        }
<?php     public function processParameters(File $phpcsFile, $stackPtr, $functionName, $parameters)

    {

        $functionLc           = \strtolower($functionName);

        $parameterCount       = \count($parameters);

        $parameterOffsetFound = $parameterCount - 1;



        foreach ($this->targetFunctions[$functionLc] as $offset => $parameterDetails) {
<?php         $targetNestingLevel = 0;

        if (isset($tokens[$secondParam['start']]['nested_parenthesis'])) {

            $targetNestingLevel = \count($tokens[$secondParam['start']]['nested_parenthesis']);

        }



        $array = $phpcsFile->findNext(Collections::$arrayTokensBC, $secondParam['start'], ($secondParam['end'] + 1));
<?php             && ($tokens[$array]['code'] === \T_ARRAY

                || Arrays::isShortArray($phpcsFile, $array) === true)

        ) {

            if ((isset($tokens[$array]['nested_parenthesis']) === false && $targetNestingLevel === 0) || \count($tokens[$array]['nested_parenthesis']) === $targetNestingLevel) {

                $phpcsFile->addError(

                    'Constant arrays using define are not allowed in PHP 5.6 or earlier',

                    $array,
<?php                 $nestedParenthesisCount = 1;

                if (isset($tokens[$opener]['nested_parenthesis'])) {

                    $nestedParenthesisCount += \count($tokens[$opener]['nested_parenthesis']);

                }



                foreach ($params as $param) {
<?php                 $targetNestingLevel = 0;

                if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {

                    $targetNestingLevel = \count($tokens[$stackPtr]['nested_parenthesis']);

                }
<?php             $nestingLevel = 0;

            if (isset($tokens[$endPtr]['nested_parenthesis']) === true) {

                $nestingLevel = \count($tokens[$endPtr]['nested_parenthesis']);

            }

            if ($nestingLevel > $targetLevel) {

                return $endPtr;
<?php         $nestingLevel = 0;

        if ($close !== ($open + 1) && isset($tokens[$open + 1]['nested_parenthesis'])) {

            $nestingLevel = \count($tokens[$open + 1]['nested_parenthesis']);

        }



        if ($this->isVariable($phpcsFile, ($open + 1), $close, $nestingLevel) === true) {
<?php         }




        if (\count($listVars) !== \count(\array_unique($listVars))) {

            $phpcsFile->addError(

                'list() will assign variable from left-to-right since PHP 7.0. Ensure all variables in list() are unique to prevent unexpected results.',

                $stackPtr,
<?php         $hasTernary = $phpcsFile->findNext(\T_INLINE_THEN, $start, $end);

        if ($hasTernary !== false

            && isset($tokens[$start]['nested_parenthesis'], $tokens[$hasTernary]['nested_parenthesis'])

            && \count($tokens[$start]['nested_parenthesis']) === \count($tokens[$hasTernary]['nested_parenthesis'])

        ) {

            $start = ($hasTernary + 1);

        }