xref: /PHP-8.1/ext/soap/tests/classmap003.phpt (revision 8ae4b560)
1--TEST--
2SOAP Classmap 3: encoding of inherited objects
3--EXTENSIONS--
4soap
5--FILE--
6<?php
7ini_set("soap.wsdl_cache_enabled",0);
8
9class A {
10  public $x;
11  function __construct($a){
12    $this->x = $a;
13  }
14}
15
16class B extends A {
17  public $y;
18  function __construct($a){
19    parent::__construct($a);
20    $this->y = $a + 1;
21  }
22}
23
24function f(){
25  return new B(5);
26}
27
28class LocalSoapClient extends SoapClient {
29
30  function __construct($wsdl, $options) {
31    parent::__construct($wsdl, $options);
32    $this->server = new SoapServer($wsdl, $options);
33    $this->server->addFunction("f");
34  }
35
36  function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
37    ob_start();
38    $this->server->handle($request);
39    $response = ob_get_contents();
40    ob_end_clean();
41    return $response;
42  }
43}
44
45$client = new LocalSoapClient(__DIR__."/classmap003.wsdl",
46    array('classmap'=>array('A'=>'A','B'=>'B')));
47print_r($client->f());
48?>
49--EXPECT--
50B Object
51(
52    [x] => 5
53    [y] => 6
54)
55