src/Mutator/ReturnValue/IntegerNegation.php
public static function getMutation(array &$tokens, $index)
    {
        $tokenCount = count($tokens);
        for ($i=$index+1; $i < $tokenCount; $i++) {
            if (is_array($tokens[$i]) && $tokens[$i][0] == T_WHITESPACE) {
                continue;
            } elseif (is_array($tokens[$i]) && $tokens[$i][0] == T_LNUMBER) {
                // Dump the negation - string for negative ints
                if (self::getPreviousToken($tokens, $i) == '-') {
                    $tokens[$i-1] = [
                        T_WHITESPACE,
                        ''
                    ];
                    break;
                }
                // otherwise multiply by -1 to make negative for positive ints
                $num = (integer) $tokens[$i][1];
                $replace = -1 * $num;
                $tokens[$i] = [
                    T_LNUMBER,
                    (string) $replace
                ];
                break;
            }
        }
    }
public static function getMutation(array &$tokens, $index)
    {
        $tokenCount = count($tokens);
        for ($i=$index+1; $i < $tokenCount; $i++) {
            if (is_array($tokens[$i]) && $tokens[$i][0] == T_WHITESPACE) {
                continue;
            } elseif (is_array($tokens[$i]) && $tokens[$i][0] == T_LNUMBER) {
                // Dump the negation - string for negative ints
                if (self::getPreviousToken($tokens, $i) == '-') {
                    $tokens[$i-1] = [
                        T_WHITESPACE,
                        ''
                    ];
                    break;
                }
                // otherwise multiply by -1 to make negative for positive ints
                $num = (integer) $tokens[$i][1];
                $replace = -1 * $num;
                $tokens[$i] = [
                    T_LNUMBER,
                    (string) $replace
                ];
                break;
            }
        }
    }
public static function getMutation ( array & $ tokens , $ index ) { $ tokenCount = count ( $ tokens ) ; for ( $ i = $ index + 1 ; $ i < $ tokenCount ; $ i ++ ) { if ( is_array ( $ tokens [ $ i ] ) && $ tokens [ $ i ] [ 0 ] == T_WHITESPACE ) { continue ; } elseif ( is_array ( $ tokens [ $ i ] ) && $ tokens [ $ i ] [ 0 ] == T_LNUMBER ) { // Dump the negation - string for negative ints if ( self :: getPreviousToken ( $ tokens , $ i ) == '-' ) { $ tokens [ $ i - 1 ] = [ T_WHITESPACE , '' ] ; break ; } // otherwise multiply by -1 to make negative for positive ints $ num = ( integer ) $ tokens [ $ i ] [ 1 ] ; $ replace = - 1 * $ num ; $ tokens [ $ i ] = [ T_LNUMBER , ( string ) $ replace ] ; break ; } } }
Replace any integer with its sign inverted (i.e. multiply by -1)

@param array $tokens
@param int $index
@return array
Replace any integer with its sign inverted ( i . e . multiply by - 1 )