PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertFixer::getAssertCandidate PHP Method

getAssertCandidate() private method

private getAssertCandidate ( Tokens $tokens, integer $assertCallIndex ) : integer | int[]
$tokens PhpCsFixer\Tokenizer\Tokens
$assertCallIndex integer Token index of assert method call
return integer | int[] indexes of assert call, test call and positive flag, or last index checked
    private function getAssertCandidate(Tokens $tokens, $assertCallIndex)
    {
        $content = strtolower($tokens[$assertCallIndex]->getContent());
        if ('asserttrue' === $content) {
            $isPositive = 1;
        } elseif ('assertfalse' === $content) {
            $isPositive = 0;
        } else {
            return $assertCallIndex;
        }
        // test candidate for simple calls like: ([\]+'some fixable call'(...))
        $assertCallOpenIndex = $tokens->getNextMeaningfulToken($assertCallIndex);
        if (!$tokens[$assertCallOpenIndex]->equals('(')) {
            return $assertCallIndex;
        }
        $testDefaultNamespaceTokenIndex = false;
        $testIndex = $tokens->getNextMeaningfulToken($assertCallOpenIndex);
        if (!$tokens[$testIndex]->isGivenKind(array(T_EMPTY, T_STRING))) {
            if (!$tokens[$testIndex]->isGivenKind(T_NS_SEPARATOR)) {
                return $testIndex;
            }
            $testDefaultNamespaceTokenIndex = $testIndex;
            $testIndex = $tokens->getNextMeaningfulToken($testIndex);
        }
        $testOpenIndex = $tokens->getNextMeaningfulToken($testIndex);
        if (!$tokens[$testOpenIndex]->equals('(')) {
            return $testOpenIndex;
        }
        $testCloseIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $testOpenIndex);
        $assertCallCloseIndex = $tokens->getNextMeaningfulToken($testCloseIndex);
        if (!$tokens[$assertCallCloseIndex]->equalsAny(array(')', ','))) {
            return $assertCallCloseIndex;
        }
        return array($isPositive, $assertCallIndex, $assertCallOpenIndex, $testDefaultNamespaceTokenIndex, $testIndex, $testOpenIndex, $testCloseIndex, $assertCallCloseIndex);
    }