1--TEST--
2Bug #60455: stream_get_line and 2 lines, one possibly empty
3--FILE--
4<?php
5class TestStream {
6	private $lines = array();
7	private $s = 0;
8	private $eofth = 3;
9	function stream_open($path, $mode, $options, &$opened_path) {
10			$this->lines[] = "a\n";
11			$this->lines[] = ($path == "test://nonempty2nd" ? "b\n" : "\n");
12			if ($path == "test://eofafter2nd")
13				$this->eofth = 2;
14	        return true;
15	}
16	function stream_read($count) {
17		if (key_exists($this->s++, $this->lines))
18			return $this->lines[$this->s - 1];
19
20		return "";
21	}
22	function stream_eof() {
23		return $this->s >= $this->eofth;
24	}
25
26}
27
28stream_wrapper_register("test", "TestStream");
29
30$f = fopen("test://nonempty2nd", "r");
31while (!feof($f)) {
32    $line = stream_get_line($f, 99, "\n");
33    var_dump($line);
34}
35$f = fopen("test://", "r");
36while (!feof($f)) {
37    $line = stream_get_line($f, 99, "\n");
38    var_dump($line);
39}
40$f = fopen("test://eofafter2nd", "r");
41while (!feof($f)) {
42    $line = stream_get_line($f, 99, "\n");
43    var_dump($line);
44}
45
46
47--EXPECT--
48string(1) "a"
49string(1) "b"
50bool(false)
51string(1) "a"
52string(0) ""
53bool(false)
54string(1) "a"
55string(0) ""
56