xref: /PHP-8.0/Zend/tests/bug78340.phpt (revision 9bfda013)
1--TEST--
2Bug #78340: Include of stream wrapper not reading whole file
3--FILE--
4<?php
5
6class lib {
7  public static $files= [];
8
9  private $bytes, $pos;
10
11  function stream_open($path, $mode, $options, $opened_path) {
12    $this->bytes= self::$files[$path];
13    $this->pos= 0;
14    $this->ino= crc32($path);
15    return true;
16  }
17
18  function stream_read($count) {
19    $chunk= substr($this->bytes, $this->pos, $count);
20    $this->pos+= strlen($chunk);
21    return $chunk;
22  }
23
24  function stream_eof() {
25    return $this->pos >= strlen($this->bytes);
26  }
27
28  function stream_close() {
29    $this->bytes= null;
30  }
31
32  function stream_stat() {
33    return [
34      'dev'   => 3632233996,
35      'size'  => strlen($this->bytes),
36      'ino'   => $this->ino
37    ];
38  }
39
40  function stream_set_option($option, $arg1, $arg2) {
41    return false;
42  }
43}
44
45$fill = str_repeat('.', 8192);
46lib::$files['lib://test.php']= '<?php /* '.$fill.' */ function test() { echo "Works!\n"; }';
47stream_wrapper_register('lib', lib::class);
48
49include('lib://test.php');
50test();
51
52?>
53--EXPECT--
54Works!
55