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