xref: /PHP-8.1/ext/soap/tests/bugs/bug30928.phpt (revision 8ae4b560)
1--TEST--
2Bug #30928 (When Using WSDL, SoapServer doesn't handle private or protected properties)
3--EXTENSIONS--
4soap
5--FILE--
6<?php
7ini_set("soap.wsdl_cache_enabled", 0);
8
9class foo {
10    public    $a="a";
11    private   $b="b";
12    protected $c="c";
13}
14
15function test($x) {
16  return $x;
17}
18
19class LocalSoapClient extends SoapClient {
20
21  function __construct($wsdl, $options) {
22    parent::__construct($wsdl, $options);
23    $this->server = new SoapServer($wsdl, $options);
24    $this->server->addFunction('test');
25  }
26
27  function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
28    ob_start();
29    $this->server->handle($request);
30    $response = ob_get_contents();
31    ob_end_clean();
32    return $response;
33  }
34}
35
36$x = new LocalSoapClient(__DIR__."/bug30928.wsdl",
37                         array());
38var_dump($x->test(new foo()));
39
40$x = new LocalSoapClient(__DIR__."/bug30928.wsdl",
41                         array("classmap" => array('testType'=>'foo')));
42var_dump($x->test(new foo()));
43
44echo "ok\n";
45?>
46--EXPECTF--
47object(stdClass)#%d (3) {
48  ["a"]=>
49  string(1) "a"
50  ["b"]=>
51  string(1) "b"
52  ["c"]=>
53  string(1) "c"
54}
55object(foo)#%d (3) {
56  ["a"]=>
57  string(1) "a"
58  ["b":"foo":private]=>
59  string(1) "b"
60  ["c":protected]=>
61  string(1) "c"
62}
63ok
64