gh8591-002.phpt 930 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. Bug GH-8591 002 (JIT does not account for class re-compile)
  3. --EXTENSIONS--
  4. opcache
  5. --INI--
  6. opcache.enable=1
  7. opcache.enable_cli=1
  8. opcache.jit_buffer_size=1M
  9. opcache.jit=1255
  10. opcache.file_update_protection=0
  11. opcache.revalidate_freq=0
  12. opcache.protect_memory=1
  13. --FILE--
  14. <?php
  15. // Checks that JITed code does not crash in --repeat 2 after the ModelInterface
  16. // interface changes and Model is re-linked.
  17. if (!isset(opcache_get_status()['scripts'][__DIR__ . '/gh8591-002.inc'])) {
  18. require __DIR__ . '/gh8591-001.inc';
  19. } else {
  20. interface ModelInterace
  21. {
  22. }
  23. }
  24. class Model implements ModelInterface
  25. {
  26. protected static int $field = 1;
  27. public function __construct()
  28. {
  29. for ($i = 0; $i < 10; $i++) {
  30. $this->cast();
  31. }
  32. }
  33. private function cast()
  34. {
  35. global $x;
  36. $x = static::$field;
  37. }
  38. }
  39. new Model();
  40. var_dump($x);
  41. print "OK";
  42. --EXPECT--
  43. int(1)
  44. OK