new_arg_eval.phpt 664 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --TEST--
  2. Check that const exprs are pre-evaluated in new arguments
  3. --FILE--
  4. <?php
  5. class C {
  6. public function __construct(public $x) {}
  7. }
  8. function test(
  9. $a = new C(__CLASS__),
  10. $b = new C(__FUNCTION__),
  11. $c = new C(x: __FILE__),
  12. ) {
  13. var_dump($a, $b, $c);
  14. }
  15. test();
  16. // Check that nested new works as well.
  17. function test2($p = new C(new C(__FUNCTION__))) {
  18. var_dump($p);
  19. }
  20. test2();
  21. ?>
  22. --EXPECTF--
  23. object(C)#1 (1) {
  24. ["x"]=>
  25. string(0) ""
  26. }
  27. object(C)#2 (1) {
  28. ["x"]=>
  29. string(4) "test"
  30. }
  31. object(C)#3 (1) {
  32. ["x"]=>
  33. string(%d) "%snew_arg_eval.php"
  34. }
  35. object(C)#3 (1) {
  36. ["x"]=>
  37. object(C)#2 (1) {
  38. ["x"]=>
  39. string(5) "test2"
  40. }
  41. }