ctor_promotion_mixing.phpt 924 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. --TEST--
  2. Constructor promotiong mixed with other properties, parameters and code
  3. --FILE--
  4. <?php
  5. class Test {
  6. public string $prop2;
  7. public function __construct(public string $prop1 = "", $param2 = "") {
  8. $this->prop2 = $prop1 . $param2;
  9. }
  10. }
  11. var_dump(new Test("Foo", "Bar"));
  12. echo "\n";
  13. echo new ReflectionClass(Test::class), "\n";
  14. ?>
  15. --EXPECTF--
  16. object(Test)#1 (2) {
  17. ["prop2"]=>
  18. string(6) "FooBar"
  19. ["prop1"]=>
  20. string(3) "Foo"
  21. }
  22. Class [ <user> class Test ] {
  23. @@ %s
  24. - Constants [0] {
  25. }
  26. - Static properties [0] {
  27. }
  28. - Static methods [0] {
  29. }
  30. - Properties [2] {
  31. Property [ public string $prop2 ]
  32. Property [ public string $prop1 ]
  33. }
  34. - Methods [1] {
  35. Method [ <user, ctor> public method __construct ] {
  36. @@ %s
  37. - Parameters [2] {
  38. Parameter #0 [ <optional> string $prop1 = '' ]
  39. Parameter #1 [ <optional> $param2 = '' ]
  40. }
  41. }
  42. }
  43. }