xref: /php-src/Zend/tests/bug38779.phpt (revision 1b120b4a)
1--TEST--
2Bug #38779 (engine crashes when require()'ing file with syntax error through userspace stream wrapper)
3--FILE--
4<?php
5
6class Loader {
7    public $context;
8    private $position;
9    private $data;
10    public function stream_open($path, $mode, $options, &$opened_path)  {
11        $this->data = '<' . "?php \n\"\";ll l\n ?" . '>';
12        $this->position = 0;
13        return true;
14    }
15    function stream_read($count) {
16        $ret = substr($this->data, $this->position, $count);
17        $this->position += strlen($ret);
18        return $ret;
19    }
20    function stream_eof() {
21        return $this->position >= strlen($this->data);
22    }
23    function stream_stat() {
24        return array('size' => strlen($this->data));
25    }
26    function stream_set_option($option, $arg1, $arg2) {
27        return false;
28    }
29}
30stream_wrapper_register('Loader', 'Loader');
31require 'Loader://qqq.php';
32
33echo "Done\n";
34?>
35--EXPECTF--
36Parse error: %s error%sin Loader://qqq.php on line %d
37