THRIFT-499. php: Thrift_protocol PHP extension does not handle signedness correctly

Cast all the number types to signed values before making PHP longs out of them.



git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@773974 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp b/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
index 399cbe6..76a8a44 100644
--- a/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
+++ b/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
@@ -441,23 +441,23 @@
     case T_BYTE: {
       uint8_t c;
       transport.readBytes(&c, 1);
-      RETURN_LONG(c);
+      RETURN_LONG((int8_t)c);
     }
     case T_I16: {
       uint16_t c;
       transport.readBytes(&c, 2);
-      RETURN_LONG(ntohs(c));
+      RETURN_LONG((int16_t)ntohs(c));
     }
     case T_I32: {
       uint32_t c;
       transport.readBytes(&c, 4);
-      RETURN_LONG(ntohl(c));
+      RETURN_LONG((int32_t)ntohl(c));
     }
     case T_U64:
     case T_I64: {
       uint64_t c;
       transport.readBytes(&c, 8);
-      RETURN_LONG(ntohll(c));
+      RETURN_LONG((int64_t)ntohll(c));
     }
     case T_DOUBLE: {
       union {