xref: /PHP-8.2/ext/soap/tests/bug48557.phpt (revision 7f2f0c00)
1--TEST--
2Bug #48557 (Numeric string keys in Apache Hashmaps are not cast to integers)
3--EXTENSIONS--
4soap
5--FILE--
6<?php
7error_reporting(E_ALL);
8ini_set('display_errors', 1);
9ini_set("soap.wsdl_cache_enabled", 0);
10
11function test($map) {
12    var_dump($map, $map[1], $map[2]);die;
13}
14
15$y = new SoapServer(__DIR__ . '/bug48557.wsdl');
16$y->addfunction("test");
17$request = <<<XML
18<?xml version="1.0"?>
19<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test-uri/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
20    <SOAP-ENV:Body>
21        <ns1:test>
22            <testParam xsi:type="ns2:Map">
23                <item>
24                    <key xsi:type="xsd:int">1</key>
25                    <value xsi:type="xsd:int">123</value>
26                </item>
27                <item>
28                    <key xsi:type="xsd:int">-1000</key>
29                    <value xsi:type="xsd:string">123</value>
30                </item>
31                <item>
32                    <key xsi:type="xsd:string">2</key>
33                    <value xsi:type="xsd:float">123.5</value>
34                </item>
35                <item>
36                    <key xsi:type="xsd:string">-2000</key>
37                    <value xsi:type="xsd:float">123.5</value>
38                </item>
39                <item>
40                    <key xsi:type="xsd:string">011</key>
41                    <value xsi:type="xsd:float">123.5</value>
42                </item>
43                <item>
44                    <key xsi:type="xsd:int">012</key>
45                    <value xsi:type="xsd:float">123.5</value>
46                </item>
47            </testParam>
48        </ns1:test>
49    </SOAP-ENV:Body>
50</SOAP-ENV:Envelope>
51XML;
52
53$y->handle($request);
54
55?>
56===DONE===
57--EXPECT--
58array(6) {
59  [1]=>
60  int(123)
61  [-1000]=>
62  string(3) "123"
63  [2]=>
64  float(123.5)
65  [-2000]=>
66  float(123.5)
67  ["011"]=>
68  float(123.5)
69  [12]=>
70  float(123.5)
71}
72int(123)
73float(123.5)
74