Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Won't Fix
-
None
-
None
-
Patch Available
Description
I've created patch for php code generator and for php library, which will allow you to use string in enums (these string will be converted from/to integers while receiving/sending).
Example:
// thrift definition
enum CheckService {
ping = 1,
ssh = 2,
http = 3,
telnet = 4,
}
Now, you can send as value 'ping' or 1, the protocol will always transfer I32 of value 1.
When receiving on other side, 1 is automatically converted to 'ping'.
By default, this patch has no effect. To turn on the conversion, you have to activate on whole thrift by
TBase::$allowEnumConversion = true;
or per struct MyStruct::$allowEnumConversion = true; which will turn on convertion for all enums directly accessible from this struct (but not in structs on deeper level)
(this patch includes patch for namespaces, I posted some days before)
Link 1 (php library patch): http://helemik.cz/juzna/opensource/php/thrift/p-enum.patch
Link 2 (php compiler patch): http://helemik.cz/juzna/opensource/php/thrift/p-enum2.patch
(Is it possible to join in to upstream? Please, someone "who's in" charge, concat me on my email or on IRC)
juzna