Commit f46a01d0 authored by Bo Yang's avatar Bo Yang

Exclude valid constant name from reserved name.

parent ddb9ef9c
...@@ -688,6 +688,8 @@ php_EXTRA_DIST= \ ...@@ -688,6 +688,8 @@ php_EXTRA_DIST= \
php/tests/proto/test_prefix.proto \ php/tests/proto/test_prefix.proto \
php/tests/proto/test_reserved_enum_lower.proto \ php/tests/proto/test_reserved_enum_lower.proto \
php/tests/proto/test_reserved_enum_upper.proto \ php/tests/proto/test_reserved_enum_upper.proto \
php/tests/proto/test_reserved_enum_value_lower.proto \
php/tests/proto/test_reserved_enum_value_upper.proto \
php/tests/proto/test_reserved_message_lower.proto \ php/tests/proto/test_reserved_message_lower.proto \
php/tests/proto/test_reserved_message_upper.proto \ php/tests/proto/test_reserved_message_upper.proto \
php/tests/proto/test_service.proto \ php/tests/proto/test_service.proto \
......
...@@ -934,5 +934,6 @@ const zend_class_entry* field_type_class( ...@@ -934,5 +934,6 @@ const zend_class_entry* field_type_class(
// Reserved name // Reserved name
bool is_reserved_name(const char* name); bool is_reserved_name(const char* name);
bool is_valid_constant_name(const char* name);
#endif // __GOOGLE_PROTOBUF_PHP_PROTOBUF_H__ #endif // __GOOGLE_PROTOBUF_PHP_PROTOBUF_H__
...@@ -840,79 +840,301 @@ class GeneratedClassTest extends TestBase ...@@ -840,79 +840,301 @@ class GeneratedClassTest extends TestBase
$m = new \Upper\PBVOID(); $m = new \Upper\PBVOID();
$m = new \Upper\PBITERABLE(); $m = new \Upper\PBITERABLE();
$m = \Lower_enum\NotAllowed::PBabstract; $m = new \Lower_enum\PBabstract();
$m = \Lower_enum\NotAllowed::PBand; $m = new \Lower_enum\PBand();
$m = \Lower_enum\NotAllowed::PBarray; $m = new \Lower_enum\PBarray();
$m = \Lower_enum\NotAllowed::PBas; $m = new \Lower_enum\PBas();
$m = \Lower_enum\NotAllowed::PBbreak; $m = new \Lower_enum\PBbreak();
$m = \Lower_enum\NotAllowed::PBcallable; $m = new \Lower_enum\PBcallable();
$m = \Lower_enum\NotAllowed::PBcase; $m = new \Lower_enum\PBcase();
$m = \Lower_enum\NotAllowed::PBcatch; $m = new \Lower_enum\PBcatch();
$m = \Lower_enum\NotAllowed::PBclass; $m = new \Lower_enum\PBclass();
$m = \Lower_enum\NotAllowed::PBclone; $m = new \Lower_enum\PBclone();
$m = \Lower_enum\NotAllowed::PBconst; $m = new \Lower_enum\PBconst();
$m = \Lower_enum\NotAllowed::PBcontinue; $m = new \Lower_enum\PBcontinue();
$m = \Lower_enum\NotAllowed::PBdeclare; $m = new \Lower_enum\PBdeclare();
$m = \Lower_enum\NotAllowed::PBdefault; $m = new \Lower_enum\PBdefault();
$m = \Lower_enum\NotAllowed::PBdie; $m = new \Lower_enum\PBdie();
$m = \Lower_enum\NotAllowed::PBdo; $m = new \Lower_enum\PBdo();
$m = \Lower_enum\NotAllowed::PBecho; $m = new \Lower_enum\PBecho();
$m = \Lower_enum\NotAllowed::PBelse; $m = new \Lower_enum\PBelse();
$m = \Lower_enum\NotAllowed::PBelseif; $m = new \Lower_enum\PBelseif();
$m = \Lower_enum\NotAllowed::PBempty; $m = new \Lower_enum\PBempty();
$m = \Lower_enum\NotAllowed::PBenddeclare; $m = new \Lower_enum\PBenddeclare();
$m = \Lower_enum\NotAllowed::PBendfor; $m = new \Lower_enum\PBendfor();
$m = \Lower_enum\NotAllowed::PBendforeach; $m = new \Lower_enum\PBendforeach();
$m = \Lower_enum\NotAllowed::PBendif; $m = new \Lower_enum\PBendif();
$m = \Lower_enum\NotAllowed::PBendswitch; $m = new \Lower_enum\PBendswitch();
$m = \Lower_enum\NotAllowed::PBendwhile; $m = new \Lower_enum\PBendwhile();
$m = \Lower_enum\NotAllowed::PBeval; $m = new \Lower_enum\PBeval();
$m = \Lower_enum\NotAllowed::PBexit; $m = new \Lower_enum\PBexit();
$m = \Lower_enum\NotAllowed::PBextends; $m = new \Lower_enum\PBextends();
$m = \Lower_enum\NotAllowed::PBfinal; $m = new \Lower_enum\PBfinal();
$m = \Lower_enum\NotAllowed::PBfor; $m = new \Lower_enum\PBfor();
$m = \Lower_enum\NotAllowed::PBforeach; $m = new \Lower_enum\PBforeach();
$m = \Lower_enum\NotAllowed::PBfunction; $m = new \Lower_enum\PBfunction();
$m = \Lower_enum\NotAllowed::PBglobal; $m = new \Lower_enum\PBglobal();
$m = \Lower_enum\NotAllowed::PBgoto; $m = new \Lower_enum\PBgoto();
$m = \Lower_enum\NotAllowed::PBif; $m = new \Lower_enum\PBif();
$m = \Lower_enum\NotAllowed::PBimplements; $m = new \Lower_enum\PBimplements();
$m = \Lower_enum\NotAllowed::PBinclude; $m = new \Lower_enum\PBinclude();
$m = \Lower_enum\NotAllowed::PBinclude_once; $m = new \Lower_enum\PBinclude_once();
$m = \Lower_enum\NotAllowed::PBinstanceof; $m = new \Lower_enum\PBinstanceof();
$m = \Lower_enum\NotAllowed::PBinsteadof; $m = new \Lower_enum\PBinsteadof();
$m = \Lower_enum\NotAllowed::PBinterface; $m = new \Lower_enum\PBinterface();
$m = \Lower_enum\NotAllowed::PBisset; $m = new \Lower_enum\PBisset();
$m = \Lower_enum\NotAllowed::PBlist; $m = new \Lower_enum\PBlist();
$m = \Lower_enum\NotAllowed::PBnamespace; $m = new \Lower_enum\PBnamespace();
$m = \Lower_enum\NotAllowed::PBnew; $m = new \Lower_enum\PBnew();
$m = \Lower_enum\NotAllowed::PBor; $m = new \Lower_enum\PBor();
$m = \Lower_enum\NotAllowed::PBprint; $m = new \Lower_enum\PBprint();
$m = \Lower_enum\NotAllowed::PBprivate; $m = new \Lower_enum\PBprivate();
$m = \Lower_enum\NotAllowed::PBprotected; $m = new \Lower_enum\PBprotected();
$m = \Lower_enum\NotAllowed::PBpublic; $m = new \Lower_enum\PBpublic();
$m = \Lower_enum\NotAllowed::PBrequire; $m = new \Lower_enum\PBrequire();
$m = \Lower_enum\NotAllowed::PBrequire_once; $m = new \Lower_enum\PBrequire_once();
$m = \Lower_enum\NotAllowed::PBreturn; $m = new \Lower_enum\PBreturn();
$m = \Lower_enum\NotAllowed::PBstatic; $m = new \Lower_enum\PBstatic();
$m = \Lower_enum\NotAllowed::PBswitch; $m = new \Lower_enum\PBswitch();
$m = \Lower_enum\NotAllowed::PBthrow; $m = new \Lower_enum\PBthrow();
$m = \Lower_enum\NotAllowed::PBtrait; $m = new \Lower_enum\PBtrait();
$m = \Lower_enum\NotAllowed::PBtry; $m = new \Lower_enum\PBtry();
$m = \Lower_enum\NotAllowed::PBunset; $m = new \Lower_enum\PBunset();
$m = \Lower_enum\NotAllowed::PBuse; $m = new \Lower_enum\PBuse();
$m = \Lower_enum\NotAllowed::PBvar; $m = new \Lower_enum\PBvar();
$m = \Lower_enum\NotAllowed::PBwhile; $m = new \Lower_enum\PBwhile();
$m = \Lower_enum\NotAllowed::PBxor; $m = new \Lower_enum\PBxor();
$m = \Lower_enum\NotAllowed::PBint; $m = new \Lower_enum\PBint();
$m = \Lower_enum\NotAllowed::PBfloat; $m = new \Lower_enum\PBfloat();
$m = \Lower_enum\NotAllowed::PBbool; $m = new \Lower_enum\PBbool();
$m = \Lower_enum\NotAllowed::PBstring; $m = new \Lower_enum\PBstring();
$m = \Lower_enum\NotAllowed::PBtrue; $m = new \Lower_enum\PBtrue();
$m = \Lower_enum\NotAllowed::PBfalse; $m = new \Lower_enum\PBfalse();
$m = \Lower_enum\NotAllowed::PBnull; $m = new \Lower_enum\PBnull();
$m = \Lower_enum\NotAllowed::PBvoid; $m = new \Lower_enum\PBvoid();
$m = \Lower_enum\NotAllowed::PBiterable; $m = new \Lower_enum\PBiterable();
$m = new \Upper_enum\PBABSTRACT();
$m = new \Upper_enum\PBAND();
$m = new \Upper_enum\PBARRAY();
$m = new \Upper_enum\PBAS();
$m = new \Upper_enum\PBBREAK();
$m = new \Upper_enum\PBCALLABLE();
$m = new \Upper_enum\PBCASE();
$m = new \Upper_enum\PBCATCH();
$m = new \Upper_enum\PBCLASS();
$m = new \Upper_enum\PBCLONE();
$m = new \Upper_enum\PBCONST();
$m = new \Upper_enum\PBCONTINUE();
$m = new \Upper_enum\PBDECLARE();
$m = new \Upper_enum\PBDEFAULT();
$m = new \Upper_enum\PBDIE();
$m = new \Upper_enum\PBDO();
$m = new \Upper_enum\PBECHO();
$m = new \Upper_enum\PBELSE();
$m = new \Upper_enum\PBELSEIF();
$m = new \Upper_enum\PBEMPTY();
$m = new \Upper_enum\PBENDDECLARE();
$m = new \Upper_enum\PBENDFOR();
$m = new \Upper_enum\PBENDFOREACH();
$m = new \Upper_enum\PBENDIF();
$m = new \Upper_enum\PBENDSWITCH();
$m = new \Upper_enum\PBENDWHILE();
$m = new \Upper_enum\PBEVAL();
$m = new \Upper_enum\PBEXIT();
$m = new \Upper_enum\PBEXTENDS();
$m = new \Upper_enum\PBFINAL();
$m = new \Upper_enum\PBFOR();
$m = new \Upper_enum\PBFOREACH();
$m = new \Upper_enum\PBFUNCTION();
$m = new \Upper_enum\PBGLOBAL();
$m = new \Upper_enum\PBGOTO();
$m = new \Upper_enum\PBIF();
$m = new \Upper_enum\PBIMPLEMENTS();
$m = new \Upper_enum\PBINCLUDE();
$m = new \Upper_enum\PBINCLUDE_ONCE();
$m = new \Upper_enum\PBINSTANCEOF();
$m = new \Upper_enum\PBINSTEADOF();
$m = new \Upper_enum\PBINTERFACE();
$m = new \Upper_enum\PBISSET();
$m = new \Upper_enum\PBLIST();
$m = new \Upper_enum\PBNAMESPACE();
$m = new \Upper_enum\PBNEW();
$m = new \Upper_enum\PBOR();
$m = new \Upper_enum\PBPRINT();
$m = new \Upper_enum\PBPRIVATE();
$m = new \Upper_enum\PBPROTECTED();
$m = new \Upper_enum\PBPUBLIC();
$m = new \Upper_enum\PBREQUIRE();
$m = new \Upper_enum\PBREQUIRE_ONCE();
$m = new \Upper_enum\PBRETURN();
$m = new \Upper_enum\PBSTATIC();
$m = new \Upper_enum\PBSWITCH();
$m = new \Upper_enum\PBTHROW();
$m = new \Upper_enum\PBTRAIT();
$m = new \Upper_enum\PBTRY();
$m = new \Upper_enum\PBUNSET();
$m = new \Upper_enum\PBUSE();
$m = new \Upper_enum\PBVAR();
$m = new \Upper_enum\PBWHILE();
$m = new \Upper_enum\PBXOR();
$m = new \Upper_enum\PBINT();
$m = new \Upper_enum\PBFLOAT();
$m = new \Upper_enum\PBBOOL();
$m = new \Upper_enum\PBSTRING();
$m = new \Upper_enum\PBTRUE();
$m = new \Upper_enum\PBFALSE();
$m = new \Upper_enum\PBNULL();
$m = new \Upper_enum\PBVOID();
$m = new \Upper_enum\PBITERABLE();
$m = \Lower_enum_value\NotAllowed::PBabstract;
$m = \Lower_enum_value\NotAllowed::PBand;
$m = \Lower_enum_value\NotAllowed::PBarray;
$m = \Lower_enum_value\NotAllowed::PBas;
$m = \Lower_enum_value\NotAllowed::PBbreak;
$m = \Lower_enum_value\NotAllowed::PBcallable;
$m = \Lower_enum_value\NotAllowed::PBcase;
$m = \Lower_enum_value\NotAllowed::PBcatch;
$m = \Lower_enum_value\NotAllowed::PBclass;
$m = \Lower_enum_value\NotAllowed::PBclone;
$m = \Lower_enum_value\NotAllowed::PBconst;
$m = \Lower_enum_value\NotAllowed::PBcontinue;
$m = \Lower_enum_value\NotAllowed::PBdeclare;
$m = \Lower_enum_value\NotAllowed::PBdefault;
$m = \Lower_enum_value\NotAllowed::PBdie;
$m = \Lower_enum_value\NotAllowed::PBdo;
$m = \Lower_enum_value\NotAllowed::PBecho;
$m = \Lower_enum_value\NotAllowed::PBelse;
$m = \Lower_enum_value\NotAllowed::PBelseif;
$m = \Lower_enum_value\NotAllowed::PBempty;
$m = \Lower_enum_value\NotAllowed::PBenddeclare;
$m = \Lower_enum_value\NotAllowed::PBendfor;
$m = \Lower_enum_value\NotAllowed::PBendforeach;
$m = \Lower_enum_value\NotAllowed::PBendif;
$m = \Lower_enum_value\NotAllowed::PBendswitch;
$m = \Lower_enum_value\NotAllowed::PBendwhile;
$m = \Lower_enum_value\NotAllowed::PBeval;
$m = \Lower_enum_value\NotAllowed::PBexit;
$m = \Lower_enum_value\NotAllowed::PBextends;
$m = \Lower_enum_value\NotAllowed::PBfinal;
$m = \Lower_enum_value\NotAllowed::PBfor;
$m = \Lower_enum_value\NotAllowed::PBforeach;
$m = \Lower_enum_value\NotAllowed::PBfunction;
$m = \Lower_enum_value\NotAllowed::PBglobal;
$m = \Lower_enum_value\NotAllowed::PBgoto;
$m = \Lower_enum_value\NotAllowed::PBif;
$m = \Lower_enum_value\NotAllowed::PBimplements;
$m = \Lower_enum_value\NotAllowed::PBinclude;
$m = \Lower_enum_value\NotAllowed::PBinclude_once;
$m = \Lower_enum_value\NotAllowed::PBinstanceof;
$m = \Lower_enum_value\NotAllowed::PBinsteadof;
$m = \Lower_enum_value\NotAllowed::PBinterface;
$m = \Lower_enum_value\NotAllowed::PBisset;
$m = \Lower_enum_value\NotAllowed::PBlist;
$m = \Lower_enum_value\NotAllowed::PBnamespace;
$m = \Lower_enum_value\NotAllowed::PBnew;
$m = \Lower_enum_value\NotAllowed::PBor;
$m = \Lower_enum_value\NotAllowed::PBprint;
$m = \Lower_enum_value\NotAllowed::PBprivate;
$m = \Lower_enum_value\NotAllowed::PBprotected;
$m = \Lower_enum_value\NotAllowed::PBpublic;
$m = \Lower_enum_value\NotAllowed::PBrequire;
$m = \Lower_enum_value\NotAllowed::PBrequire_once;
$m = \Lower_enum_value\NotAllowed::PBreturn;
$m = \Lower_enum_value\NotAllowed::PBstatic;
$m = \Lower_enum_value\NotAllowed::PBswitch;
$m = \Lower_enum_value\NotAllowed::PBthrow;
$m = \Lower_enum_value\NotAllowed::PBtrait;
$m = \Lower_enum_value\NotAllowed::PBtry;
$m = \Lower_enum_value\NotAllowed::PBunset;
$m = \Lower_enum_value\NotAllowed::PBuse;
$m = \Lower_enum_value\NotAllowed::PBvar;
$m = \Lower_enum_value\NotAllowed::PBwhile;
$m = \Lower_enum_value\NotAllowed::PBxor;
$m = \Lower_enum_value\NotAllowed::int;
$m = \Lower_enum_value\NotAllowed::float;
$m = \Lower_enum_value\NotAllowed::bool;
$m = \Lower_enum_value\NotAllowed::string;
$m = \Lower_enum_value\NotAllowed::true;
$m = \Lower_enum_value\NotAllowed::false;
$m = \Lower_enum_value\NotAllowed::null;
$m = \Lower_enum_value\NotAllowed::void;
$m = \Lower_enum_value\NotAllowed::iterable;
$m = \Upper_enum_value\NotAllowed::PBABSTRACT;
$m = \Upper_enum_value\NotAllowed::PBAND;
$m = \Upper_enum_value\NotAllowed::PBARRAY;
$m = \Upper_enum_value\NotAllowed::PBAS;
$m = \Upper_enum_value\NotAllowed::PBBREAK;
$m = \Upper_enum_value\NotAllowed::PBCALLABLE;
$m = \Upper_enum_value\NotAllowed::PBCASE;
$m = \Upper_enum_value\NotAllowed::PBCATCH;
$m = \Upper_enum_value\NotAllowed::PBCLASS;
$m = \Upper_enum_value\NotAllowed::PBCLONE;
$m = \Upper_enum_value\NotAllowed::PBCONST;
$m = \Upper_enum_value\NotAllowed::PBCONTINUE;
$m = \Upper_enum_value\NotAllowed::PBDECLARE;
$m = \Upper_enum_value\NotAllowed::PBDEFAULT;
$m = \Upper_enum_value\NotAllowed::PBDIE;
$m = \Upper_enum_value\NotAllowed::PBDO;
$m = \Upper_enum_value\NotAllowed::PBECHO;
$m = \Upper_enum_value\NotAllowed::PBELSE;
$m = \Upper_enum_value\NotAllowed::PBELSEIF;
$m = \Upper_enum_value\NotAllowed::PBEMPTY;
$m = \Upper_enum_value\NotAllowed::PBENDDECLARE;
$m = \Upper_enum_value\NotAllowed::PBENDFOR;
$m = \Upper_enum_value\NotAllowed::PBENDFOREACH;
$m = \Upper_enum_value\NotAllowed::PBENDIF;
$m = \Upper_enum_value\NotAllowed::PBENDSWITCH;
$m = \Upper_enum_value\NotAllowed::PBENDWHILE;
$m = \Upper_enum_value\NotAllowed::PBEVAL;
$m = \Upper_enum_value\NotAllowed::PBEXIT;
$m = \Upper_enum_value\NotAllowed::PBEXTENDS;
$m = \Upper_enum_value\NotAllowed::PBFINAL;
$m = \Upper_enum_value\NotAllowed::PBFOR;
$m = \Upper_enum_value\NotAllowed::PBFOREACH;
$m = \Upper_enum_value\NotAllowed::PBFUNCTION;
$m = \Upper_enum_value\NotAllowed::PBGLOBAL;
$m = \Upper_enum_value\NotAllowed::PBGOTO;
$m = \Upper_enum_value\NotAllowed::PBIF;
$m = \Upper_enum_value\NotAllowed::PBIMPLEMENTS;
$m = \Upper_enum_value\NotAllowed::PBINCLUDE;
$m = \Upper_enum_value\NotAllowed::PBINCLUDE_ONCE;
$m = \Upper_enum_value\NotAllowed::PBINSTANCEOF;
$m = \Upper_enum_value\NotAllowed::PBINSTEADOF;
$m = \Upper_enum_value\NotAllowed::PBINTERFACE;
$m = \Upper_enum_value\NotAllowed::PBISSET;
$m = \Upper_enum_value\NotAllowed::PBLIST;
$m = \Upper_enum_value\NotAllowed::PBNAMESPACE;
$m = \Upper_enum_value\NotAllowed::PBNEW;
$m = \Upper_enum_value\NotAllowed::PBOR;
$m = \Upper_enum_value\NotAllowed::PBPRINT;
$m = \Upper_enum_value\NotAllowed::PBPRIVATE;
$m = \Upper_enum_value\NotAllowed::PBPROTECTED;
$m = \Upper_enum_value\NotAllowed::PBPUBLIC;
$m = \Upper_enum_value\NotAllowed::PBREQUIRE;
$m = \Upper_enum_value\NotAllowed::PBREQUIRE_ONCE;
$m = \Upper_enum_value\NotAllowed::PBRETURN;
$m = \Upper_enum_value\NotAllowed::PBSTATIC;
$m = \Upper_enum_value\NotAllowed::PBSWITCH;
$m = \Upper_enum_value\NotAllowed::PBTHROW;
$m = \Upper_enum_value\NotAllowed::PBTRAIT;
$m = \Upper_enum_value\NotAllowed::PBTRY;
$m = \Upper_enum_value\NotAllowed::PBUNSET;
$m = \Upper_enum_value\NotAllowed::PBUSE;
$m = \Upper_enum_value\NotAllowed::PBVAR;
$m = \Upper_enum_value\NotAllowed::PBWHILE;
$m = \Upper_enum_value\NotAllowed::PBXOR;
$m = \Upper_enum_value\NotAllowed::INT;
$m = \Upper_enum_value\NotAllowed::FLOAT;
$m = \Upper_enum_value\NotAllowed::BOOL;
$m = \Upper_enum_value\NotAllowed::STRING;
$m = \Upper_enum_value\NotAllowed::TRUE;
$m = \Upper_enum_value\NotAllowed::FALSE;
$m = \Upper_enum_value\NotAllowed::NULL;
$m = \Upper_enum_value\NotAllowed::VOID;
$m = \Upper_enum_value\NotAllowed::ITERABLE;
} }
######################################################### #########################################################
......
...@@ -2,78 +2,76 @@ syntax = "proto3"; ...@@ -2,78 +2,76 @@ syntax = "proto3";
package lower_enum; package lower_enum;
enum NotAllowed { enum abstract { ZERO1 = 0; }
abstract = 0; enum and { ZERO2 = 0; }
and = 1; enum array { ZERO3 = 0; }
array = 2; enum as { ZERO4 = 0; }
as = 3; enum break { ZERO5 = 0; }
break = 4; enum callable { ZERO6 = 0; }
callable = 5; enum case { ZERO7 = 0; }
case = 6; enum catch { ZERO8 = 0; }
catch = 7; enum class { ZERO9 = 0; }
class = 8; enum clone { ZERO10 = 0; }
clone = 9; enum const { ZERO11 = 0; }
const = 10; enum continue { ZERO12 = 0; }
continue = 11; enum declare { ZERO13 = 0; }
declare = 12; enum default { ZERO14 = 0; }
default = 13; enum die { ZERO15 = 0; }
die = 14; enum do { ZERO16 = 0; }
do = 15; enum echo { ZERO17 = 0; }
echo = 16; enum else { ZERO18 = 0; }
else = 17; enum elseif { ZERO19 = 0; }
elseif = 18; enum empty { ZERO20 = 0; }
empty = 19; enum enddeclare { ZERO21 = 0; }
enddeclare = 20; enum endfor { ZERO22 = 0; }
endfor = 21; enum endforeach { ZERO23 = 0; }
endforeach = 22; enum endif { ZERO24 = 0; }
endif = 23; enum endswitch { ZERO25 = 0; }
endswitch = 24; enum endwhile { ZERO26 = 0; }
endwhile = 25; enum eval { ZERO27 = 0; }
eval = 26; enum exit { ZERO28 = 0; }
exit = 27; enum extends { ZERO29 = 0; }
extends = 28; enum final { ZERO30 = 0; }
final = 29; enum for { ZERO31 = 0; }
for = 30; enum foreach { ZERO32 = 0; }
foreach = 31; enum function { ZERO33 = 0; }
function = 32; enum global { ZERO34 = 0; }
global = 33; enum goto { ZERO35 = 0; }
goto = 34; enum if { ZERO36 = 0; }
if = 35; enum implements { ZERO37 = 0; }
implements = 36; enum include { ZERO38 = 0; }
include = 37; enum include_once { ZERO39 = 0; }
include_once = 38; enum instanceof { ZERO40 = 0; }
instanceof = 39; enum insteadof { ZERO41 = 0; }
insteadof = 40; enum interface { ZERO42 = 0; }
interface = 41; enum isset { ZERO43 = 0; }
isset = 42; enum list { ZERO44 = 0; }
list = 43; enum namespace { ZERO45 = 0; }
namespace = 44; enum new { ZERO46 = 0; }
new = 45; enum or { ZERO47 = 0; }
or = 46; enum print { ZERO48 = 0; }
print = 47; enum private { ZERO49 = 0; }
private = 48; enum protected { ZERO50 = 0; }
protected = 49; enum public { ZERO51 = 0; }
public = 50; enum require { ZERO52 = 0; }
require = 51; enum require_once { ZERO53 = 0; }
require_once = 52; enum return { ZERO54 = 0; }
return = 53; enum static { ZERO55 = 0; }
static = 54; enum switch { ZERO56 = 0; }
switch = 55; enum throw { ZERO57 = 0; }
throw = 56; enum trait { ZERO58 = 0; }
trait = 57; enum try { ZERO59 = 0; }
try = 58; enum unset { ZERO60 = 0; }
unset = 59; enum use { ZERO61 = 0; }
use = 60; enum var { ZERO62 = 0; }
var = 61; enum while { ZERO63 = 0; }
while = 62; enum xor { ZERO64 = 0; }
xor = 63; enum int { ZERO65 = 0; }
int = 64; enum float { ZERO66 = 0; }
float = 65; enum bool { ZERO67 = 0; }
bool = 66; enum string { ZERO68 = 0; }
string = 67; enum true { ZERO69 = 0; }
true = 68; enum false { ZERO70 = 0; }
false = 69; enum null { ZERO71 = 0; }
null = 70; enum void { ZERO72 = 0; }
void = 71; enum iterable { ZERO73 = 0; }
iterable = 72;
}
...@@ -2,78 +2,76 @@ syntax = "proto3"; ...@@ -2,78 +2,76 @@ syntax = "proto3";
package upper_enum; package upper_enum;
enum NotAllowed { enum ABSTRACT { ZERO1 = 0; }
ABSTRACT = 0; enum AND { ZERO2 = 0; }
AND = 1; enum ARRAY { ZERO3 = 0; }
ARRAY = 2; enum AS { ZERO4 = 0; }
AS = 3; enum BREAK { ZERO5 = 0; }
BREAK = 4; enum CALLABLE { ZERO6 = 0; }
CALLABLE = 5; enum CASE { ZERO7 = 0; }
CASE = 6; enum CATCH { ZERO8 = 0; }
CATCH = 7; enum CLASS { ZERO9 = 0; }
CLASS = 8; enum CLONE { ZERO10 = 0; }
CLONE = 9; enum CONST { ZERO11 = 0; }
CONST = 10; enum CONTINUE { ZERO12 = 0; }
CONTINUE = 11; enum DECLARE { ZERO13 = 0; }
DECLARE = 12; enum DEFAULT { ZERO14 = 0; }
DEFAULT = 13; enum DIE { ZERO15 = 0; }
DIE = 14; enum DO { ZERO16 = 0; }
DO = 15; enum ECHO { ZERO17 = 0; }
ECHO = 16; enum ELSE { ZERO18 = 0; }
ELSE = 17; enum ELSEIF { ZERO19 = 0; }
ELSEIF = 18; enum EMPTY { ZERO20 = 0; }
EMPTY = 19; enum ENDDECLARE { ZERO21 = 0; }
ENDDECLARE = 20; enum ENDFOR { ZERO22 = 0; }
ENDFOR = 21; enum ENDFOREACH { ZERO23 = 0; }
ENDFOREACH = 22; enum ENDIF { ZERO24 = 0; }
ENDIF = 23; enum ENDSWITCH { ZERO25 = 0; }
ENDSWITCH = 24; enum ENDWHILE { ZERO26 = 0; }
ENDWHILE = 25; enum EVAL { ZERO27 = 0; }
EVAL = 26; enum EXIT { ZERO28 = 0; }
EXIT = 27; enum EXTENDS { ZERO29 = 0; }
EXTENDS = 28; enum FINAL { ZERO30 = 0; }
FINAL = 29; enum FOR { ZERO31 = 0; }
FOR = 30; enum FOREACH { ZERO32 = 0; }
FOREACH = 31; enum FUNCTION { ZERO33 = 0; }
FUNCTION = 32; enum GLOBAL { ZERO34 = 0; }
GLOBAL = 33; enum GOTO { ZERO35 = 0; }
GOTO = 34; enum IF { ZERO36 = 0; }
IF = 35; enum IMPLEMENTS { ZERO37 = 0; }
IMPLEMENTS = 36; enum INCLUDE { ZERO38 = 0; }
INCLUDE = 37; enum INCLUDE_ONCE { ZERO39 = 0; }
INCLUDE_ONCE = 38; enum INSTANCEOF { ZERO40 = 0; }
INSTANCEOF = 39; enum INSTEADOF { ZERO41 = 0; }
INSTEADOF = 40; enum INTERFACE { ZERO42 = 0; }
INTERFACE = 41; enum ISSET { ZERO43 = 0; }
ISSET = 42; enum LIST { ZERO44 = 0; }
LIST = 43; enum NAMESPACE { ZERO45 = 0; }
NAMESPACE = 44; enum NEW { ZERO46 = 0; }
NEW = 45; enum OR { ZERO47 = 0; }
OR = 46; enum PRINT { ZERO48 = 0; }
PRINT = 47; enum PRIVATE { ZERO49 = 0; }
PRIVATE = 48; enum PROTECTED { ZERO50 = 0; }
PROTECTED = 49; enum PUBLIC { ZERO51 = 0; }
PUBLIC = 50; enum REQUIRE { ZERO52 = 0; }
REQUIRE = 51; enum REQUIRE_ONCE { ZERO53 = 0; }
REQUIRE_ONCE = 52; enum RETURN { ZERO54 = 0; }
RETURN = 53; enum STATIC { ZERO55 = 0; }
STATIC = 54; enum SWITCH { ZERO56 = 0; }
SWITCH = 55; enum THROW { ZERO57 = 0; }
THROW = 56; enum TRAIT { ZERO58 = 0; }
TRAIT = 57; enum TRY { ZERO59 = 0; }
TRY = 58; enum UNSET { ZERO60 = 0; }
UNSET = 59; enum USE { ZERO61 = 0; }
USE = 60; enum VAR { ZERO62 = 0; }
VAR = 61; enum WHILE { ZERO63 = 0; }
WHILE = 62; enum XOR { ZERO64 = 0; }
XOR = 63; enum INT { ZERO65 = 0; }
INT = 64; enum FLOAT { ZERO66 = 0; }
FLOAT = 65; enum BOOL { ZERO67 = 0; }
BOOL = 66; enum STRING { ZERO68 = 0; }
STRING = 67; enum TRUE { ZERO69 = 0; }
TRUE = 68; enum FALSE { ZERO70 = 0; }
FALSE = 69; enum NULL { ZERO71 = 0; }
NULL = 70; enum VOID { ZERO72 = 0; }
VOID = 71; enum ITERABLE { ZERO73 = 0; }
ITERABLE = 72;
}
syntax = "proto3";
package lower_enum_value;
enum NotAllowed {
abstract = 0;
and = 1;
array = 2;
as = 3;
break = 4;
callable = 5;
case = 6;
catch = 7;
class = 8;
clone = 9;
const = 10;
continue = 11;
declare = 12;
default = 13;
die = 14;
do = 15;
echo = 16;
else = 17;
elseif = 18;
empty = 19;
enddeclare = 20;
endfor = 21;
endforeach = 22;
endif = 23;
endswitch = 24;
endwhile = 25;
eval = 26;
exit = 27;
extends = 28;
final = 29;
for = 30;
foreach = 31;
function = 32;
global = 33;
goto = 34;
if = 35;
implements = 36;
include = 37;
include_once = 38;
instanceof = 39;
insteadof = 40;
interface = 41;
isset = 42;
list = 43;
namespace = 44;
new = 45;
or = 46;
print = 47;
private = 48;
protected = 49;
public = 50;
require = 51;
require_once = 52;
return = 53;
static = 54;
switch = 55;
throw = 56;
trait = 57;
try = 58;
unset = 59;
use = 60;
var = 61;
while = 62;
xor = 63;
int = 64;
float = 65;
bool = 66;
string = 67;
true = 68;
false = 69;
null = 70;
void = 71;
iterable = 72;
}
syntax = "proto3";
package upper_enum_value;
enum NotAllowed {
ABSTRACT = 0;
AND = 1;
ARRAY = 2;
AS = 3;
BREAK = 4;
CALLABLE = 5;
CASE = 6;
CATCH = 7;
CLASS = 8;
CLONE = 9;
CONST = 10;
CONTINUE = 11;
DECLARE = 12;
DEFAULT = 13;
DIE = 14;
DO = 15;
ECHO = 16;
ELSE = 17;
ELSEIF = 18;
EMPTY = 19;
ENDDECLARE = 20;
ENDFOR = 21;
ENDFOREACH = 22;
ENDIF = 23;
ENDSWITCH = 24;
ENDWHILE = 25;
EVAL = 26;
EXIT = 27;
EXTENDS = 28;
FINAL = 29;
FOR = 30;
FOREACH = 31;
FUNCTION = 32;
GLOBAL = 33;
GOTO = 34;
IF = 35;
IMPLEMENTS = 36;
INCLUDE = 37;
INCLUDE_ONCE = 38;
INSTANCEOF = 39;
INSTEADOF = 40;
INTERFACE = 41;
ISSET = 42;
LIST = 43;
NAMESPACE = 44;
NEW = 45;
OR = 46;
PRINT = 47;
PRIVATE = 48;
PROTECTED = 49;
PUBLIC = 50;
REQUIRE = 51;
REQUIRE_ONCE = 52;
RETURN = 53;
STATIC = 54;
SWITCH = 55;
THROW = 56;
TRAIT = 57;
TRY = 58;
UNSET = 59;
USE = 60;
VAR = 61;
WHILE = 62;
XOR = 63;
INT = 64;
FLOAT = 65;
BOOL = 66;
STRING = 67;
TRUE = 68;
FALSE = 69;
NULL = 70;
VOID = 71;
ITERABLE = 72;
}
...@@ -65,7 +65,12 @@ const char* const kReservedNames[] = { ...@@ -65,7 +65,12 @@ const char* const kReservedNames[] = {
"use", "var", "while", "xor", "int", "use", "var", "while", "xor", "int",
"float", "bool", "string", "true", "false", "float", "bool", "string", "true", "false",
"null", "void", "iterable"}; "null", "void", "iterable"};
const char* const kValidConstantNames[] = {
"int", "float", "bool", "string", "true",
"false", "null", "void", "iterable",
};
const int kReservedNamesSize = 73; const int kReservedNamesSize = 73;
const int kValidConstantNamesSize = 9;
const int kFieldSetter = 1; const int kFieldSetter = 1;
const int kFieldGetter = 2; const int kFieldGetter = 2;
const int kFieldProperty = 3; const int kFieldProperty = 3;
...@@ -161,6 +166,34 @@ std::string ClassNamePrefix(const string& classname, ...@@ -161,6 +166,34 @@ std::string ClassNamePrefix(const string& classname,
return ""; return "";
} }
std::string ClassNamePrefix(const string& classname,
const EnumValueDescriptor* desc) {
bool is_reserved = false;
string lower = classname;
transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
for (int i = 0; i < kReservedNamesSize; i++) {
if (lower == kReservedNames[i]) {
is_reserved = true;
break;
}
}
for (int i = 0; i < kValidConstantNamesSize; i++) {
if (lower == kValidConstantNames[i]) {
is_reserved = false;
break;
}
}
if (is_reserved) {
return "PB";
}
return "";
}
template <typename DescriptorType> template <typename DescriptorType>
std::string NamespacedName(const string& classname, std::string NamespacedName(const string& classname,
const DescriptorType* desc, bool is_descriptor) { const DescriptorType* desc, bool is_descriptor) {
...@@ -696,7 +729,7 @@ void GenerateEnumToPool(const EnumDescriptor* en, io::Printer* printer) { ...@@ -696,7 +729,7 @@ void GenerateEnumToPool(const EnumDescriptor* en, io::Printer* printer) {
const EnumValueDescriptor* value = en->value(i); const EnumValueDescriptor* value = en->value(i);
printer->Print( printer->Print(
"->value(\"^name^\", ^number^)\n", "->value(\"^name^\", ^number^)\n",
"name", ClassNamePrefix(value->name(), en) + value->name(), "name", ClassNamePrefix(value->name(), value) + value->name(),
"number", IntToString(value->number())); "number", IntToString(value->number()));
} }
printer->Print("->finalizeToPool();\n\n"); printer->Print("->finalizeToPool();\n\n");
...@@ -999,7 +1032,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, ...@@ -999,7 +1032,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
const EnumValueDescriptor* value = en->value(i); const EnumValueDescriptor* value = en->value(i);
GenerateEnumValueDocComment(&printer, value); GenerateEnumValueDocComment(&printer, value);
printer.Print("const ^name^ = ^number^;\n", printer.Print("const ^name^ = ^number^;\n",
"name", ClassNamePrefix(value->name(), en) + value->name(), "name", ClassNamePrefix(value->name(), value) + value->name(),
"number", IntToString(value->number())); "number", IntToString(value->number()));
} }
......
...@@ -355,6 +355,8 @@ generate_php_test_proto() { ...@@ -355,6 +355,8 @@ generate_php_test_proto() {
proto/test_empty_php_namespace.proto \ proto/test_empty_php_namespace.proto \
proto/test_reserved_enum_lower.proto \ proto/test_reserved_enum_lower.proto \
proto/test_reserved_enum_upper.proto \ proto/test_reserved_enum_upper.proto \
proto/test_reserved_enum_value_lower.proto \
proto/test_reserved_enum_value_upper.proto \
proto/test_reserved_message_lower.proto \ proto/test_reserved_message_lower.proto \
proto/test_reserved_message_upper.proto \ proto/test_reserved_message_upper.proto \
proto/test_service.proto \ proto/test_service.proto \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment