During migration of my code from PHP5 to PHP7, I am facing some pretty issues, One of them are arrayObject(). arrayObject in PHP7 is not behaving as expected, what will be the alternate solution to achieve arrayObject functionality.
//I have some data in this carList array
$carList = array();
$carArray = new ArrayObject();
//Go throuch each car record and populate the car object
foreach ($carList as $lst){
$car = new carDetail();
foreach ($lst as $key=>$value){
$car->{lcfirst($key)} = $value;
}
$car = new SoapVar($car, SOAP_ENC_OBJECT, null, null, 'car');
$carArray->append($car);
}
return $carArray;
It results in following Soap Envelope
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://logistics.website.eu">
<SOAP-ENV:Body>
<ns1:OutgoingNoosGoodsOrder>
</carArray>
</ns1:OutgoingNoosGoodsOrder>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Before migration, it is like this on PHP 5
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://logistics.website.eu">
<SOAP-ENV:Body>
<ns1:OutgoingNoosGoodsOrder>
<carArray>
<car>
<make> Hyundai </make>
<model> Verna </model>
<year> 2019 </year>
</car>
<car>
<make> Audi </make>
<model> Q7 </model>
<year> 2022 </year>
</car>
</carArray>
</ns1:OutgoingNoosGoodsOrder>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>