Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5082

Add a Class reference for PHP enum $_TSPEC

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.14.0
    • PHP - Compiler
    • None

    Description

      Currently we are losing the connection between the structure enum parameter value and the enum definition itself in PHP.

       

      The following thrift parameter which is using GroupType enum:

      5: required GroupType group_type;

      Is compiled to PHP:

      5 => array(
        'var' => 'group_type',
        'isRequired' => true,
        'type' => TType::I32,
       ),

       

      Which means that we cannot say on PHP side if that is a regular i32 or an enum.

      Why do I need that?

      I am using lowercase enum values instead of integers in database and on the frontend. Currently converting them by manually specifying the Enum Classes for enum parameters for each Structure which is not scalable, more difficult to maintain and growing over time. 

      This also makes it impossible to validate fields by Enum values on php side.

      Attachments

        Issue Links

          Activity

            People

              spwin Stanislav
              spwin Stanislav
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m