bug79839.phpt 444 B

1234567891011121314151617181920212223242526
  1. --TEST--
  2. Bug #79839: array_walk() does not respect property types
  3. --FILE--
  4. <?php
  5. class Test {
  6. public int $prop = 42;
  7. }
  8. $test = new Test;
  9. try {
  10. array_walk($test, function(&$ref) {
  11. $ref = []; // Should throw
  12. });
  13. } catch (TypeError $e) {
  14. echo $e->getMessage(), "\n";
  15. }
  16. var_dump($test);
  17. ?>
  18. --EXPECT--
  19. Cannot assign array to reference held by property Test::$prop of type int
  20. object(Test)#1 (1) {
  21. ["prop"]=>
  22. int(42)
  23. }