summaryrefslogtreecommitdiff
path: root/ext/standard/tests/streams/bug67626.phpt
blob: 67c2c3f8e088bfbfcb3ccb0af236134f3bb1cb8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--TEST--
Bug #67626: Exceptions not properly handled in user stream handlers
--FILE--
<?php
class MyStream
{
	public function stream_open() { return true; }
	
	public function stream_read()
	{
		throw new Exception('stream_read_exception');
		return 'read';
	}
	
	public function stream_eof()
	{
		return true;
	}
	
	public function stream_write()
	{
		throw new Exception('stream_write_exception');
		return 42;
	}
}

stream_wrapper_register("my", "MyStream");

$fp = fopen('my://foobar', 'r+');

try {
	fread($fp, 42);
} catch (Exception $e) {
	echo $e->getMessage();
}
echo "\n";
try {
	fwrite($fp, 'foobar');
} catch (Exception $e) {
	echo $e->getMessage();
}
?>
--EXPECTF--
stream_read_exception
stream_write_exception