From 97264864df4e7c14d8a4323af6ad37e726c52ef9 Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Thu, 20 Dec 2007 03:23:27 +0000 Subject: [PATCH] is_a is deprecated, instanceof only takes vars or constants Summary: Solution, dummy static class var to use instanceof Reviewed By: dweatherford Test Plan: Regen'd some mobile code in trunk using this git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665401 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/generate/t_php_generator.cc | 4 +-- lib/php/src/protocol/TProtocol.php | 30 ++++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/compiler/cpp/src/generate/t_php_generator.cc b/compiler/cpp/src/generate/t_php_generator.cc index eeac91e4..5b3c979f 100644 --- a/compiler/cpp/src/generate/t_php_generator.cc +++ b/compiler/cpp/src/generate/t_php_generator.cc @@ -1336,7 +1336,7 @@ void t_php_generator::generate_deserialize_field(ofstream &out, generate_deserialize_container(out, type, name); } else if (type->is_base_type() || type->is_enum()) { - out << indent() << "if (is_a($input,'TBinaryProtocolAccelerated') && function_exists('thrift_protocol_binary_deserialize')) {" << endl; + out << indent() << "if (($input instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_binary_deserialize')) {" << endl; indent_up(); string ttype_name; if (type->is_enum()) { @@ -1496,7 +1496,7 @@ void t_php_generator::generate_deserialize_struct(ofstream &out, void t_php_generator::generate_deserialize_container(ofstream &out, t_type* ttype, string prefix) { - out << indent() << "if (is_a($input, 'TBinaryProtocolAccelerated') && function_exists('thrift_protocol_binary_deserialize'))" << endl; + out << indent() << "if (($input instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_binary_deserialize'))" << endl; scope_up(out); string ttype_name; diff --git a/lib/php/src/protocol/TProtocol.php b/lib/php/src/protocol/TProtocol.php index 658e54cc..7e736d5f 100644 --- a/lib/php/src/protocol/TProtocol.php +++ b/lib/php/src/protocol/TProtocol.php @@ -39,6 +39,12 @@ class TProtocolException extends TException { * Protocol base class module. */ abstract class TProtocol { + // The below may seem silly, but it is to get around the problem that the + // "instanceof" operator can only take in a T_VARIABLE and not a T_STRING + // or T_CONSTANT_ENCAPSED_STRING. Using "is_a()" instead of "instanceof" is + // a workaround but is deprecated in PHP5. This is used in the generated + // deserialization code. + static $TBINARYPROTOCOLACCELERATED = 'TBinaryProtocolAccelerated'; /** * Underlying transport @@ -63,7 +69,7 @@ abstract class TProtocol { return $this->trans_; } - /** + /** * Writes the message header * * @param string $name Function name @@ -112,19 +118,19 @@ abstract class TProtocol { public abstract function writeMapBegin($keyType, $valType, $size); public abstract function writeMapEnd(); - + public abstract function writeListBegin($elemType, $size); - + public abstract function writeListEnd(); public abstract function writeSetBegin($elemType, $size); public abstract function writeSetEnd(); - + public abstract function writeBool($bool); public abstract function writeByte($byte); - + public abstract function writeI16($i16); public abstract function writeI32($i32); @@ -150,7 +156,7 @@ abstract class TProtocol { public abstract function readMessageEnd(); public abstract function readStructBegin(&$name); - + public abstract function readStructEnd(); public abstract function readFieldBegin(&$name, &$fieldType, &$fieldId); @@ -162,17 +168,17 @@ abstract class TProtocol { public abstract function readMapEnd(); public abstract function readListBegin(&$elemType, &$size); - + public abstract function readListEnd(); public abstract function readSetBegin(&$elemType, &$size); - + public abstract function readSetEnd(); public abstract function readBool(&$bool); - + public abstract function readByte(&$byte); - + public abstract function readI16(&$i16); public abstract function readI32(&$i32); @@ -343,7 +349,7 @@ abstract class TProtocol { } default: return 0; - } + } } } @@ -358,6 +364,6 @@ interface TProtocolFactory { */ public function getProtocol($trans); } - + ?> -- 2.17.1