dereference_010.phpt 540 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. Testing dereference in non-array values
  3. --FILE--
  4. <?php
  5. error_reporting(E_ALL);
  6. function a() {
  7. return 1;
  8. }
  9. $a = 1;
  10. var_dump($a[1]);
  11. var_dump(a()[1]);
  12. function b() {
  13. return new stdClass;
  14. }
  15. var_dump(b()[1]);
  16. ?>
  17. --EXPECTF--
  18. Warning: Trying to access array offset on value of type int in %s on line %d
  19. NULL
  20. Warning: Trying to access array offset on value of type int in %s on line %d
  21. NULL
  22. Fatal error: Uncaught Error: Cannot use object of type stdClass as array in %s:%d
  23. Stack trace:
  24. #0 {main}
  25. thrown in %s on line %d