bug81015.phpt 467 B

1234567891011121314151617181920212223242526
  1. --TEST--
  2. Bug #81015: Opcache optimization assumes wrong part of ternary operator in if-condition
  3. --FILE--
  4. <?php
  5. function ternary(bool $enabled, ?string $value): void
  6. {
  7. // the "true" part is not as trivial in the real case
  8. if ($enabled ? true : $value === null) {
  9. echo ($value ?? 'NULL') . "\n";
  10. } else {
  11. echo "INVALID\n";
  12. }
  13. }
  14. ternary(true, 'value');
  15. ternary(true, null);
  16. ternary(false, 'value');
  17. ternary(false, null);
  18. ?>
  19. --EXPECT--
  20. value
  21. NULL
  22. INVALID
  23. NULL