You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Alex Medvedev (JIRA)" <ji...@apache.org> on 2014/11/21 18:02:34 UTC

[jira] [Comment Edited] (THRIFT-1905) Struct names with underscores get mangled in PHP compiled output

    [ https://issues.apache.org/jira/browse/THRIFT-1905?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14221126#comment-14221126 ] 

Alex Medvedev edited comment on THRIFT-1905 at 11/21/14 5:02 PM:
-----------------------------------------------------------------

+1 

This problem makes factually impossible use of underscores in struct names since underscores get stripped inside all the service method type hints (and in interface too), but generated structs itself have original underscores untouched. For example Test_SQL_Row class (which refers to struct Test_SQL_Row from original Tim Behrendsen's example) can be found inside the generates Types.php file. This behavior leads to type mismatch. 

May be we can dispose [usage of classify function in compiler|https://github.com/apache/thrift/blob/16a23a6618754a5a87aeb8df99a72516b0272fb3/compiler/cpp/src/generate/t_php_generator.cc#L2370] in order to translate original struct names in generated code?


was (Author: fduch):
+1 

This problem makes factually impossible use of underscores in struct names since underscores get stripped inside all the service method type hints (and in interface to), but generated structs itself have original underscores untouched. For example Test_SQL_Row class (which refers to struct Test_SQL_Row from original Tim Behrendsen's example) can be found inside the generates Types.php file. This behavior leads to type mismatch. 

May be we can dispose [usage of classify function in compiler|https://github.com/apache/thrift/blob/16a23a6618754a5a87aeb8df99a72516b0272fb3/compiler/cpp/src/generate/t_php_generator.cc#L2370] in order to translate original struct names in generated code?

> Struct names with underscores get mangled in PHP compiled output
> ----------------------------------------------------------------
>
>                 Key: THRIFT-1905
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1905
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Compiler
>    Affects Versions: 0.9
>         Environment: Centos 6.4
>            Reporter: Tim Behrendsen
>
> When compiling a thrift file containing a struct name with underscores, the underscores get stripped out in the name if the struct is used as a type hint in a function definition.
> EXAMPLE THRIFT FILE
> ------------------------------------------------------------------
> {noformat}
> namespace php TEST
> struct Test_SQL_Row {
>     1: map<string,string> row
> }
> service New_Service {
>     i16 Tester(1:Test_SQL_Row row),
> }
> {noformat}
> ------------------------------------------------------------------
> SNIPPET FROM COMPILED OUTPUT
> Command: thrift -r --gen php bad.thrift
> ------------------------------------------------------------------
> {noformat}
>   public function Tester(\TEST\TestSQLRow $row)
>   {
>     $this->send_Tester($row);
>     return $this->recv_Tester();
>   }
> {noformat}
> ------------------------------------------------------------------



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)