bug80900.phpt 1006 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. Bug 80900: Switch constant with incorrect type
  3. --INI--
  4. opcache.enable=1
  5. opcache.enable_cli=1
  6. opcache.optimization_level=-1
  7. --EXTENSIONS--
  8. opcache
  9. --FILE--
  10. <?php
  11. function switchLong() {
  12. $var = 'foo';
  13. /* The number of case clauses needs to be greater than 5,
  14. * otherwise it will not be compiled into SWITCH_LONG. */
  15. switch ($var) {
  16. case 1:
  17. echo 'no1';
  18. break;
  19. case 2:
  20. echo 'no2';
  21. break;
  22. case 3:
  23. echo 'no3';
  24. break;
  25. case 4:
  26. echo 'no4';
  27. break;
  28. case 5:
  29. echo 'no5';
  30. break;
  31. default:
  32. echo 'yes';
  33. break;
  34. }
  35. echo PHP_EOL;
  36. }
  37. function switchString() {
  38. $var = false;
  39. switch ($var) {
  40. case 'string':
  41. echo 'no';
  42. break;
  43. default:
  44. echo 'yes';
  45. break;
  46. }
  47. echo PHP_EOL;
  48. }
  49. switchLong();
  50. switchString();
  51. ?>
  52. --EXPECT--
  53. yes
  54. yes