classmap003.phpt 996 B

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