public static function encodeSigned(string &$buf, int $x): int
    {
        $ux = $x << 1;
        if ($x < 0) {
            $ux = ~$ux;
        }
        return self::encodeUnsigned($buf, $ux);
    }
public static function encodeSigned(string &$buf, int $x): int
    {
        $ux = $x << 1;
        if ($x < 0) {
            $ux = ~$ux;
        }
        return self::encodeUnsigned($buf, $ux);
    }
public static function encodeSigned ( string & $ buf , int $ x ) : int { $ ux = $ x << 1 ; if ( $ x < 0 ) { $ ux = ~ $ ux ; } return self :: encodeUnsigned ( $ buf , $ ux ) ; }
Varint encode as signed integer.

@param string $buf bytestring to hold varint encoding of $x.
@param int $x the signed integer to varint encode.
@return int number of bytes written to buf.
Varint encode as signed integer .