PageRenderTime 46ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/CodeSniffer/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.inc

http://github.com/squizlabs/PHP_CodeSniffer
PHP | 164 lines | 132 code | 31 blank | 1 comment | 16 complexity | a008b140c94ae08f6bfaa9f5775f9739 MD5 | raw file
  1. <?php
  2. switch ($var) {
  3. case '1':
  4. return;
  5. echo 'hi';
  6. case '2':
  7. case '3':
  8. if ($something === true) {
  9. break;
  10. echo 'hi';
  11. }
  12. break;
  13. default:
  14. return;
  15. if ($something === true) {
  16. break;
  17. echo 'hi';
  18. }
  19. }
  20. function myFunction($var)
  21. {
  22. if ($something === TRUE) {
  23. return;
  24. echo 'hi';
  25. }
  26. return;
  27. return FALSE;
  28. if ($something === TRUE) {
  29. return TRUE;
  30. }
  31. }//end myFunction()
  32. foreach ($vars as $var) {
  33. if ($something === TRUE) {
  34. continue;
  35. break;
  36. } else {
  37. continue;
  38. echo 'hi';
  39. }
  40. echo $var."\n";
  41. }
  42. switch ($lowerVarType) {
  43. case 'bool':
  44. return 'boolean';
  45. echo 'hi';
  46. case 'double':
  47. case 'real':
  48. return 'float';
  49. echo 'hi';
  50. }
  51. while ($line=fgets($fp,2*1024*1024))
  52. {
  53. if (!preg_match("/^<([a-z0-9_]+)/",$line,$matches))
  54. continue;
  55. print $line;
  56. }
  57. switch ($var) {
  58. case 1:
  59. echo '1';
  60. break;
  61. echo 'non-executable';
  62. default:
  63. echo '2';
  64. break;
  65. }
  66. switch (0) {
  67. case 1:
  68. return '1';
  69. echo 'non-executable';
  70. default:
  71. break;
  72. }
  73. function myFunction()
  74. {
  75. if ($something === TRUE) {
  76. return;
  77. }
  78. echo 'foo';
  79. return;
  80. }//end myFunction()
  81. function myFunction()
  82. {
  83. return uksort(
  84. $array,
  85. function() {
  86. return mt_rand(-1, 1);
  87. echo 'done';
  88. }
  89. );
  90. }//end myFunction()
  91. public static function thisCausesAnError() {
  92. return new foo(function() {return $foo;}
  93. );
  94. }
  95. function myFunction()
  96. {
  97. if ($something === TRUE) {
  98. throw new Exception('exception');
  99. }
  100. throw new Exception('exception');
  101. echo 'non-executable';
  102. }//end myFunction()
  103. switch ($var) {
  104. case 1: {
  105. return '1';
  106. }
  107. case 2: {
  108. return '2';
  109. }
  110. }
  111. defined('FOO') or die('error');
  112. interface myInterface {
  113. function myFunc();
  114. }
  115. echo 'hello';
  116. exit();
  117. // Errors are thrown from here down from the exit() above.
  118. foreach ($vars as $var) {
  119. if ($something === TRUE) {
  120. break;
  121. break;
  122. }
  123. }
  124. exit();
  125. function test() {
  126. echo 'no error';
  127. }
  128. class myClass {
  129. function myFunc() {
  130. echo 'no error';
  131. }
  132. }
  133. ?>