1--TEST-- 2file_put_contents() and invalid parameters 3--FILE-- 4<?php 5class foo { 6 function __toString() { 7 return __METHOD__; 8 } 9} 10$file = __DIR__."/file_put_contents.txt"; 11 12$context = stream_context_create(); 13 14try { 15 var_dump(file_put_contents($file, $context)); 16} catch (TypeError $e) { 17 echo $e->getMessage(), "\n"; 18} 19var_dump(file_put_contents($file, new stdClass)); 20var_dump(file_put_contents($file, new foo)); 21$fp = fopen($file, "r"); 22try { 23 var_dump(file_put_contents($file, "string", 0, $fp)); 24} catch (TypeError $e) { 25 echo $e->getMessage(), "\n"; 26} 27 28@unlink($file); 29 30echo "Done\n"; 31?> 32--EXPECT-- 33file_put_contents(): supplied resource is not a valid stream resource 34bool(false) 35int(15) 36file_put_contents(): supplied resource is not a valid Stream-Context resource 37Done 38