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