public static function decodeSigned(string $buf, int &$x): int
    {
        $ux = 0;
        $cnt = self::decodeUnsigned($buf, $ux);
        $x = $ux >> 1;
        if ($ux&1 != 0) {
            $x = ~$x;
        }
        return $cnt;
    }
public static function decodeSigned(string $buf, int &$x): int
    {
        $ux = 0;
        $cnt = self::decodeUnsigned($buf, $ux);
        $x = $ux >> 1;
        if ($ux&1 != 0) {
            $x = ~$x;
        }
        return $cnt;
    }
public static function decodeSigned ( string $ buf , int & $ x ) : int { $ ux = 0 ; $ cnt = self :: decodeUnsigned ( $ buf , $ ux ) ; $ x = $ ux >> 1 ; if ( $ ux & 1 != 0 ) { $ x = ~ $ x ; } return $ cnt ; }
Varint decode a signed integer.

@param string $buf bytestring holding varint encoding.
@param int $x integer to receive the decoded value.
@return int number of bytes read from buf.
Varint decode a signed integer .