yield_unary_precedence.phpt 382 B

123456789101112131415161718192021222324
  1. --TEST--
  2. When + or - are used on yield, they must be unary (and not binary) (Bug #69160)
  3. --FILE--
  4. <?php
  5. function gen() {
  6. var_dump(yield +1);
  7. var_dump(yield -1);
  8. var_dump(yield * -1); // other ops still should behave normally
  9. }
  10. for ($gen = gen(); $gen->valid(); $gen->send(1)) {
  11. echo "\n";
  12. var_dump($gen->current());
  13. }
  14. ?>
  15. --EXPECT--
  16. int(1)
  17. int(1)
  18. int(-1)
  19. int(1)
  20. NULL
  21. int(-1)