fstat_variation6.phpt 983 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. Test function fstat() by substituting argument 1 with object values.
  3. --FILE--
  4. <?php
  5. function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
  6. if (error_reporting() != 0) {
  7. // report non-silenced errors
  8. echo "Error: $err_no - $err_msg, $filename($linenum)\n";
  9. }
  10. }
  11. set_error_handler('test_error_handler');
  12. class classWithToString
  13. {
  14. public function __toString() {
  15. return "Class A object";
  16. }
  17. }
  18. class classWithoutToString
  19. {
  20. }
  21. $variation_array = array(
  22. 'instance of classWithToString' => new classWithToString(),
  23. 'instance of classWithoutToString' => new classWithoutToString(),
  24. );
  25. foreach ( $variation_array as $var ) {
  26. var_dump(fstat( $var ) );
  27. }
  28. ?>
  29. ===DONE===
  30. --EXPECTF--
  31. Error: 2 - fstat() expects parameter 1 to be resource, object given, %s(%d)
  32. bool(false)
  33. Error: 2 - fstat() expects parameter 1 to be resource, object given, %s(%d)
  34. bool(false)
  35. ===DONE===