PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/quick/static_properties.php

http://github.com/facebook/hiphop-php
PHP | 221 lines | 174 code | 32 blank | 15 comment | 0 complexity | 28330c269feb63a4dbeb7390b5dad7ce MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?php
  2. print "Test begin\n";
  3. class A {
  4. const CD = "A::CD";
  5. const CE = B::CE;
  6. const CF = C::CG;
  7. static $a = "A::a";
  8. static protected $b = "A::b";
  9. static private $c = "A::c";
  10. static $d = A::CD;
  11. static protected $e = A::CE;
  12. static private $f = A::CF;
  13. function aFunc() {
  14. print "In A::aFunc():\n";
  15. print " A::a: " . A::$a . "\n";
  16. print " A::b: " . A::$b . "\n";
  17. print " A::c: " . A::$c . "\n";
  18. print " A::d: " . A::$d . "\n";
  19. print " A::e: " . A::$e . "\n";
  20. print " A::f: " . A::$f . "\n";
  21. print "\n";
  22. print " B::a: " . B::$a . "\n";
  23. print " B::b: " . B::$b . "\n";
  24. # print " B::c: " . B::$c . "\n";
  25. print " B::d: " . B::$d . "\n";
  26. print " B::e: " . B::$e . "\n";
  27. # print " B::f: " . B::$f . "\n";
  28. print " B::g: " . B::$g . "\n";
  29. print "\n";
  30. print " C::a: " . C::$a . "\n";
  31. print " C::b: " . C::$b . "\n";
  32. # print " C::c: " . C::$c . "\n";
  33. print " C::d: " . C::$d . "\n";
  34. print " C::e: " . C::$e . "\n";
  35. # print " C::f: " . C::$f . "\n";
  36. print " C::g: " . C::$g . "\n";
  37. print " C::h: " . C::$h . "\n";
  38. }
  39. }
  40. class B extends A {
  41. const CD = "B::CD";
  42. const CE = "B::CE";
  43. static protected $b = "B::b";
  44. static private $c = "B::c";
  45. static $d = B::CD;
  46. static protected $g = "B::g";
  47. function bFunc() {
  48. print "In B::bFunc():\n";
  49. print " A::a: " . A::$a . "\n";
  50. print " A::b: " . A::$b . "\n";
  51. # print " A::c: " . A::$c . "\n";
  52. print " A::d: " . A::$d . "\n";
  53. print " A::e: " . A::$e . "\n";
  54. # print " A::f: " . A::$f . "\n";
  55. print "\n";
  56. print " B::a: " . B::$a . "\n";
  57. print " B::b: " . B::$b . "\n";
  58. print " B::c: " . B::$c . "\n";
  59. print " B::d: " . B::$d . "\n";
  60. print " B::e: " . B::$e . "\n";
  61. # print " B::f: " . B::$f . "\n";
  62. print " B::g: " . B::$g . "\n";
  63. print "\n";
  64. print " C::a: " . C::$a . "\n";
  65. print " C::b: " . C::$b . "\n";
  66. # print " C::c: " . C::$c . "\n";
  67. print " C::d: " . C::$d . "\n";
  68. print " C::e: " . C::$e . "\n";
  69. # print " C::f: " . C::$f . "\n";
  70. print " C::g: " . C::$g . "\n";
  71. print " C::h: " . C::$h . "\n";
  72. }
  73. }
  74. class C extends B {
  75. const CG = "C::CG";
  76. static protected $b = "C::b";
  77. static $h = "C::h";
  78. public $i = C::CG;
  79. function cFunc() {
  80. print "In C::cFunc():\n";
  81. print " A::a: " . A::$a . "\n";
  82. print " A::b: " . A::$b . "\n";
  83. # print " A::c: " . A::$c . "\n";
  84. print " A::d: " . A::$d . "\n";
  85. print " A::e: " . A::$e . "\n";
  86. # print " A::f: " . A::$f . "\n";
  87. print "\n";
  88. print " B::a: " . B::$a . "\n";
  89. print " B::b: " . B::$b . "\n";
  90. # print " B::c: " . B::$c . "\n";
  91. print " B::d: " . B::$d . "\n";
  92. print " B::e: " . B::$e . "\n";
  93. # print " B::f: " . B::$f . "\n";
  94. print " B::g: " . B::$g . "\n";
  95. print "\n";
  96. print " C::a: " . C::$a . "\n";
  97. print " C::b: " . C::$b . "\n";
  98. # print " C::c: " . C::$c . "\n";
  99. print " C::d: " . C::$d . "\n";
  100. print " C::e: " . C::$e . "\n";
  101. # print " C::f: " . C::$f . "\n";
  102. print " C::g: " . C::$g . "\n";
  103. print " C::h: " . C::$h . "\n";
  104. }
  105. }
  106. function main() {
  107. $a = new A;
  108. $a->aFunc();
  109. $b = new B;
  110. $b->aFunc();
  111. $b->bFunc();
  112. $c = new C;
  113. $c->aFunc();
  114. $c->bFunc();
  115. $c->cFunc();
  116. print "isset(C::\$h): ".(isset(C::$h)?"true":"false")."\n";
  117. print "empty(C::\$h): ".(empty(C::$h)?"true":"false")."\n";
  118. print "isset(C::\$i): ".(isset(C::$i)?"true":"false")."\n";
  119. print "empty(C::\$i): ".(empty(C::$i)?"true":"false")."\n";
  120. print "C::\$h: ".C::$h."\n";
  121. C::$h = 42;
  122. print "C::\$h: ".C::$h."\n";
  123. C::$h += 42;
  124. print "C::\$h: ".C::$h."\n";
  125. print "C::\$h: ".++C::$h."\n";
  126. print "C::\$h: ".C::$h++."\n";
  127. print "C::\$h: ".C::$h--."\n";
  128. print "C::\$h: ".--C::$h."\n";
  129. $x = 1234;
  130. C::$h =& $x;
  131. print "C::\$h: ".C::$h."\n";
  132. $x++;
  133. print "C::\$h: ".C::$h."\n";
  134. C::$h = 5678;
  135. print "x: ".$x."\n";
  136. C::$h = array(0, 1, 2);
  137. $y = C::$h[1];
  138. print "\$y: $y\n";
  139. C::$h[2] = 42;
  140. $y = C::$h[2];
  141. print "\$y: $y\n";
  142. print "Test end\n";
  143. }
  144. class D {
  145. static function main() {
  146. $a = new A;
  147. $a->aFunc();
  148. $b = new B;
  149. $b->aFunc();
  150. $b->bFunc();
  151. $c = new C;
  152. $c->aFunc();
  153. $c->bFunc();
  154. $c->cFunc();
  155. print "isset(C::\$h): ".(isset(C::$h)?"true":"false")."\n";
  156. print "empty(C::\$h): ".(empty(C::$h)?"true":"false")."\n";
  157. print "isset(C::\$i): ".(isset(C::$i)?"true":"false")."\n";
  158. print "empty(C::\$i): ".(empty(C::$i)?"true":"false")."\n";
  159. print "C::\$h: ".C::$h."\n";
  160. C::$h = 42;
  161. print "C::\$h: ".C::$h."\n";
  162. C::$h += 42;
  163. print "C::\$h: ".C::$h."\n";
  164. print "C::\$h: ".++C::$h."\n";
  165. print "C::\$h: ".C::$h++."\n";
  166. print "C::\$h: ".C::$h--."\n";
  167. print "C::\$h: ".--C::$h."\n";
  168. $x = 1234;
  169. C::$h =& $x;
  170. print "C::\$h: ".C::$h."\n";
  171. $x++;
  172. print "C::\$h: ".C::$h."\n";
  173. C::$h = 5678;
  174. print "x: ".$x."\n";
  175. C::$h = array(0, 1, 2);
  176. $y = C::$h[1];
  177. print "\$y: $y\n";
  178. C::$h[2] = 42;
  179. $y = C::$h[2];
  180. print "\$y: $y\n";
  181. C::$h = 20;
  182. $w =& C::$h;
  183. $w = 5;
  184. print "C::\$h: ".C::$h."\n";
  185. print "Test end\n";
  186. }
  187. }
  188. main();
  189. D::main();