Skip to content

Commit 3c4c758

Browse files
committed
Added global namespace to SimpleXMLElement calls, and some other minor refactors.
1 parent b31cb70 commit 3c4c758

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

ToolkitApi/ToolkitServiceXML.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22
namespace ToolkitApi;
33

4-
use ToolkitApi\DateTimeApi;
5-
64
/**
75
* Class XMLWrapper
86
*
@@ -36,7 +34,7 @@ class XMLWrapper
3634
* @param string $options
3735
* @param ToolkitService $ToolkitSrvObj
3836
*/
39-
function __construct($options ='', ToolkitService $ToolkitSrvObj = null)
37+
public function __construct($options ='', ToolkitService $ToolkitSrvObj = null)
4038
{
4139
if (is_string($options)) {
4240
// $options is a string so it must be encoding (assumption for backwards compatibility)
@@ -244,7 +242,7 @@ protected function xmlToObj($xml)
244242
{
245243
$xmlobj = simplexml_load_string($xml);
246244

247-
if (!$xmlobj instanceof SimpleXMLElement) {
245+
if (!$xmlobj instanceof \SimpleXMLElement) {
248246
$badXmlLog = '/tmp/bad.xml';
249247
$this->error = "Unable to parse output XML, which has been logged in $badXmlLog. Possible problems: CCSID, encoding, binary data in an alpha field (use binary/BYTE type instead); if < or > are the problem, consider using CDATA tags.";
250248
error_log($xml, 3, $badXmlLog);
@@ -442,6 +440,7 @@ public function buildXmlIn($inputOutputParams = NULL, array $returnParams = NULL
442440
protected function buildParamXml(ProgramParameter $paramElement)
443441
{
444442
$paramXml = '';
443+
$specialOuterDsName = '';
445444

446445
// build start ds tag
447446
$props = $paramElement->getParamProperties();
@@ -630,7 +629,6 @@ protected function getSingleParamFromXml(\SimpleXMLElement $simpleXmlElement)
630629

631630
// is this a parm, or perhaps a DS??
632631
$elementType = $simpleXmlElement->getName(); // "name" of the XML tag is element type
633-
$elementAttrs = $simpleXmlElement->attributes();
634632

635633
// if this is the outer (parm or return) element, go down one level to either ds or data.
636634
if ($elementType == 'parm' || $elementType == 'return') {
@@ -810,7 +808,7 @@ public function getParamsFromXml($xml)
810808
// or <report> (if unsuccessful)
811809
// Outer node is discarded in parsed XML objects.
812810

813-
if (!$xmlobj instanceof SimpleXMLElement) {
811+
if (!$xmlobj instanceof \SimpleXMLElement) {
814812
$badXmlLog = '/tmp/bad.xml';
815813
$this->error = "Unable to parse output XML, which has been logged in $badXmlLog. Possible problems: CCSID, encoding, binary data in an alpha field (use binary/BYTE type instead); if < or > are the problem, consider using CDATA tags.";
816814
error_log($xml, 3, $badXmlLog);
@@ -947,7 +945,7 @@ public function getCmdResultFromXml($xml, $parentTag = 'sh') {
947945
$this->error = '';
948946

949947
$xmlobj = simplexml_load_string($xml);
950-
if (!$xmlobj instanceof SimpleXMLElement) {
948+
if (!$xmlobj instanceof \SimpleXMLElement) {
951949
/*bad xml returned*/
952950
$this->error = "Can't read output xml";
953951
error_log($xml, 3, '/tmp/bad.xml');
@@ -1058,7 +1056,7 @@ public function getRowsFromXml($xml, $parent = 'sh')
10581056
$values = array();
10591057

10601058
$xmlobj = @simplexml_load_string($xml);
1061-
if (!$xmlobj instanceof SimpleXMLElement) {
1059+
if (!$xmlobj instanceof \SimpleXMLElement) {
10621060
/* bad xml returned*/
10631061
$this->error = "Can't read output xml";
10641062
return false;

0 commit comments

Comments
 (0)