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

Hudson commented on THRIFT-1926:
--------------------------------

FAILURE: Integrated in Thrift #1201 (See 
[https://builds.apache.org/job/Thrift/1201/])
THRIFT-1926 PHP Constant Generation Refactoring (jensg: rev 
bc2ca4e5d76486729b5ebc0e5318b822cd87a438)
* compiler/cpp/src/generate/t_php_generator.cc
* lib/php/lib/Thrift/Type/TConstant.php


> PHP Constant Generation Refactoring
> -----------------------------------
>
>                 Key: THRIFT-1926
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1926
>             Project: Thrift
>          Issue Type: Improvement
>          Components: PHP - Compiler, PHP - Library
>            Reporter: Xavier HAUSHERR
>            Assignee: Jens Geyer
>              Labels: constant, php
>             Fix For: 0.9.2
>
>         Attachments: 0001-PHP-Replace-constant-Generation.patch
>
>
> When I have added PHP namespace, one point was missing from my refactoring: 
> the constants.
> Actually, PHP constants are generated into $GLOBALS because PHP cannot 
> generate constants for array or object with the function "define".
> But there is some problems:
> - Add vars in $GLOBALS is not a good pratice
> - These vars are not constant because user can modify them
> - Object constants instanciate a new object everytime the constant is call
> So I have added a new PHP Class in library called TConstant. The goal of this 
> class which is a Singleton, is to isolate Constant, and instanciate them 
> on-demand (only one time) in static properties. There is no setter so 
> constants cannot be edited and the class is abstract.
> I have edited the PHP generator to create those constants given to the 
> definition file. Every constant create a static property and an init method 
> in a final class called Constant in the definition Namespace.
> To get a constant, you just have to write:
> \MyDefinitionNamepace\Constant::get('CONSTANT_NAME');
> If the constant doesn't exists, it throws a Fatal error like it is done in 
> PHP when you call a static property which doesn't exists. Maybe we can add an 
> exception.
> I have attached a diff patch made from the 
> c613cd2d9bc01ee4eb43a3d40a8691c736f7a316 commit (Thrift-1846:Restore socket.h 
> header to support builds with Android NDK). Because you aren't not in SVN 
> anymore, I don't know how to send you this patch, I hope this one is good.
> I hope you like my patch. 



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to