File: libxml_set_streams_context_overwrite.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (50 lines) | stat: -rw-r--r-- 885 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--TEST--
Overwrite libxml_set_streams_context
--EXTENSIONS--
simplexml
--FILE--
<?php

// Based on bug54440.phpt

class TestWrapper {
    function stream_open($path, $mode, $options, &$opened_path)
    {
        print_r(stream_context_get_options($this->context));
        return false;
    }

    function url_stat($path, $flags)
    {
        return array();
    }
}

stream_wrapper_register("test", "TestWrapper");

$ctx1 = stream_context_create(array('test'=>array('test'=>'test 1')));
$ctx2 = stream_context_create(array('test'=>array('test'=>'test 2')));

libxml_set_streams_context($ctx2);
@simplexml_load_file('test://sdfsdf');

libxml_set_streams_context($ctx1);
@simplexml_load_file('test://sdfsdf');
?>
--EXPECT--
Array
(
    [test] => Array
        (
            [test] => test 2
        )

)
Array
(
    [test] => Array
        (
            [test] => test 1
        )

)