bug44660.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. --TEST--
  2. Bug #44660 (Indexed and reference assignment to property of non-object don't trigger warning)
  3. --FILE--
  4. <?php
  5. $s = "hello";
  6. $a = true;
  7. echo "--> read access:";
  8. echo $a->p;
  9. echo "\n--> direct assignment:\n";
  10. try {
  11. $a->p = $s;
  12. } catch (Error $e) {
  13. echo $e->getMessage(), "\n";
  14. }
  15. echo "\n--> increment:\n";
  16. try {
  17. $a->p++;
  18. } catch (Error $e) {
  19. echo $e->getMessage(), "\n";
  20. }
  21. echo "\n--> reference assignment:\n";
  22. try {
  23. $a->p =& $s;
  24. } catch (Error $e) {
  25. echo $e->getMessage(), "\n";
  26. }
  27. echo "\n--> reference assignment:\n";
  28. try {
  29. $s =& $a->p;
  30. } catch (Error $e) {
  31. echo $e->getMessage(), "\n";
  32. }
  33. echo "\n--> indexed assignment:\n";
  34. try {
  35. $a->p[0] = $s;
  36. } catch (Error $e) {
  37. echo $e->getMessage(), "\n";
  38. }
  39. echo "\n--> Confirm assignments have had no impact:\n";
  40. var_dump($a);
  41. ?>
  42. --EXPECTF--
  43. --> read access:
  44. Warning: Attempt to read property "p" on bool in %s on line %d
  45. --> direct assignment:
  46. Attempt to assign property "p" on bool
  47. --> increment:
  48. Attempt to increment/decrement property "p" on bool
  49. --> reference assignment:
  50. Attempt to modify property "p" on bool
  51. --> reference assignment:
  52. Attempt to modify property "p" on bool
  53. --> indexed assignment:
  54. Attempt to modify property "p" on bool
  55. --> Confirm assignments have had no impact:
  56. bool(true)