xref: /php-src/ext/soap/tests/classmap003.phpt (revision 8b561d33)
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  private $server;
30
31  function __construct($wsdl, $options) {
32    parent::__construct($wsdl, $options);
33    $this->server = new SoapServer($wsdl, $options);
34    $this->server->addFunction("f");
35  }
36
37  function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
38    ob_start();
39    $this->server->handle($request);
40    $response = ob_get_contents();
41    ob_end_clean();
42    return $response;
43  }
44}
45
46$client = new LocalSoapClient(__DIR__."/classmap003.wsdl",
47    array('classmap'=>array('A'=>'A','B'=>'B')));
48print_r($client->f());
49?>
50--EXPECT--
51B Object
52(
53    [x] => 5
54    [y] => 6
55)
56