From 7f9b8c23879d6faadf0a3063f368e1bd6edacbe3 Mon Sep 17 00:00:00 2001 From: s-renier-taonix-fr Date: Mon, 13 Feb 2023 11:11:16 +0800 Subject: [PATCH] Optim : 'if' statement with common parts --- src/nusoap.php | 71 +++++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 47 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index a62c59d..91f5533 100755 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -478,8 +478,6 @@ function serialize_val($val, $name = false, $type = false, $name_ns = false, $ty if ($use == 'literal') { // TODO: depends on minOccurs $xml = "<$name$xmlns$atts/>"; - $this->debug("serialize_val returning $xml"); - return $xml; } else { if (isset($type) && isset($type_prefix)) { $type_str = " xsi:type=\"$type_prefix:$type\""; @@ -487,9 +485,9 @@ function serialize_val($val, $name = false, $type = false, $name_ns = false, $ty $type_str = ''; } $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>"; - $this->debug("serialize_val returning $xml"); - return $xml; } + $this->debug("serialize_val returning $xml"); + return $xml; } // serialize if an xsd built-in primitive type if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) { @@ -505,13 +503,11 @@ function serialize_val($val, $name = false, $type = false, $name_ns = false, $ty } if ($use == 'literal') { $xml = "<$name$xmlns$atts>$val"; - $this->debug("serialize_val returning $xml"); - return $xml; } else { $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val"; - $this->debug("serialize_val returning $xml"); - return $xml; } + $this->debug("serialize_val returning $xml"); + return $xml; } // detect type and serialize $xml = ''; @@ -777,10 +773,8 @@ function contractQname($qname) if ($p) { return $p . ':' . $name; } - return $qname; - } else { - return $qname; } + return $qname; } /** @@ -1432,41 +1426,26 @@ function schemaStartElement($parser, $name, $attrs) $this->xdebug('processing named complexType ' . $attrs['name']); //$this->currentElement = false; $this->currentComplexType = $attrs['name']; - $this->complexTypes[$this->currentComplexType] = $attrs; - $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; - // This is for constructs like - // - // - // - // - // - if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) { - $this->xdebug('complexType is unusual array'); - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; - } else { - $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; - } } else { $name = $this->CreateTypeName($this->currentElement); $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name); $this->currentComplexType = $name; //$this->currentElement = false; - $this->complexTypes[$this->currentComplexType] = $attrs; - $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; - // This is for constructs like - // - // - // - // - // - if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) { - $this->xdebug('complexType is unusual array'); - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; - } else { - $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; - } + } + $this->complexTypes[$this->currentComplexType] = $attrs; + $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; + // This is for constructs like + // + // + // + // + // + if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) { + $this->xdebug('complexType is unusual array'); + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; + } else { + $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; } $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false'; break; @@ -7417,7 +7396,6 @@ function buildVal($pos) $ret = is_array($params) ? $params : array(); $this->debug('in buildVal, return:'); $this->appendDebug($this->varDump($ret)); - return $ret; } else { $this->debug('in buildVal, no children, building scalar'); $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; @@ -7434,8 +7412,9 @@ function buildVal($pos) } $ret = $this->message[$pos]['cdata']; $this->debug("in buildVal, return: $ret"); - return $ret; } + + return $ret; } } @@ -8243,10 +8222,10 @@ function _getProxyClassCode($r) $evalStr = ''; foreach ($this->operations as $operation => $opData) { if ($operation != '') { + $paramStr = ''; + $paramArrayStr = ''; // create param string and param comment string if (sizeof($opData['input']['parts']) > 0) { - $paramStr = ''; - $paramArrayStr = ''; $paramCommentStr = ''; foreach ($opData['input']['parts'] as $name => $type) { $paramStr .= "\$$name, "; @@ -8257,8 +8236,6 @@ function _getProxyClassCode($r) $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr) - 2); $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr) - 2); } else { - $paramStr = ''; - $paramArrayStr = ''; $paramCommentStr = 'void'; } $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace'];