src/Fixer/PhpUnit/PhpUnitStrictFixer.php
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        $argumentsAnalyzer = new ArgumentsAnalyzer();

        foreach ($this->configuration['assertions'] as $methodBefore) {
            $methodAfter = self::$assertionMap[$methodBefore];

            for ($index = 0, $limit = $tokens->count(); $index < $limit; ++$index) {
                $methodIndex = $tokens->getNextTokenOfKind($index, [[T_STRING, $methodBefore]]);

                if (null === $methodIndex) {
                    break;
                }

                $operatorIndex = $tokens->getPrevMeaningfulToken($methodIndex);
                $referenceIndex = $tokens->getPrevMeaningfulToken($operatorIndex);
                if (
                    !($tokens[$operatorIndex]->equals([T_OBJECT_OPERATOR, '->']) && $tokens[$referenceIndex]->equals([T_VARIABLE, '$this']))
                    && !($tokens[$operatorIndex]->equals([T_DOUBLE_COLON, '::']) && $tokens[$referenceIndex]->equals([T_STRING, 'self']))
                    && !($tokens[$operatorIndex]->equals([T_DOUBLE_COLON, '::']) && $tokens[$referenceIndex]->equals([T_STATIC, 'static']))
                ) {
                    continue;
                }

                $openingParenthesisIndex = $tokens->getNextMeaningfulToken($methodIndex);
                $argumentsCount = $argumentsAnalyzer->countArguments(
                    $tokens,
                    $openingParenthesisIndex,
                    $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $openingParenthesisIndex)
                );

                if (2 === $argumentsCount || 3 === $argumentsCount) {
                    $tokens[$methodIndex] = new Token([T_STRING, $methodAfter]);
                }

                $index = $methodIndex;
            }
        }
    }
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        $argumentsAnalyzer = new ArgumentsAnalyzer();

        foreach ($this->configuration['assertions'] as $methodBefore) {
            $methodAfter = self::$assertionMap[$methodBefore];

            for ($index = 0, $limit = $tokens->count(); $index < $limit; ++$index) {
                $methodIndex = $tokens->getNextTokenOfKind($index, [[T_STRING, $methodBefore]]);

                if (null === $methodIndex) {
                    break;
                }

                $operatorIndex = $tokens->getPrevMeaningfulToken($methodIndex);
                $referenceIndex = $tokens->getPrevMeaningfulToken($operatorIndex);
                if (
                    !($tokens[$operatorIndex]->equals([T_OBJECT_OPERATOR, '->']) && $tokens[$referenceIndex]->equals([T_VARIABLE, '$this']))
                    && !($tokens[$operatorIndex]->equals([T_DOUBLE_COLON, '::']) && $tokens[$referenceIndex]->equals([T_STRING, 'self']))
                    && !($tokens[$operatorIndex]->equals([T_DOUBLE_COLON, '::']) && $tokens[$referenceIndex]->equals([T_STATIC, 'static']))
                ) {
                    continue;
                }

                $openingParenthesisIndex = $tokens->getNextMeaningfulToken($methodIndex);
                $argumentsCount = $argumentsAnalyzer->countArguments(
                    $tokens,
                    $openingParenthesisIndex,
                    $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $openingParenthesisIndex)
                );

                if (2 === $argumentsCount || 3 === $argumentsCount) {
                    $tokens[$methodIndex] = new Token([T_STRING, $methodAfter]);
                }

                $index = $methodIndex;
            }
        }
    }
protected function applyFix ( \ SplFileInfo $ file , Tokens $ tokens ) { $ argumentsAnalyzer = new ArgumentsAnalyzer ( ) ; foreach ( $ this -> configuration [ 'assertions' ] as $ methodBefore ) { $ methodAfter = self :: $ assertionMap [ $ methodBefore ] ; for ( $ index = 0 , $ limit = $ tokens -> count ( ) ; $ index < $ limit ; ++ $ index ) { $ methodIndex = $ tokens -> getNextTokenOfKind ( $ index , [ [ T_STRING , $ methodBefore ] ] ) ; if ( null === $ methodIndex ) { break ; } $ operatorIndex = $ tokens -> getPrevMeaningfulToken ( $ methodIndex ) ; $ referenceIndex = $ tokens -> getPrevMeaningfulToken ( $ operatorIndex ) ; if ( ! ( $ tokens [ $ operatorIndex ] -> equals ( [ T_OBJECT_OPERATOR , '->' ] ) && $ tokens [ $ referenceIndex ] -> equals ( [ T_VARIABLE , '$this' ] ) ) && ! ( $ tokens [ $ operatorIndex ] -> equals ( [ T_DOUBLE_COLON , '::' ] ) && $ tokens [ $ referenceIndex ] -> equals ( [ T_STRING , 'self' ] ) ) && ! ( $ tokens [ $ operatorIndex ] -> equals ( [ T_DOUBLE_COLON , '::' ] ) && $ tokens [ $ referenceIndex ] -> equals ( [ T_STATIC , 'static' ] ) ) ) { continue ; } $ openingParenthesisIndex = $ tokens -> getNextMeaningfulToken ( $ methodIndex ) ; $ argumentsCount = $ argumentsAnalyzer -> countArguments ( $ tokens , $ openingParenthesisIndex , $ tokens -> findBlockEnd ( Tokens :: BLOCK_TYPE_PARENTHESIS_BRACE , $ openingParenthesisIndex ) ) ; if ( 2 === $ argumentsCount || 3 === $ argumentsCount ) { $ tokens [ $ methodIndex ] = new Token ( [ T_STRING , $ methodAfter ] ) ; } $ index = $ methodIndex ; } } }
{@inheritdoc}
{