1--TEST--
2Bug #60817: stream_get_line() reads from stream even when there is already sufficient data buffered
3--FILE--
4<?php
5class TestStream { //data, empty data, empty data + eof
6    public $context;
7    private $s = 0;
8    function stream_open($path, $mode, $options, &$opened_path) {
9            return true;
10    }
11    function stream_read($count) {
12        echo "Read done\n";
13        if ($this->s++ == 0)
14            return "a\nbb\ncc";
15
16        return "";
17    }
18    function stream_eof() {
19        return $this->s >= 2;
20    }
21
22}
23
24stream_wrapper_register("test", "TestStream");
25
26$f = fopen("test://", "r");
27while (!feof($f)) {
28    $line = stream_get_line($f, 99, "\n");
29    var_dump($line);
30}
31?>
32--EXPECT--
33Read done
34string(1) "a"
35string(2) "bb"
36Read done
37string(2) "cc"
38