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
28echo "Done\n";
29?>
30--CLEAN--
31<?php
32$file = __DIR__."/file_put_contents.txt";
33unlink($file);
34?>
35--EXPECT--
36file_put_contents(): supplied resource is not a valid stream resource
37bool(false)
38int(15)
39file_put_contents(): supplied resource is not a valid Stream-Context resource
40Done
41