From e10d4c0ad565b5b6038cd3e41baf3d172ceeaad8 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 10 Jun 2018 19:26:51 -0400 Subject: [PATCH 01/40] php-cs-fixer --- src/nusoap.php | 803 ++++++++++++++++++++++++------------------------- 1 file changed, 399 insertions(+), 404 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index f5ad76f..ef43a6d 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -91,35 +91,35 @@ class nusoap_base * @var string * @access private */ - var $title = 'NuSOAP'; + public $title = 'NuSOAP'; /** * Version for HTTP headers. * * @var string * @access private */ - var $version = '0.9.5'; + public $version = '0.9.5'; /** * CVS revision for HTTP headers. * * @var string * @access private */ - var $revision = '$Revision: 1.123 $'; + public $revision = '$Revision: 1.123 $'; /** * Current error string (manipulated by getError/setError) * * @var string * @access private */ - var $error_str = ''; + public $error_str = ''; /** * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment) * * @var string * @access private */ - var $debug_str = ''; + public $debug_str = ''; /** * toggles automatic encoding of special characters as entities * (should always be true, I think) @@ -127,14 +127,14 @@ class nusoap_base * @var boolean * @access private */ - var $charencoding = true; + public $charencoding = true; /** * the debug level for this instance * * @var integer * @access private */ - var $debugLevel; + public $debugLevel; /** * set schema version @@ -142,7 +142,7 @@ class nusoap_base * @var string * @access public */ - var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; + public $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; /** * charset encoding for outgoing messages @@ -150,7 +150,7 @@ class nusoap_base * @var string * @access public */ - var $soap_defencoding = 'ISO-8859-1'; + public $soap_defencoding = 'ISO-8859-1'; //var $soap_defencoding = 'UTF-8'; /** @@ -161,7 +161,7 @@ class nusoap_base * @var array * @access public */ - var $namespaces = array( + public $namespaces = array( 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xsd' => 'http://www.w3.org/2001/XMLSchema', 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', @@ -174,7 +174,7 @@ class nusoap_base * @var array * @access private */ - var $usedNamespaces = array(); + public $usedNamespaces = array(); /** * XML Schema types in an array of uri => (array of xml type => php type) @@ -184,7 +184,7 @@ class nusoap_base * @var array * @access public */ - var $typemap = array( + public $typemap = array( 'http://www.w3.org/2001/XMLSchema' => array( 'string' => 'string', 'boolean' => 'boolean', 'float' => 'double', 'double' => 'double', 'decimal' => 'double', 'duration' => '', 'dateTime' => 'string', 'time' => 'string', 'date' => 'string', 'gYearMonth' => '', @@ -217,7 +217,7 @@ class nusoap_base * @deprecated * @see expandEntities */ - var $xmlEntities = array('quot' => '"', 'amp' => '&', + public $xmlEntities = array('quot' => '"', 'amp' => '&', 'lt' => '<', 'gt' => '>', 'apos' => "'"); /** @@ -225,7 +225,7 @@ class nusoap_base * * @access public */ - function __construct() + public function __construct() { $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; } @@ -236,7 +236,7 @@ function __construct() * @return integer Debug level 0-9, where 0 turns off * @access public */ - function getGlobalDebugLevel() + public function getGlobalDebugLevel() { return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; } @@ -247,7 +247,7 @@ function getGlobalDebugLevel() * @param int $level Debug level 0-9, where 0 turns off * @access public */ - function setGlobalDebugLevel($level) + public function setGlobalDebugLevel($level) { $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level; } @@ -258,7 +258,7 @@ function setGlobalDebugLevel($level) * @return int Debug level 0-9, where 0 turns off * @access public */ - function getDebugLevel() + public function getDebugLevel() { return $this->debugLevel; } @@ -269,7 +269,7 @@ function getDebugLevel() * @param int $level Debug level 0-9, where 0 turns off * @access public */ - function setDebugLevel($level) + public function setDebugLevel($level) { $this->debugLevel = $level; } @@ -280,7 +280,7 @@ function setDebugLevel($level) * @param string $string debug data * @access private */ - function debug($string) + public function debug($string) { if ($this->debugLevel > 0) { $this->appendDebug($this->getmicrotime() . ' ' . get_class($this) . ": $string\n"); @@ -293,7 +293,7 @@ function debug($string) * @param string $string debug data * @access public */ - function appendDebug($string) + public function appendDebug($string) { if ($this->debugLevel > 0) { // it would be nice to use a memory stream here to use @@ -307,7 +307,7 @@ function appendDebug($string) * * @access public */ - function clearDebug() + public function clearDebug() { // it would be nice to use a memory stream here to use // memory more efficiently @@ -320,7 +320,7 @@ function clearDebug() * @return debug data * @access public */ - function &getDebug() + public function &getDebug() { // it would be nice to use a memory stream here to use // memory more efficiently @@ -334,7 +334,7 @@ function &getDebug() * @return debug data as an XML comment * @access public */ - function &getDebugAsXMLComment() + public function &getDebugAsXMLComment() { // it would be nice to use a memory stream here to use // memory more efficiently @@ -351,7 +351,7 @@ function &getDebugAsXMLComment() * @param string $val The string in which to expand entities. * @access private */ - function expandEntities($val) + public function expandEntities($val) { if ($this->charencoding) { $val = str_replace('&', '&', $val); @@ -369,7 +369,7 @@ function expandEntities($val) * @return mixed error string or false * @access public */ - function getError() + public function getError() { if ($this->error_str != '') { return $this->error_str; @@ -383,7 +383,7 @@ function getError() * @return boolean $string error string * @access private */ - function setError($str) + public function setError($str) { $this->error_str = $str; } @@ -395,7 +395,7 @@ function setError($str) * @return string (arraySimple|arrayStruct) * @access private */ - function isArraySimpleOrStruct($val) + public function isArraySimpleOrStruct($val) { $keyList = array_keys($val); foreach ($keyList as $keyListValue) { @@ -421,7 +421,7 @@ function isArraySimpleOrStruct($val) * @return string The serialized element, possibly with child elements * @access public */ - function serialize_val($val, $name = false, $type = false, $name_ns = false, $type_ns = false, $attributes = false, $use = 'encoded', $soapval = false) + public function serialize_val($val, $name = false, $type = false, $name_ns = false, $type_ns = false, $attributes = false, $use = 'encoded', $soapval = false) { $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval"); $this->appendDebug('value=' . $this->varDump($val)); @@ -688,7 +688,7 @@ function serialize_val($val, $name = false, $type = false, $name_ns = false, $ty * @return string the message * @access public */ - function serializeEnvelope($body, $headers = false, $namespaces = array(), $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/') + public function serializeEnvelope($body, $headers = false, $namespaces = array(), $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/') { // TODO: add an option to automatically run utf8_encode on $body and $headers // if $this->soap_defencoding is UTF-8. Not doing this automatically allows @@ -744,7 +744,7 @@ function serializeEnvelope($body, $headers = false, $namespaces = array(), $styl * @access public * @deprecated */ - function formatDump($str) + public function formatDump($str) { $str = htmlspecialchars($str); return nl2br($str); @@ -757,7 +757,7 @@ function formatDump($str) * @return string contracted qname * @access private */ - function contractQname($qname) + public function contractQname($qname) { // get element namespace //$this->xdebug("Contract $qname"); @@ -783,7 +783,7 @@ function contractQname($qname) * @return string expanded qname * @access private */ - function expandQname($qname) + public function expandQname($qname) { // get element prefix if (strpos($qname, ':') && !preg_match('/^http:\/\//', $qname)) { @@ -809,7 +809,7 @@ function expandQname($qname) * @return string The local part * @access public */ - function getLocalPart($str) + public function getLocalPart($str) { if ($sstr = strrchr($str, ':')) { // get unqualified name @@ -827,7 +827,7 @@ function getLocalPart($str) * @return mixed The prefix or false if there is no prefix * @access public */ - function getPrefix($str) + public function getPrefix($str) { if ($pos = strrpos($str, ':')) { // get prefix @@ -843,7 +843,7 @@ function getPrefix($str) * @return mixed The namespace, false if no namespace has the specified prefix * @access public */ - function getNamespaceFromPrefix($prefix) + public function getNamespaceFromPrefix($prefix) { if (isset($this->namespaces[$prefix])) { return $this->namespaces[$prefix]; @@ -860,7 +860,7 @@ function getNamespaceFromPrefix($prefix) * @return mixed The prefix, false if the namespace has no prefixes * @access public */ - function getPrefixFromNamespace($ns) + public function getPrefixFromNamespace($ns) { foreach ($this->namespaces as $p => $n) { if ($ns == $n || $ns == $p) { @@ -877,7 +877,7 @@ function getPrefixFromNamespace($ns) * @return string The time in ODBC canonical form with microseconds * @access public */ - function getmicrotime() + public function getmicrotime() { if (function_exists('gettimeofday')) { $tod = gettimeofday(); @@ -897,7 +897,7 @@ function getmicrotime() * @return string The output of var_dump * @access public */ - function varDump($data) + public function varDump($data) { ob_start(); var_dump($data); @@ -912,7 +912,7 @@ function varDump($data) * @return string * @access public */ - function __toString() + public function __toString() { return $this->varDump($this); } @@ -997,7 +997,7 @@ function iso8601_to_timestamp($datestr) } } return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); -// return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z"); + // return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z"); } else { return false; } @@ -1039,28 +1039,28 @@ class nusoap_fault extends nusoap_base * @var string * @access private */ - var $faultcode; + public $faultcode; /** * The fault actor * * @var string * @access private */ - var $faultactor; + public $faultactor; /** * The fault string, a description of the fault * * @var string * @access private */ - var $faultstring; + public $faultstring; /** * The fault detail, typically a string or array of string * * @var mixed * @access private */ - var $faultdetail; + public $faultdetail; /** * constructor @@ -1070,7 +1070,7 @@ class nusoap_fault extends nusoap_base * @param string $faultstring human readable error message * @param mixed $faultdetail detail, typically a string or array of string */ - function __construct($faultcode, $faultactor = '', $faultstring = '', $faultdetail = '') + public function __construct($faultcode, $faultactor = '', $faultstring = '', $faultdetail = '') { parent::__construct(); $this->faultcode = $faultcode; @@ -1085,7 +1085,7 @@ function __construct($faultcode, $faultactor = '', $faultstring = '', $faultdeta * @return string The serialization of the fault instance. * @access public */ - function serialize() + public function serialize() { $ns_string = ''; foreach ($this->namespaces as $k => $v) { @@ -1129,33 +1129,33 @@ class nusoap_xmlschema extends nusoap_base { // files - var $schema = ''; - var $xml = ''; + public $schema = ''; + public $xml = ''; // namespaces - var $enclosingNamespaces; + public $enclosingNamespaces; // schema info - var $schemaInfo = array(); - var $schemaTargetNamespace = ''; + public $schemaInfo = array(); + public $schemaTargetNamespace = ''; // types, elements, attributes defined by the schema - var $attributes = array(); - var $complexTypes = array(); - var $complexTypeStack = array(); - var $currentComplexType = null; - var $elements = array(); - var $elementStack = array(); - var $currentElement = null; - var $simpleTypes = array(); - var $simpleTypeStack = array(); - var $currentSimpleType = null; + public $attributes = array(); + public $complexTypes = array(); + public $complexTypeStack = array(); + public $currentComplexType = null; + public $elements = array(); + public $elementStack = array(); + public $currentElement = null; + public $simpleTypes = array(); + public $simpleTypeStack = array(); + public $currentSimpleType = null; // imports - var $imports = array(); + public $imports = array(); // parser vars - var $parser; - var $position = 0; - var $depth = 0; - var $depth_array = array(); - var $message = array(); - var $defaultNamespace = array(); + public $parser; + public $position = 0; + public $depth = 0; + public $depth_array = array(); + public $message = array(); + public $defaultNamespace = array(); /** * constructor @@ -1165,7 +1165,7 @@ class nusoap_xmlschema extends nusoap_base * @param string $namespaces namespaces defined in enclosing XML * @access public */ - function __construct($schema = '', $xml = '', $namespaces = array()) + public function __construct($schema = '', $xml = '', $namespaces = array()) { parent::__construct(); $this->debug('nusoap_xmlschema class instantiated, inside constructor'); @@ -1188,7 +1188,6 @@ function __construct($schema = '', $xml = '', $namespaces = array()) $this->debug('initial xml file: ' . $xml); $this->parseFile($xml, 'xml'); } - } /** @@ -1199,7 +1198,7 @@ function __construct($schema = '', $xml = '', $namespaces = array()) * @return boolean * @access public */ - function parseFile($xml, $type) + public function parseFile($xml, $type) { // parse xml file if ($xml != "") { @@ -1226,7 +1225,7 @@ function parseFile($xml, $type) * @param string $type (schema|xml) * @access private */ - function parseString($xml, $type) + public function parseString($xml, $type) { // parse xml string if ($xml != "") { @@ -1251,7 +1250,8 @@ function parseString($xml, $type) // Parse the XML file. if (!xml_parse($this->parser, $xml, true)) { // Display an error message. - $errstr = sprintf('XML error parsing XML schema on line %d: %s', + $errstr = sprintf( + 'XML error parsing XML schema on line %d: %s', xml_get_current_line_number($this->parser), xml_error_string(xml_get_error_code($this->parser)) ); @@ -1275,7 +1275,7 @@ function parseString($xml, $type) * @return string A type name for an unnamed type * @access private */ - function CreateTypeName($ename) + public function CreateTypeName($ename) { $scope = ''; for ($i = 0; $i < count($this->complexTypeStack); $i++) { @@ -1292,7 +1292,7 @@ function CreateTypeName($ename) * @param string $attrs associative array of attributes * @access private */ - function schemaStartElement($parser, $name, $attrs) + public function schemaStartElement($parser, $name, $attrs) { // position in the total number of elements, starting from 0 @@ -1620,7 +1620,7 @@ function schemaStartElement($parser, $name, $attrs) * @param string $name element name * @access private */ - function schemaEndElement($parser, $name) + public function schemaEndElement($parser, $name) { // bring depth down a notch $this->depth--; @@ -1660,7 +1660,7 @@ function schemaEndElement($parser, $name) * @param string $data element content * @access private */ - function schemaCharacterData($parser, $data) + public function schemaCharacterData($parser, $data) { $pos = $this->depth_array[$this->depth - 1]; $this->message[$pos]['cdata'] .= $data; @@ -1671,9 +1671,8 @@ function schemaCharacterData($parser, $data) * * @access public */ - function serializeSchema() + public function serializeSchema() { - $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); $xml = ''; // imports @@ -1790,7 +1789,7 @@ function serializeSchema() * @param string $string debug data * @access private */ - function xdebug($string) + public function xdebug($string) { $this->debug('<' . $this->schemaTargetNamespace . '> ' . $string); } @@ -1807,7 +1806,7 @@ function xdebug($string) * @access public * @deprecated */ - function getPHPType($type, $ns) + public function getPHPType($type, $ns) { if (isset($this->typemap[$ns][$type])) { //print "found type '$type' and ns $ns in typemap
"; @@ -1841,7 +1840,7 @@ function getPHPType($type, $ns) * @see addSimpleType * @see addElement */ - function getTypeDef($type) + public function getTypeDef($type) { //$this->debug("in getTypeDef for type $type"); if (substr($type, -1) == '^') { @@ -1921,7 +1920,7 @@ function getTypeDef($type) * @access public * @deprecated */ - function serializeTypeDef($type) + public function serializeTypeDef($type) { //print "in sTD() for type $type
"; if ($typeDef = $this->getTypeDef($type)) { @@ -1958,7 +1957,7 @@ function serializeTypeDef($type) * @access public * @deprecated */ - function typeToForm($name, $type) + public function typeToForm($name, $type) { // get typedef if ($typeDef = $this->getTypeDef($type)) { @@ -1971,7 +1970,7 @@ function typeToForm($name, $type) "; } $buffer .= ''; - // if array + // if array } elseif ($typeDef['phpType'] == 'array') { $buffer .= ''; for ($i = 0; $i < 3; $i++) { @@ -1980,7 +1979,7 @@ function typeToForm($name, $type) "; } $buffer .= '
'; - // if scalar + // if scalar } else { $buffer .= ""; } @@ -2031,7 +2030,7 @@ function typeToForm($name, $type) * @access public * @see getTypeDef */ - function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') + public function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') { $this->complexTypes[$name] = array( 'name' => $name, @@ -2060,7 +2059,7 @@ function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $ * @see nusoap_xmlschema * @see getTypeDef */ - function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) + public function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) { $this->simpleTypes[$name] = array( 'name' => $name, @@ -2081,7 +2080,7 @@ function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', * @see nusoap_xmlschema * @access public */ - function addElement($attrs) + public function addElement($attrs) { if (!$this->getPrefix($attrs['type'])) { $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; @@ -2121,42 +2120,42 @@ class soapval extends nusoap_base * @var string * @access private */ - var $name; + public $name; /** * The XML type name (string or false) * * @var mixed * @access private */ - var $type; + public $type; /** * The PHP value * * @var mixed * @access private */ - var $value; + public $value; /** * The XML element namespace (string or false) * * @var mixed * @access private */ - var $element_ns; + public $element_ns; /** * The XML type namespace (string or false) * * @var mixed * @access private */ - var $type_ns; + public $type_ns; /** * The XML element attributes (array or false) * * @var mixed * @access private */ - var $attributes; + public $attributes; /** * constructor @@ -2169,7 +2168,7 @@ class soapval extends nusoap_base * @param mixed $attributes associative array of attributes to add to element serialization * @access public */ - function __construct($name = 'soapval', $type = false, $value = -1, $element_ns = false, $type_ns = false, $attributes = false) + public function __construct($name = 'soapval', $type = false, $value = -1, $element_ns = false, $type_ns = false, $attributes = false) { parent::__construct(); $this->name = $name; @@ -2187,7 +2186,7 @@ function __construct($name = 'soapval', $type = false, $value = -1, $element_ns * @return string XML data * @access public */ - function serialize($use = 'encoded') + public function serialize($use = 'encoded') { return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true); } @@ -2198,7 +2197,7 @@ function serialize($use = 'encoded') * @return mixed * @access public */ - function decode() + public function decode() { return $this->value; } @@ -2216,34 +2215,33 @@ function decode() */ class soap_transport_http extends nusoap_base { - - var $url = ''; - var $uri = ''; - var $digest_uri = ''; - var $scheme = ''; - var $host = ''; - var $port = ''; - var $path = ''; - var $request_method = 'POST'; - var $protocol_version = '1.0'; - var $encoding = ''; - var $outgoing_headers = array(); - var $incoming_headers = array(); - var $incoming_cookies = array(); - var $outgoing_payload = ''; - var $incoming_payload = ''; - var $response_status_line; // HTTP response status line - var $useSOAPAction = true; - var $persistentConnection = false; - var $ch = false; // cURL handle - var $ch_options = array(); // cURL custom options - var $use_curl = false; // force cURL use - var $proxy = null; // proxy information (associative array) - var $username = ''; - var $password = ''; - var $authtype = ''; - var $digestRequest = array(); - var $certRequest = array(); // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional) + public $url = ''; + public $uri = ''; + public $digest_uri = ''; + public $scheme = ''; + public $host = ''; + public $port = ''; + public $path = ''; + public $request_method = 'POST'; + public $protocol_version = '1.0'; + public $encoding = ''; + public $outgoing_headers = array(); + public $incoming_headers = array(); + public $incoming_cookies = array(); + public $outgoing_payload = ''; + public $incoming_payload = ''; + public $response_status_line; // HTTP response status line + public $useSOAPAction = true; + public $persistentConnection = false; + public $ch = false; // cURL handle + public $ch_options = array(); // cURL custom options + public $use_curl = false; // force cURL use + public $proxy = null; // proxy information (associative array) + public $username = ''; + public $password = ''; + public $authtype = ''; + public $digestRequest = array(); + public $certRequest = array(); // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional) // cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem' // sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem' // sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem' @@ -2260,7 +2258,7 @@ class soap_transport_http extends nusoap_base * @param boolean $use_curl Whether to try to force cURL use * @access public */ - function __construct($url, $curl_options = null, $use_curl = false) + public function __construct($url, $curl_options = null, $use_curl = false) { parent::__construct(); $this->debug("ctor url=$url use_curl=$use_curl curl_options:"); @@ -2281,7 +2279,7 @@ function __construct($url, $curl_options = null, $use_curl = false) * @param mixed $value The cURL option value * @access private */ - function setCurlOption($option, $value) + public function setCurlOption($option, $value) { $this->debug("setCurlOption option=$option, value="); $this->appendDebug($this->varDump($value)); @@ -2295,7 +2293,7 @@ function setCurlOption($option, $value) * @param string $value The value of the header * @access private */ - function setHeader($name, $value) + public function setHeader($name, $value) { $this->outgoing_headers[$name] = $value; $this->debug("set header $name: $value"); @@ -2307,7 +2305,7 @@ function setHeader($name, $value) * @param string $name The name of the header * @access private */ - function unsetHeader($name) + public function unsetHeader($name) { if (isset($this->outgoing_headers[$name])) { $this->debug("unset header $name"); @@ -2321,7 +2319,7 @@ function unsetHeader($name) * @param string $url The URL to which to connect * @access private */ - function setURL($url) + public function setURL($url) { $this->url = $url; @@ -2366,7 +2364,7 @@ function setURL($url) * @return string I/O method to use (socket|curl|unknown) * @access private */ - function io_method() + public function io_method() { if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) { return 'curl'; @@ -2385,20 +2383,20 @@ function io_method() * @return boolean true if connected, false if not * @access private */ - function connect($connection_timeout = 0, $response_timeout = 30) + public function connect($connection_timeout = 0, $response_timeout = 30) { // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like // "regular" socket. // TODO: disabled for now because OpenSSL must be *compiled* in (not just // loaded), and until PHP5 stream_get_wrappers is not available. -// if ($this->scheme == 'https') { -// if (version_compare(phpversion(), '4.3.0') >= 0) { -// if (extension_loaded('openssl')) { -// $this->scheme = 'ssl'; -// $this->debug('Using SSL over OpenSSL'); -// } -// } -// } + // if ($this->scheme == 'https') { + // if (version_compare(phpversion(), '4.3.0') >= 0) { + // if (extension_loaded('openssl')) { + // $this->scheme = 'ssl'; + // $this->debug('Using SSL over OpenSSL'); + // } + // } + // } $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port"); if ($this->io_method() == 'socket') { if (!is_array($this->proxy)) { @@ -2453,7 +2451,7 @@ function connect($connection_timeout = 0, $response_timeout = 30) return true; } elseif ($this->io_method() == 'curl') { if (!extension_loaded('curl')) { -// $this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS'); + // $this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS'); $this->setError('The PHP cURL Extension is required for HTTPS or NLTM. You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.'); return false; } @@ -2513,9 +2511,9 @@ function connect($connection_timeout = 0, $response_timeout = 30) $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1); // encode // We manage this ourselves through headers and encoding -// if(function_exists('gzuncompress')){ -// $this->setCurlOption(CURLOPT_ENCODING, 'deflate'); -// } + // if(function_exists('gzuncompress')){ + // $this->setCurlOption(CURLOPT_ENCODING, 'deflate'); + // } // persistent connection if ($this->persistentConnection) { // I believe the following comment is now bogus, having applied to @@ -2539,7 +2537,7 @@ function connect($connection_timeout = 0, $response_timeout = 30) // recent versions of cURL turn on peer/host checking by default, // while PHP binaries are not compiled with a default location for the // CA cert bundle, so disable peer/host checking. - //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt'); + //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt'); $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0); $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0); @@ -2628,9 +2626,8 @@ function connect($connection_timeout = 0, $response_timeout = 30) * @return string data * @access public */ - function send($data, $timeout = 0, $response_timeout = 30, $cookies = null) + public function send($data, $timeout = 0, $response_timeout = 30, $cookies = null) { - $this->debug('entered send() with data of length: ' . strlen($data)); $this->tryagain = true; @@ -2670,7 +2667,7 @@ function send($data, $timeout = 0, $response_timeout = 30, $cookies = null) * @access public * @deprecated */ - function sendHTTPS($data, $timeout = 0, $response_timeout = 30, $cookies) + public function sendHTTPS($data, $timeout = 0, $response_timeout = 30, $cookies) { return $this->send($data, $timeout, $response_timeout, $cookies); } @@ -2685,7 +2682,7 @@ function sendHTTPS($data, $timeout = 0, $response_timeout = 30, $cookies) * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) * @access public */ - function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) + public function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) { $this->debug("setCredentials username=$username authtype=$authtype digestRequest="); $this->appendDebug($this->varDump($digestRequest)); @@ -2760,7 +2757,7 @@ function setCredentials($username, $password, $authtype = 'basic', $digestReques * @param string $soapaction * @access public */ - function setSOAPAction($soapaction) + public function setSOAPAction($soapaction) { $this->setHeader('SOAPAction', '"' . $soapaction . '"'); } @@ -2771,7 +2768,7 @@ function setSOAPAction($soapaction) * @param string $enc encoding style. supported values: gzip, deflate, or both * @access public */ - function setEncoding($enc = 'gzip, deflate') + public function setEncoding($enc = 'gzip, deflate') { if (function_exists('gzdeflate')) { $this->protocol_version = '1.1'; @@ -2796,7 +2793,7 @@ function setEncoding($enc = 'gzip, deflate') * @param string $proxyauthtype (basic|ntlm) * @access public */ - function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') + public function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') { if ($proxyhost) { $this->proxy = array( @@ -2825,7 +2822,7 @@ function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = * @returns boolean Whether a skippable header was found. * @access private */ - function isSkippableCurlHeader(&$data) + public function isSkippableCurlHeader(&$data) { $skipHeaders = array('HTTP/1.1 100', 'HTTP/1.0 301', @@ -2855,7 +2852,7 @@ function isSkippableCurlHeader(&$data) * @access public * @deprecated */ - function decodeChunked($buffer, $lb) + public function decodeChunked($buffer, $lb) { // length := 0 $length = 0; @@ -2913,7 +2910,7 @@ function decodeChunked($buffer, $lb) * @return void * @access private */ - function buildPayload($data, $cookie_str = '') + public function buildPayload($data, $cookie_str = '') { // Note: for cURL connections, $this->outgoing_payload is ignored, // as is the Content-Length header, but these are still created as @@ -2963,7 +2960,7 @@ function buildPayload($data, $cookie_str = '') * @return boolean true if OK, false if problem * @access private */ - function sendRequest($data, $cookies = null) + public function sendRequest($data, $cookies = null) { // build cookie string $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https'))); @@ -3021,7 +3018,7 @@ function sendRequest($data, $cookies = null) * @return string the response (also sets member variables like incoming_payload) * @access private */ - function getResponse() + public function getResponse() { $this->incoming_payload = ''; @@ -3188,7 +3185,6 @@ function getResponse() // set decoded payload // $this->incoming_payload = $header_data.$lb.$lb.$data; // } - } elseif ($this->io_method() == 'curl') { // send and receive $this->debug('send and receive with cURL'); @@ -3401,7 +3397,7 @@ function getResponse() * @param mixed $charset character set used for encoding (or false) * @access public */ - function setContentType($type, $charset = false) + public function setContentType($type, $charset = false) { $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : '')); } @@ -3412,7 +3408,7 @@ function setContentType($type, $charset = false) * @return boolean whether the request was honored by this method. * @access public */ - function usePersistentConnection() + public function usePersistentConnection() { if (isset($this->outgoing_headers['Accept-Encoding'])) { return false; @@ -3431,9 +3427,9 @@ function usePersistentConnection() * @access private */ /* - * TODO: allow a Set-Cookie string to be parsed into multiple cookies - */ - function parseCookie($cookie_str) + * TODO: allow a Set-Cookie string to be parsed into multiple cookies + */ + public function parseCookie($cookie_str) { $cookie_str = str_replace('; ', ';', $cookie_str) . ';'; $data = preg_split('/;/', $cookie_str); @@ -3498,7 +3494,7 @@ function parseCookie($cookie_str) * @return string for Cookie-HTTP-Header * @access private */ - function getCookiesForRequest($cookies, $secure = false) + public function getCookiesForRequest($cookies, $secure = false) { $cookie_str = ''; if ((!is_null($cookies)) && (is_array($cookies))) { @@ -3558,84 +3554,84 @@ class nusoap_server extends nusoap_base * @var array * @access private */ - var $headers = array(); + public $headers = array(); /** * HTTP request * * @var string * @access private */ - var $request = ''; + public $request = ''; /** * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text) * * @var string * @access public */ - var $requestHeaders = ''; + public $requestHeaders = ''; /** * SOAP Headers from request (parsed) * * @var mixed * @access public */ - var $requestHeader = null; + public $requestHeader = null; /** * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text) * * @var string * @access public */ - var $document = ''; + public $document = ''; /** * SOAP payload for request (text) * * @var string * @access public */ - var $requestSOAP = ''; + public $requestSOAP = ''; /** * requested method namespace URI * * @var string * @access private */ - var $methodURI = ''; + public $methodURI = ''; /** * name of method requested * * @var string * @access private */ - var $methodname = ''; + public $methodname = ''; /** * method parameters from request * * @var array * @access private */ - var $methodparams = array(); + public $methodparams = array(); /** * SOAP Action from request * * @var string * @access private */ - var $SOAPAction = ''; + public $SOAPAction = ''; /** * character set encoding of incoming (request) messages * * @var string * @access public */ - var $xml_encoding = ''; + public $xml_encoding = ''; /** * toggles whether the parser decodes element content w/ utf8_decode() * * @var boolean * @access public */ - var $decode_utf8 = true; + public $decode_utf8 = true; /** * HTTP headers of response @@ -3643,56 +3639,56 @@ class nusoap_server extends nusoap_base * @var array * @access public */ - var $outgoing_headers = array(); + public $outgoing_headers = array(); /** * HTTP response * * @var string * @access private */ - var $response = ''; + public $response = ''; /** * SOAP headers for response (text or array of soapval or associative array) * * @var mixed * @access public */ - var $responseHeaders = ''; + public $responseHeaders = ''; /** * SOAP payload for response (text) * * @var string * @access private */ - var $responseSOAP = ''; + public $responseSOAP = ''; /** * method return value to place in response * * @var mixed * @access private */ - var $methodreturn = false; + public $methodreturn = false; /** * whether $methodreturn is a string of literal XML * * @var boolean * @access public */ - var $methodreturnisliteralxml = false; + public $methodreturnisliteralxml = false; /** * SOAP fault for response (or false) * * @var mixed * @access private */ - var $fault = false; + public $fault = false; /** * text indication of result (for debugging) * * @var string * @access private */ - var $result = 'successful'; + public $result = 'successful'; /** * assoc array of operations => opData; operations are added by the register() @@ -3701,28 +3697,28 @@ class nusoap_server extends nusoap_base * @var array * @access private */ - var $operations = array(); + public $operations = array(); /** * wsdl instance (if one) * * @var mixed * @access private */ - var $wsdl = false; + public $wsdl = false; /** * URL for WSDL (if one) * * @var mixed * @access private */ - var $externalWSDLURL = false; + public $externalWSDLURL = false; /** * whether to append debug to response as XML comment * * @var boolean * @access public */ - var $debug_flag = false; + public $debug_flag = false; /** @@ -3732,7 +3728,7 @@ class nusoap_server extends nusoap_base * @param mixed $wsdl file path or URL (string), or wsdl instance (object) * @access public */ - function __construct($wsdl = false) + public function __construct($wsdl = false) { parent::__construct(); // turn on debugging? @@ -3796,7 +3792,7 @@ function __construct($wsdl = false) * @param string $data usually is the value of $HTTP_RAW_POST_DATA * @access public */ - function service($data) + public function service($data) { global $HTTP_SERVER_VARS; @@ -3881,7 +3877,7 @@ function service($data) * * @access private */ - function parse_http_headers() + public function parse_http_headers() { global $HTTP_SERVER_VARS; @@ -4010,7 +4006,7 @@ function parse_http_headers() * @param string $data XML string * @access private */ - function parse_request($data = '') + public function parse_request($data = '') { $this->debug('entering parse_request()'); $this->parse_http_headers(); @@ -4058,7 +4054,7 @@ function parse_request($data = '') * * @access private */ - function invoke_method() + public function invoke_method() { $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction); @@ -4195,7 +4191,7 @@ function invoke_method() $call_arg = array($class, $method); } else { $this->debug('in invoke_method, calling instance method using call_user_func_array()'); - $instance = new $class (); + $instance = new $class(); $call_arg = array(&$instance, $method); } if (is_array($this->methodparams)) { @@ -4220,7 +4216,7 @@ function invoke_method() * * @access private */ - function serialize_return() + public function serialize_return() { $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI); // if fault @@ -4230,7 +4226,7 @@ function serialize_return() return; } elseif ($this->methodreturnisliteralxml) { $return_val = $this->methodreturn; - // returned value(s) + // returned value(s) } else { $this->debug('got a(n) ' . gettype($this->methodreturn) . ' from method'); $this->debug('serializing return value'); @@ -4321,7 +4317,7 @@ function serialize_return() * * @access private */ - function send_response() + public function send_response() { $this->debug('Enter send_response'); if ($this->fault) { @@ -4401,7 +4397,7 @@ function send_response() * @return boolean Whether the operation was found * @access private */ - function verify_method($operation, $request) + public function verify_method($operation, $request) { if (isset($this->wsdl) && is_object($this->wsdl)) { if ($this->wsdl->getOperationData($operation)) { @@ -4421,7 +4417,7 @@ function verify_method($operation, $request) * @return mixed value of the message, decoded into a PHP type * @access private */ - function parseRequest($headers, $data) + public function parseRequest($headers, $data) { $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:'); $this->appendDebug($this->varDump($headers)); @@ -4454,7 +4450,7 @@ function parseRequest($headers, $data) if ($err = $parser->getError()) { $this->result = 'fault: error in msg parsing: ' . $err; $this->fault('SOAP-ENV:Client', "error in msg parsing:\n" . $err); - // else successfully parsed request into soapval object + // else successfully parsed request into soapval object } else { // get/set methodname $this->methodURI = $parser->root_struct_namespace; @@ -4478,7 +4474,7 @@ function parseRequest($headers, $data) * @return string The HTTP body, which includes the SOAP payload * @access private */ - function getHTTPBody($soapmsg) + public function getHTTPBody($soapmsg) { return $soapmsg; } @@ -4491,7 +4487,7 @@ function getHTTPBody($soapmsg) * @return string the HTTP content type for the current response. * @access private */ - function getHTTPContentType() + public function getHTTPContentType() { return 'text/xml'; } @@ -4505,7 +4501,7 @@ function getHTTPContentType() * @return string the HTTP content type charset for the current response. * @access private */ - function getHTTPContentTypeCharset() + public function getHTTPContentTypeCharset() { return $this->soap_defencoding; } @@ -4519,7 +4515,7 @@ function getHTTPContentTypeCharset() * @access public * @deprecated */ - function add_to_map($methodname, $in, $out) + public function add_to_map($methodname, $in, $out) { $this->operations[$methodname] = array('name' => $methodname, 'in' => $in, 'out' => $out); } @@ -4538,7 +4534,7 @@ function add_to_map($methodname, $in, $out) * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) * @access public */ - function register($name, $in = array(), $out = array(), $namespace = false, $soapaction = false, $style = false, $use = false, $documentation = '', $encodingStyle = '') + public function register($name, $in = array(), $out = array(), $namespace = false, $soapaction = false, $style = false, $use = false, $documentation = '', $encodingStyle = '') { global $HTTP_SERVER_VARS; @@ -4608,7 +4604,7 @@ function register($name, $in = array(), $out = array(), $namespace = false, $soa * @param string $faultdetail * @access public */ - function fault($faultcode, $faultstring, $faultactor = '', $faultdetail = '') + public function fault($faultcode, $faultstring, $faultactor = '', $faultdetail = '') { if ($faultdetail == '' && $this->debug_flag) { $faultdetail = $this->getDebug(); @@ -4628,7 +4624,7 @@ function fault($faultcode, $faultstring, $faultactor = '', $faultdetail = '') * @param string $transport optional SOAP transport * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false */ - function configureWSDL($serviceName, $namespace = false, $endpoint = false, $style = 'rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false) + public function configureWSDL($serviceName, $namespace = false, $endpoint = false, $style = 'rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false) { global $HTTP_SERVER_VARS; @@ -4720,46 +4716,46 @@ class soap_server extends nusoap_server class wsdl extends nusoap_base { // URL or filename of the root of this WSDL - var $wsdl; + public $wsdl; // define internal arrays of bindings, ports, operations, messages, etc. - var $schemas = array(); - var $currentSchema; - var $message = array(); - var $complexTypes = array(); - var $messages = array(); - var $currentMessage; - var $currentOperation; - var $portTypes = array(); - var $currentPortType; - var $bindings = array(); - var $currentBinding; - var $ports = array(); - var $currentPort; - var $opData = array(); - var $status = ''; - var $documentation = false; - var $endpoint = ''; + public $schemas = array(); + public $currentSchema; + public $message = array(); + public $complexTypes = array(); + public $messages = array(); + public $currentMessage; + public $currentOperation; + public $portTypes = array(); + public $currentPortType; + public $bindings = array(); + public $currentBinding; + public $ports = array(); + public $currentPort; + public $opData = array(); + public $status = ''; + public $documentation = false; + public $endpoint = ''; // array of wsdl docs to import - var $import = array(); + public $import = array(); // parser vars - var $parser; - var $position = 0; - var $depth = 0; - var $depth_array = array(); + public $parser; + public $position = 0; + public $depth = 0; + public $depth_array = array(); // for getting wsdl - var $proxyhost = ''; - var $proxyport = ''; - var $proxyusername = ''; - var $proxypassword = ''; - var $timeout = 0; - var $response_timeout = 30; - var $curl_options = array(); // User-specified cURL options - var $use_curl = false; // whether to always try to use cURL + public $proxyhost = ''; + public $proxyport = ''; + public $proxyusername = ''; + public $proxypassword = ''; + public $timeout = 0; + public $response_timeout = 30; + public $curl_options = array(); // User-specified cURL options + public $use_curl = false; // whether to always try to use cURL // for HTTP authentication - var $username = ''; // Username for HTTP authentication - var $password = ''; // Password for HTTP authentication - var $authtype = ''; // Type of HTTP authentication - var $certRequest = array(); // Certificate for HTTP SSL authentication + public $username = ''; // Username for HTTP authentication + public $password = ''; // Password for HTTP authentication + public $authtype = ''; // Type of HTTP authentication + public $certRequest = array(); // Certificate for HTTP SSL authentication /** * constructor @@ -4775,7 +4771,7 @@ class wsdl extends nusoap_base * @param boolean $use_curl try to use cURL * @access public */ - function __construct($wsdl = '', $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $curl_options = null, $use_curl = false) + public function __construct($wsdl = '', $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $curl_options = null, $use_curl = false) { parent::__construct(); $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout"); @@ -4797,7 +4793,7 @@ function __construct($wsdl = '', $proxyhost = false, $proxyport = false, $proxyu * * @access public */ - function fetchWSDL($wsdl) + public function fetchWSDL($wsdl) { $this->debug("parse and process WSDL path=$wsdl"); $this->wsdl = $wsdl; @@ -4901,7 +4897,7 @@ function fetchWSDL($wsdl) * @param string $wsdl path or URL * @access private */ - function parseWSDL($wsdl = '') + public function parseWSDL($wsdl = '') { $this->debug("parse WSDL at path=$wsdl"); @@ -5009,7 +5005,7 @@ function parseWSDL($wsdl = '') * @param string $attrs associative array of attributes * @access private */ - function start_element($parser, $name, $attrs) + public function start_element($parser, $name, $attrs) { if ($this->status == 'schema') { $this->currentSchema->schemaStartElement($parser, $name, $attrs); @@ -5058,10 +5054,10 @@ function start_element($parser, $name, $attrs) } else { $attrs = array(); } - // Set default prefix and namespace - // to prevent error Undefined variable $prefix and $namespace if (preg_match('/:/', $name)) return 0 or FALSE - $prefix = ''; - $namespace = ''; + // Set default prefix and namespace + // to prevent error Undefined variable $prefix and $namespace if (preg_match('/:/', $name)) return 0 or FALSE + $prefix = ''; + $namespace = ''; // get element prefix, namespace and name if (preg_match('/:/', $name)) { // get ns prefix @@ -5226,7 +5222,7 @@ function start_element($parser, $name, $attrs) * @param string $name element name * @access private */ - function end_element($parser, $name) + public function end_element($parser, $name) { // unset schema status if (/*preg_match('/types$/', $name) ||*/ @@ -5259,7 +5255,7 @@ function end_element($parser, $name) * @param string $data element content * @access private */ - function character_data($parser, $data) + public function character_data($parser, $data) { $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0; if (isset($this->message[$pos]['cdata'])) { @@ -5279,7 +5275,7 @@ function character_data($parser, $data) * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) * @access public */ - function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) + public function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) { $this->debug("setCredentials username=$username authtype=$authtype certRequest="); $this->appendDebug($this->varDump($certRequest)); @@ -5289,7 +5285,7 @@ function setCredentials($username, $password, $authtype = 'basic', $certRequest $this->certRequest = $certRequest; } - function getBindingData($binding) + public function getBindingData($binding) { if (is_array($this->bindings[$binding])) { return $this->bindings[$binding]; @@ -5304,7 +5300,7 @@ function getBindingData($binding) * @return array * @access public */ - function getOperations($portName = '', $bindingType = 'soap') + public function getOperations($portName = '', $bindingType = 'soap') { $ops = array(); if ($bindingType == 'soap') { @@ -5345,7 +5341,7 @@ function getOperations($portName = '', $bindingType = 'soap') * @return array * @access public */ - function getOperationData($operation, $bindingType = 'soap') + public function getOperationData($operation, $bindingType = 'soap') { if ($bindingType == 'soap') { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; @@ -5377,7 +5373,7 @@ function getOperationData($operation, $bindingType = 'soap') * @return array * @access public */ - function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') + public function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') { if ($bindingType == 'soap') { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; @@ -5416,7 +5412,7 @@ function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') * @access public * @see nusoap_xmlschema */ - function getTypeDef($type, $ns) + public function getTypeDef($type, $ns) { $this->debug("in getTypeDef: type=$type, ns=$ns"); if ((!$ns) && isset($this->namespaces['tns'])) { @@ -5477,7 +5473,7 @@ function getTypeDef($type, $ns) * * @access private */ - function webDescription() + public function webDescription() { global $HTTP_SERVER_VARS; @@ -5612,7 +5608,7 @@ function popout(){ // Hides message * @return string serialization of WSDL * @access public */ - function serialize($debug = 0) + public function serialize($debug = 0) { $xml = ''; $xml .= "\ndebug("in parametersMatchWrapped type=$type, parameters="); $this->appendDebug($this->varDump($parameters)); @@ -5835,7 +5831,7 @@ function parametersMatchWrapped($type, &$parameters) * @return mixed parameters serialized as XML or false on error (e.g. operation not found) * @access public */ - function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') + public function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') { $this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType"); $this->appendDebug('parameters=' . $this->varDump($parameters)); @@ -5937,7 +5933,7 @@ function serializeRPCParameters($operation, $direction, $parameters, $bindingTyp * @access public * @deprecated */ - function serializeParameters($operation, $direction, $parameters) + public function serializeParameters($operation, $direction, $parameters) { $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion"); $this->appendDebug('parameters=' . $this->varDump($parameters)); @@ -5965,7 +5961,6 @@ function serializeParameters($operation, $direction, $parameters) // set input params $xml = ''; if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) { - $use = $opData[$direction]['use']; $this->debug("use=$use"); $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)'); @@ -6016,7 +6011,7 @@ function serializeParameters($operation, $direction, $parameters) * @return string value serialized as an XML string * @access private */ - function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle = false, $unqualified = false) + public function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle = false, $unqualified = false) { $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified")); $this->appendDebug("value=" . $this->varDump($value)); @@ -6335,7 +6330,7 @@ function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle = * @return string value serialized as an XML string * @access private */ - function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) + public function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) { $this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType"); $xml = ''; @@ -6399,7 +6394,7 @@ function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) * @return string value serialized as an XML string * @access private */ - function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use = 'encoded', $encodingStyle = false) + public function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use = 'encoded', $encodingStyle = false) { $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType"); $xml = ''; @@ -6508,7 +6503,7 @@ function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use = 'en * @see nusoap_xmlschema * @access public */ - function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') + public function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') { if (count($elements) > 0) { $eElements = array(); @@ -6556,7 +6551,7 @@ function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $ * @see nusoap_xmlschema * @access public */ - function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) + public function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) { $restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase; @@ -6571,7 +6566,7 @@ function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', * @see nusoap_xmlschema * @access public */ - function addElement($attrs) + public function addElement($attrs) { $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; $this->schemas[$typens][0]->addElement($attrs); @@ -6591,7 +6586,7 @@ function addElement($attrs) * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) * @access public */ - function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = '') + public function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = '') { if ($use == 'encoded' && $encodingStyle == '') { $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; @@ -6676,40 +6671,39 @@ function addOperation($name, $in = false, $out = false, $namespace = false, $soa */ class nusoap_parser extends nusoap_base { - - var $xml = ''; - var $xml_encoding = ''; - var $method = ''; - var $root_struct = ''; - var $root_struct_name = ''; - var $root_struct_namespace = ''; - var $root_header = ''; - var $document = ''; // incoming SOAP body (text) + public $xml = ''; + public $xml_encoding = ''; + public $method = ''; + public $root_struct = ''; + public $root_struct_name = ''; + public $root_struct_namespace = ''; + public $root_header = ''; + public $document = ''; // incoming SOAP body (text) // determines where in the message we are (envelope,header,body,method) - var $status = ''; - var $position = 0; - var $depth = 0; - var $default_namespace = ''; - var $namespaces = array(); - var $message = array(); - var $parent = ''; - var $fault = false; - var $fault_code = ''; - var $fault_str = ''; - var $fault_detail = ''; - var $depth_array = array(); - var $debug_flag = true; - var $soapresponse = null; // parsed SOAP Body - var $soapheader = null; // parsed SOAP Header - var $responseHeaders = ''; // incoming SOAP headers (text) - var $body_position = 0; + public $status = ''; + public $position = 0; + public $depth = 0; + public $default_namespace = ''; + public $namespaces = array(); + public $message = array(); + public $parent = ''; + public $fault = false; + public $fault_code = ''; + public $fault_str = ''; + public $fault_detail = ''; + public $depth_array = array(); + public $debug_flag = true; + public $soapresponse = null; // parsed SOAP Body + public $soapheader = null; // parsed SOAP Header + public $responseHeaders = ''; // incoming SOAP headers (text) + public $body_position = 0; // for multiref parsing: // array of id => pos - var $ids = array(); + public $ids = array(); // array of id => hrefs => pos - var $multirefs = array(); + public $multirefs = array(); // toggle for auto-decoding element content - var $decode_utf8 = true; + public $decode_utf8 = true; /** * constructor that actually does the parsing @@ -6720,7 +6714,7 @@ class nusoap_parser extends nusoap_base * @param string $decode_utf8 whether to decode UTF-8 to ISO-8859-1 * @access public */ - function __construct($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = true) + public function __construct($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = true) { parent::__construct(); $this->xml = $xml; @@ -6769,9 +6763,11 @@ function __construct($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = tru // Parse the XML file. if (!xml_parse($this->parser, $xml, true)) { // Display an error message. - $err = sprintf('XML error parsing SOAP payload on line %d: %s', + $err = sprintf( + 'XML error parsing SOAP payload on line %d: %s', xml_get_current_line_number($this->parser), - xml_error_string(xml_get_error_code($this->parser))); + xml_error_string(xml_get_error_code($this->parser)) + ); $this->debug($err); $this->debug("XML payload:\n" . $xml); $this->setError($err); @@ -6816,7 +6812,7 @@ function __construct($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = tru * @param array $attrs associative array of attributes * @access private */ - function start_element($parser, $name, $attrs) + public function start_element($parser, $name, $attrs) { // position in a total number of elements, starting from 0 // update class level pos @@ -6853,7 +6849,7 @@ function start_element($parser, $name, $attrs) } elseif ($name == 'Body' && $this->status == 'envelope') { $this->status = 'body'; $this->body_position = $pos; - // set method + // set method } elseif ($this->status == 'body' && $pos == ($this->body_position + 1)) { $this->status = 'method'; $this->root_struct_name = $name; @@ -6904,13 +6900,13 @@ function start_element($parser, $name, $attrs) } elseif ($key_localpart == 'arrayType') { $this->message[$pos]['type'] = 'array'; /* do arrayType ereg here - [1] arrayTypeValue ::= atype asize - [2] atype ::= QName rank* - [3] rank ::= '[' (',')* ']' - [4] asize ::= '[' length~ ']' - [5] length ::= nextDimension* Digit+ - [6] nextDimension ::= Digit+ ',' - */ + [1] arrayTypeValue ::= atype asize + [2] atype ::= QName rank* + [3] rank ::= '[' (',')* ']' + [4] asize ::= '[' length~ ']' + [5] length ::= nextDimension* Digit+ + [6] nextDimension ::= Digit+ ',' + */ $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; if (preg_match($expr, $value, $regs)) { $this->message[$pos]['typePrefix'] = $regs[1]; @@ -6927,7 +6923,7 @@ function start_element($parser, $name, $attrs) // specifies nil value (or not) } elseif ($key_localpart == 'nil') { $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); - // some other attribute + // some other attribute } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { $this->message[$pos]['xattrs']['!' . $key] = $value; } @@ -6972,7 +6968,7 @@ function start_element($parser, $name, $attrs) * @param string $name element name * @access private */ - function end_element($parser, $name) + public function end_element($parser, $name) { // position of current element is equal to the last value left in depth_array for my depth $pos = $this->depth_array[$this->depth--]; @@ -6995,7 +6991,7 @@ function end_element($parser, $name) $this->multirefs[$id][$pos] = 'placeholder'; // add set a reference to it as the result value $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; - // build complexType values + // build complexType values } elseif ($this->message[$pos]['children'] != '') { // if result has already been generated (struct/array) if (!isset($this->message[$pos]['result'])) { @@ -7018,7 +7014,7 @@ function end_element($parser, $name) } } $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; - // set value of simpleType (or nil complexType) + // set value of simpleType (or nil complexType) } else { //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { @@ -7035,15 +7031,15 @@ function end_element($parser, $name) } /* add value to parent's result, if parent is struct/array - $parent = $this->message[$pos]['parent']; - if($this->message[$parent]['type'] != 'map'){ - if(strtolower($this->message[$parent]['type']) == 'array'){ - $this->message[$parent]['result'][] = $this->message[$pos]['result']; - } else { - $this->message[$parent]['result'][$this->message[$pos]['name']] = $this->message[$pos]['result']; - } - } - */ + $parent = $this->message[$pos]['parent']; + if($this->message[$parent]['type'] != 'map'){ + if(strtolower($this->message[$parent]['type']) == 'array'){ + $this->message[$parent]['result'][] = $this->message[$pos]['result']; + } else { + $this->message[$parent]['result'][$this->message[$pos]['name']] = $this->message[$pos]['result']; + } + } + */ } } @@ -7079,7 +7075,7 @@ function end_element($parser, $name) * @param string $data element content * @access private */ - function character_data($parser, $data) + public function character_data($parser, $data) { $pos = $this->depth_array[$this->depth]; if ($this->xml_encoding == 'UTF-8') { @@ -7106,7 +7102,7 @@ function character_data($parser, $data) * @access public * @deprecated use get_soapbody instead */ - function get_response() + public function get_response() { return $this->soapresponse; } @@ -7117,7 +7113,7 @@ function get_response() * @return mixed * @access public */ - function get_soapbody() + public function get_soapbody() { return $this->soapresponse; } @@ -7128,7 +7124,7 @@ function get_soapbody() * @return mixed * @access public */ - function get_soapheader() + public function get_soapheader() { return $this->soapheader; } @@ -7139,7 +7135,7 @@ function get_soapheader() * @return string XML or empty if no Header * @access public */ - function getHeaders() + public function getHeaders() { return $this->responseHeaders; } @@ -7153,7 +7149,7 @@ function getHeaders() * @return mixed PHP value * @access private */ - function decodeSimple($value, $type, $typens) + public function decodeSimple($value, $type, $typens) { // TODO: use the namespace! if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { @@ -7199,7 +7195,7 @@ function decodeSimple($value, $type, $typens) * @return mixed PHP value * @access private */ - function buildVal($pos) + public function buildVal($pos) { if (!isset($this->message[$pos]['type'])) { $this->message[$pos]['type'] = ''; @@ -7339,62 +7335,61 @@ class soap_parser extends nusoap_parser */ class nusoap_client extends nusoap_base { - - var $username = ''; // Username for HTTP authentication - var $password = ''; // Password for HTTP authentication - var $authtype = ''; // Type of HTTP authentication - var $certRequest = array(); // Certificate for HTTP SSL authentication - var $requestHeaders = false; // SOAP headers in request (text) - var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text) - var $responseHeader = null; // SOAP Header from response (parsed) - var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text) - var $endpoint; - var $forceEndpoint = ''; // overrides WSDL endpoint - var $proxyhost = ''; - var $proxyport = ''; - var $proxyusername = ''; - var $proxypassword = ''; - var $portName = ''; // port name to use in WSDL - var $xml_encoding = ''; // character set encoding of incoming (response) messages - var $http_encoding = false; - var $timeout = 0; // HTTP connection timeout - var $response_timeout = 30; // HTTP response timeout - var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error - var $persistentConnection = false; - var $defaultRpcParams = false; // This is no longer used - var $request = ''; // HTTP request - var $response = ''; // HTTP response - var $responseData = ''; // SOAP payload of response - var $cookies = array(); // Cookies from response or for request - var $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode() - var $operations = array(); // WSDL operations, empty for WSDL initialization error - var $curl_options = array(); // User-specified cURL options - var $bindingType = ''; // WSDL operation binding type - var $use_curl = false; // whether to always try to use cURL + public $username = ''; // Username for HTTP authentication + public $password = ''; // Password for HTTP authentication + public $authtype = ''; // Type of HTTP authentication + public $certRequest = array(); // Certificate for HTTP SSL authentication + public $requestHeaders = false; // SOAP headers in request (text) + public $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text) + public $responseHeader = null; // SOAP Header from response (parsed) + public $document = ''; // SOAP body response portion (incomplete namespace resolution) (text) + public $endpoint; + public $forceEndpoint = ''; // overrides WSDL endpoint + public $proxyhost = ''; + public $proxyport = ''; + public $proxyusername = ''; + public $proxypassword = ''; + public $portName = ''; // port name to use in WSDL + public $xml_encoding = ''; // character set encoding of incoming (response) messages + public $http_encoding = false; + public $timeout = 0; // HTTP connection timeout + public $response_timeout = 30; // HTTP response timeout + public $endpointType = ''; // soap|wsdl, empty for WSDL initialization error + public $persistentConnection = false; + public $defaultRpcParams = false; // This is no longer used + public $request = ''; // HTTP request + public $response = ''; // HTTP response + public $responseData = ''; // SOAP payload of response + public $cookies = array(); // Cookies from response or for request + public $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode() + public $operations = array(); // WSDL operations, empty for WSDL initialization error + public $curl_options = array(); // User-specified cURL options + public $bindingType = ''; // WSDL operation binding type + public $use_curl = false; // whether to always try to use cURL /* - * fault related variables - */ + * fault related variables + */ /** * @var fault * @access public */ - var $fault; + public $fault; /** * @var faultcode * @access public */ - var $faultcode; + public $faultcode; /** * @var faultstring * @access public */ - var $faultstring; + public $faultstring; /** * @var faultdetail * @access public */ - var $faultdetail; + public $faultdetail; /** * constructor @@ -7410,7 +7405,7 @@ class nusoap_client extends nusoap_base * @param string $portName optional portName in WSDL document * @access public */ - function __construct($endpoint, $wsdl = false, $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = '') + public function __construct($endpoint, $wsdl = false, $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = '') { parent::__construct(); $this->endpoint = $endpoint; @@ -7470,7 +7465,7 @@ function __construct($endpoint, $wsdl = false, $proxyhost = false, $proxyport = * @return mixed response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors * @access public */ - function call($operation, $params = array(), $namespace = 'http://tempuri.org', $soapAction = '', $headers = false, $rpcParams = null, $style = 'rpc', $use = 'encoded') + public function call($operation, $params = array(), $namespace = 'http://tempuri.org', $soapAction = '', $headers = false, $rpcParams = null, $style = 'rpc', $use = 'encoded') { $this->operation = $operation; $this->fault = false; @@ -7553,7 +7548,7 @@ function call($operation, $params = array(), $namespace = 'http://tempuri.org', // no WSDL //$this->namespaces['ns1'] = $namespace; $nsPrefix = 'ns' . rand(1000, 9999); - // serialize + // serialize $payload = ''; if (is_string($params)) { $this->debug("serializing param string for operation $operation"); @@ -7645,7 +7640,7 @@ function call($operation, $params = array(), $namespace = 'http://tempuri.org', $this->debug('return shifted value: '); $this->appendDebug($this->varDump($return)); return $return; - // nothing returned (ie, echoVoid) + // nothing returned (ie, echoVoid) } else { return ""; } @@ -7658,7 +7653,7 @@ function call($operation, $params = array(), $namespace = 'http://tempuri.org', * * @access private */ - function checkWSDL() + public function checkWSDL() { $this->appendDebug($this->wsdl->getDebug()); $this->wsdl->clearDebug(); @@ -7693,7 +7688,7 @@ function checkWSDL() * * @access public */ - function loadWSDL() + public function loadWSDL() { $this->debug('instantiating wsdl class with doc: ' . $this->wsdlFile); $this->wsdl = new wsdl('', $this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword, $this->timeout, $this->response_timeout, $this->curl_options, $this->use_curl); @@ -7709,7 +7704,7 @@ function loadWSDL() * @return array array of data pertaining to the operation * @access public */ - function getOperationData($operation) + public function getOperationData($operation) { if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { $this->loadWSDL(); @@ -7737,7 +7732,7 @@ function getOperationData($operation) * @return mixed native PHP types. * @access private */ - function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30) + public function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30) { $this->checkCookies(); // detect transport @@ -7817,7 +7812,7 @@ function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30) * @return mixed value of the message, decoded into a PHP type * @access private */ - function parseResponse($headers, $data) + public function parseResponse($headers, $data) { $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:'); $this->appendDebug($this->varDump($headers)); @@ -7874,7 +7869,7 @@ function parseResponse($headers, $data) * @param mixed $value The cURL option value * @access public */ - function setCurlOption($option, $value) + public function setCurlOption($option, $value) { $this->debug("setCurlOption option=$option, value="); $this->appendDebug($this->varDump($value)); @@ -7887,7 +7882,7 @@ function setCurlOption($option, $value) * @param string $endpoint The endpoint URL to use, or empty string or false to prevent override * @access public */ - function setEndpoint($endpoint) + public function setEndpoint($endpoint) { $this->debug("setEndpoint(\"$endpoint\")"); $this->forceEndpoint = $endpoint; @@ -7899,7 +7894,7 @@ function setEndpoint($endpoint) * @param mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers * @access public */ - function setHeaders($headers) + public function setHeaders($headers) { $this->debug("setHeaders headers="); $this->appendDebug($this->varDump($headers)); @@ -7912,7 +7907,7 @@ function setHeaders($headers) * @return string * @access public */ - function getHeaders() + public function getHeaders() { return $this->responseHeaders; } @@ -7923,7 +7918,7 @@ function getHeaders() * @return mixed * @access public */ - function getHeader() + public function getHeader() { return $this->responseHeader; } @@ -7937,7 +7932,7 @@ function getHeader() * @param string $proxypassword * @access public */ - function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '') + public function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '') { $this->proxyhost = $proxyhost; $this->proxyport = $proxyport; @@ -7954,7 +7949,7 @@ function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypasswor * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) * @access public */ - function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) + public function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) { $this->debug("setCredentials username=$username authtype=$authtype certRequest="); $this->appendDebug($this->varDump($certRequest)); @@ -7970,7 +7965,7 @@ function setCredentials($username, $password, $authtype = 'basic', $certRequest * @param string $enc HTTP encoding * @access public */ - function setHTTPEncoding($enc = 'gzip, deflate') + public function setHTTPEncoding($enc = 'gzip, deflate') { $this->debug("setHTTPEncoding(\"$enc\")"); $this->http_encoding = $enc; @@ -7982,7 +7977,7 @@ function setHTTPEncoding($enc = 'gzip, deflate') * @param boolean $use Whether to try to use cURL * @access public */ - function setUseCURL($use) + public function setUseCURL($use) { $this->debug("setUseCURL($use)"); $this->use_curl = $use; @@ -7993,7 +7988,7 @@ function setUseCURL($use) * * @access public */ - function useHTTPPersistentConnection() + public function useHTTPPersistentConnection() { $this->debug("useHTTPPersistentConnection"); $this->persistentConnection = true; @@ -8010,7 +8005,7 @@ function useHTTPPersistentConnection() * @access public * @deprecated */ - function getDefaultRpcParams() + public function getDefaultRpcParams() { return $this->defaultRpcParams; } @@ -8026,7 +8021,7 @@ function getDefaultRpcParams() * @access public * @deprecated */ - function setDefaultRpcParams($rpcParams) + public function setDefaultRpcParams($rpcParams) { $this->defaultRpcParams = $rpcParams; } @@ -8038,7 +8033,7 @@ function setDefaultRpcParams($rpcParams) * @return object soap_proxy object * @access public */ - function getProxy() + public function getProxy() { $r = rand(); $evalStr = $this->_getProxyClassCode($r); @@ -8087,7 +8082,7 @@ function getProxy() * @return string PHP/NuSOAP code for the proxy class * @access private */ - function _getProxyClassCode($r) + public function _getProxyClassCode($r) { $this->debug("in getProxy endpointType=$this->endpointType"); $this->appendDebug("wsdl=" . $this->varDump($this->wsdl)); @@ -8147,7 +8142,7 @@ function " . str_replace('.', '__', $operation) . "($paramStr) { * @return string PHP/NuSOAP code for the proxy class * @access public */ - function getProxyClassCode() + public function getProxyClassCode() { $r = rand(); return $this->_getProxyClassCode($r); @@ -8160,7 +8155,7 @@ function getProxyClassCode() * @return string The HTTP body, which includes the SOAP payload * @access private */ - function getHTTPBody($soapmsg) + public function getHTTPBody($soapmsg) { return $soapmsg; } @@ -8173,7 +8168,7 @@ function getHTTPBody($soapmsg) * @return string the HTTP content type for the current request. * @access private */ - function getHTTPContentType() + public function getHTTPContentType() { return 'text/xml'; } @@ -8187,18 +8182,18 @@ function getHTTPContentType() * @return string the HTTP content type charset for the current request. * @access private */ - function getHTTPContentTypeCharset() + public function getHTTPContentTypeCharset() { return $this->soap_defencoding; } /* - * whether or not parser should decode utf8 element content + * whether or not parser should decode utf8 element content * * @return always returns true * @access public */ - function decodeUTF8($bool) + public function decodeUTF8($bool) { $this->decode_utf8 = $bool; return true; @@ -8212,7 +8207,7 @@ function decodeUTF8($bool) * @return boolean if cookie-set was successful returns true, else false * @access public */ - function setCookie($name, $value) + public function setCookie($name, $value) { if (strlen($name) == 0) { return false; @@ -8227,7 +8222,7 @@ function setCookie($name, $value) * @return array with all internal cookies * @access public */ - function getCookies() + public function getCookies() { return $this->cookies; } @@ -8238,7 +8233,7 @@ function getCookies() * @return boolean always return true * @access private */ - function checkCookies() + public function checkCookies() { if (sizeof($this->cookies) == 0) { return true; @@ -8272,7 +8267,7 @@ function checkCookies() * @return boolean always return true * @access private */ - function UpdateCookies($cookies) + public function UpdateCookies($cookies) { if (sizeof($this->cookies) == 0) { // no existing cookies: take whatever is new From f6c868c2c33c83299fd224f6594077bc1c573ed6 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 10 Jun 2018 19:28:26 -0400 Subject: [PATCH 02/40] update version to 0.9.6 --- src/nusoap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nusoap.php b/src/nusoap.php index ef43a6d..692be0f 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -98,7 +98,7 @@ class nusoap_base * @var string * @access private */ - public $version = '0.9.5'; + public $version = '0.9.6'; /** * CVS revision for HTTP headers. * From eb64ea1434b22bdbd997365a3455b4f0ee4253d3 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 10 Jun 2018 19:31:44 -0400 Subject: [PATCH 03/40] Case mismatch in function/method call --- src/nusoap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nusoap.php b/src/nusoap.php index 692be0f..360bd64 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -757,7 +757,7 @@ public function formatDump($str) * @return string contracted qname * @access private */ - public function contractQname($qname) + public function contractQName($qname) { // get element namespace //$this->xdebug("Contract $qname"); From cdaa69a580769eddd52f1d90260eb97a57ff8534 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 10 Jun 2018 19:33:56 -0400 Subject: [PATCH 04/40] Array short syntax --- src/nusoap.php | 300 ++++++++++++++++++++++++++----------------------- 1 file changed, 157 insertions(+), 143 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index 360bd64..5697c51 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -161,12 +161,12 @@ class nusoap_base * @var array * @access public */ - public $namespaces = array( + public $namespaces = [ 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xsd' => 'http://www.w3.org/2001/XMLSchema', 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/' - ); + ]; /** * namespaces used in the current context, e.g. during serialization @@ -174,7 +174,7 @@ class nusoap_base * @var array * @access private */ - public $usedNamespaces = array(); + public $usedNamespaces = []; /** * XML Schema types in an array of uri => (array of xml type => php type) @@ -184,8 +184,8 @@ class nusoap_base * @var array * @access public */ - public $typemap = array( - 'http://www.w3.org/2001/XMLSchema' => array( + public $typemap = [ + 'http://www.w3.org/2001/XMLSchema' => [ 'string' => 'string', 'boolean' => 'boolean', 'float' => 'double', 'double' => 'double', 'decimal' => 'double', 'duration' => '', 'dateTime' => 'string', 'time' => 'string', 'date' => 'string', 'gYearMonth' => '', 'gYear' => '', 'gMonthDay' => '', 'gDay' => '', 'gMonth' => '', 'hexBinary' => 'string', 'base64Binary' => 'string', @@ -195,19 +195,22 @@ class nusoap_base 'normalizedString' => 'string', 'token' => 'string', 'language' => '', 'NMTOKEN' => '', 'NMTOKENS' => '', 'Name' => '', 'NCName' => '', 'ID' => '', 'IDREF' => '', 'IDREFS' => '', 'ENTITY' => '', 'ENTITIES' => '', 'integer' => 'integer', 'nonPositiveInteger' => 'integer', 'negativeInteger' => 'integer', 'long' => 'integer', 'int' => 'integer', 'short' => 'integer', 'byte' => 'integer', 'nonNegativeInteger' => 'integer', - 'unsignedLong' => '', 'unsignedInt' => '', 'unsignedShort' => '', 'unsignedByte' => '', 'positiveInteger' => ''), - 'http://www.w3.org/2000/10/XMLSchema' => array( + 'unsignedLong' => '', 'unsignedInt' => '', 'unsignedShort' => '', 'unsignedByte' => '', 'positiveInteger' => '' + ], + 'http://www.w3.org/2000/10/XMLSchema' => [ 'i4' => '', 'int' => 'integer', 'boolean' => 'boolean', 'string' => 'string', 'double' => 'double', 'float' => 'double', 'dateTime' => 'string', - 'timeInstant' => 'string', 'base64Binary' => 'string', 'base64' => 'string', 'ur-type' => 'array'), - 'http://www.w3.org/1999/XMLSchema' => array( + 'timeInstant' => 'string', 'base64Binary' => 'string', 'base64' => 'string', 'ur-type' => 'array' + ], + 'http://www.w3.org/1999/XMLSchema' => [ 'i4' => '', 'int' => 'integer', 'boolean' => 'boolean', 'string' => 'string', 'double' => 'double', 'float' => 'double', 'dateTime' => 'string', - 'timeInstant' => 'string', 'base64Binary' => 'string', 'base64' => 'string', 'ur-type' => 'array'), - 'http://soapinterop.org/xsd' => array('SOAPStruct' => 'struct'), - 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64' => 'string', 'array' => 'array', 'Array' => 'array'), - 'http://xml.apache.org/xml-soap' => array('Map') - ); + 'timeInstant' => 'string', 'base64Binary' => 'string', 'base64' => 'string', 'ur-type' => 'array' + ], + 'http://soapinterop.org/xsd' => ['SOAPStruct' => 'struct'], + 'http://schemas.xmlsoap.org/soap/encoding/' => ['base64' => 'string', 'array' => 'array', 'Array' => 'array'], + 'http://xml.apache.org/xml-soap' => ['Map'] + ]; /** * XML entities to convert @@ -217,8 +220,10 @@ class nusoap_base * @deprecated * @see expandEntities */ - public $xmlEntities = array('quot' => '"', 'amp' => '&', - 'lt' => '<', 'gt' => '>', 'apos' => "'"); + public $xmlEntities = [ + 'quot' => '"', 'amp' => '&', + 'lt' => '<', 'gt' => '>', 'apos' => "'" + ]; /** * constructor @@ -688,7 +693,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal * @return string the message * @access public */ - public function serializeEnvelope($body, $headers = false, $namespaces = array(), $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/') + public function serializeEnvelope($body, $headers = false, $namespaces = [], $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/') { // TODO: add an option to automatically run utf8_encode on $body and $headers // if $this->soap_defencoding is UTF-8. Not doing this automatically allows @@ -1134,28 +1139,28 @@ class nusoap_xmlschema extends nusoap_base // namespaces public $enclosingNamespaces; // schema info - public $schemaInfo = array(); + public $schemaInfo = []; public $schemaTargetNamespace = ''; // types, elements, attributes defined by the schema - public $attributes = array(); - public $complexTypes = array(); - public $complexTypeStack = array(); + public $attributes = []; + public $complexTypes = []; + public $complexTypeStack = []; public $currentComplexType = null; - public $elements = array(); - public $elementStack = array(); + public $elements = []; + public $elementStack = []; public $currentElement = null; - public $simpleTypes = array(); - public $simpleTypeStack = array(); + public $simpleTypes = []; + public $simpleTypeStack = []; public $currentSimpleType = null; // imports - public $imports = array(); + public $imports = []; // parser vars public $parser; public $position = 0; public $depth = 0; - public $depth_array = array(); - public $message = array(); - public $defaultNamespace = array(); + public $depth_array = []; + public $message = []; + public $defaultNamespace = []; /** * constructor @@ -1165,7 +1170,7 @@ class nusoap_xmlschema extends nusoap_base * @param string $namespaces namespaces defined in enclosing XML * @access public */ - public function __construct($schema = '', $xml = '', $namespaces = array()) + public function __construct($schema = '', $xml = '', $namespaces = []) { parent::__construct(); $this->debug('nusoap_xmlschema class instantiated, inside constructor'); @@ -1300,7 +1305,7 @@ public function schemaStartElement($parser, $name, $attrs) $depth = $this->depth++; // set self as current value for this depth $this->depth_array[$depth] = $pos; - $this->message[$pos] = array('cdata' => ''); + $this->message[$pos] = ['cdata' => '']; if ($depth > 0) { $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]]; } else { @@ -1345,7 +1350,7 @@ public function schemaStartElement($parser, $name, $attrs) } $attrs = $eAttrs; } else { - $attrs = array(); + $attrs = []; } // find status, register data switch ($name) { @@ -1537,10 +1542,10 @@ public function schemaStartElement($parser, $name, $attrs) case 'import': if (isset($attrs['schemaLocation'])) { $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']); - $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false); + $this->imports[$attrs['namespace']][] = ['location' => $attrs['schemaLocation'], 'loaded' => false]; } else { $this->xdebug('import namespace ' . $attrs['namespace']); - $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true); + $this->imports[$attrs['namespace']][] = ['location' => '', 'loaded' => true]; if (!$this->getPrefixFromNamespace($attrs['namespace'])) { $this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace']; } @@ -1549,7 +1554,7 @@ public function schemaStartElement($parser, $name, $attrs) case 'include': if (isset($attrs['schemaLocation'])) { $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']); - $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false); + $this->imports[$this->schemaTargetNamespace][] = ['location' => $attrs['schemaLocation'], 'loaded' => false]; } else { $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute'); } @@ -2030,9 +2035,9 @@ public function typeToForm($name, $type) * @access public * @see getTypeDef */ - public function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') + public function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = [], $attrs = [], $arrayType = '') { - $this->complexTypes[$name] = array( + $this->complexTypes[$name] = [ 'name' => $name, 'typeClass' => $typeClass, 'phpType' => $phpType, @@ -2041,7 +2046,7 @@ public function addComplexType($name, $typeClass = 'complexType', $phpType = 'ar 'elements' => $elements, 'attrs' => $attrs, 'arrayType' => $arrayType - ); + ]; $this->xdebug("addComplexType $name:"); $this->appendDebug($this->varDump($this->complexTypes[$name])); @@ -2059,15 +2064,15 @@ public function addComplexType($name, $typeClass = 'complexType', $phpType = 'ar * @see nusoap_xmlschema * @see getTypeDef */ - public function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) + public function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = []) { - $this->simpleTypes[$name] = array( + $this->simpleTypes[$name] = [ 'name' => $name, 'typeClass' => $typeClass, 'phpType' => $phpType, 'type' => $restrictionBase, 'enumeration' => $enumeration - ); + ]; $this->xdebug("addSimpleType $name:"); $this->appendDebug($this->varDump($this->simpleTypes[$name])); @@ -2225,23 +2230,23 @@ class soap_transport_http extends nusoap_base public $request_method = 'POST'; public $protocol_version = '1.0'; public $encoding = ''; - public $outgoing_headers = array(); - public $incoming_headers = array(); - public $incoming_cookies = array(); + public $outgoing_headers = []; + public $incoming_headers = []; + public $incoming_cookies = []; public $outgoing_payload = ''; public $incoming_payload = ''; public $response_status_line; // HTTP response status line public $useSOAPAction = true; public $persistentConnection = false; public $ch = false; // cURL handle - public $ch_options = array(); // cURL custom options + public $ch_options = []; // cURL custom options public $use_curl = false; // force cURL use public $proxy = null; // proxy information (associative array) public $username = ''; public $password = ''; public $authtype = ''; - public $digestRequest = array(); - public $certRequest = array(); // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional) + public $digestRequest = []; + public $certRequest = []; // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional) // cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem' // sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem' // sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem' @@ -2682,7 +2687,7 @@ public function sendHTTPS($data, $timeout = 0, $response_timeout = 30, $cookies) * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) * @access public */ - public function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) + public function setCredentials($username, $password, $authtype = 'basic', $digestRequest = [], $certRequest = []) { $this->debug("setCredentials username=$username authtype=$authtype digestRequest="); $this->appendDebug($this->varDump($digestRequest)); @@ -2796,13 +2801,13 @@ public function setEncoding($enc = 'gzip, deflate') public function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') { if ($proxyhost) { - $this->proxy = array( + $this->proxy = [ 'host' => $proxyhost, 'port' => $proxyport, 'username' => $proxyusername, 'password' => $proxypassword, 'authtype' => $proxyauthtype - ); + ]; if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') { $this->setHeader('Proxy-Authorization', ' Basic ' . base64_encode($proxyusername . ':' . $proxypassword)); } @@ -2824,14 +2829,16 @@ public function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypass */ public function isSkippableCurlHeader(&$data) { - $skipHeaders = array('HTTP/1.1 100', + $skipHeaders = [ + 'HTTP/1.1 100', 'HTTP/1.0 301', 'HTTP/1.1 301', 'HTTP/1.0 302', 'HTTP/1.1 302', 'HTTP/1.0 401', 'HTTP/1.1 401', - 'HTTP/1.0 200 Connection established'); + 'HTTP/1.0 200 Connection established' + ]; foreach ($skipHeaders as $hd) { $prefix = substr($data, 0, strlen($hd)); if ($prefix == $hd) { @@ -2983,7 +2990,7 @@ public function sendRequest($data, $cookies = null) // turns out that the URI and HTTP version are appended to this, which // some servers refuse to work with (so we no longer use this method!) //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload); - $curl_headers = array(); + $curl_headers = []; foreach ($this->outgoing_headers as $k => $v) { if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') { $this->debug("Skip cURL header $k: $v"); @@ -3070,8 +3077,8 @@ public function getResponse() // process headers $header_data = trim(substr($data, 0, $pos)); $header_array = explode($lb, $header_data); - $this->incoming_headers = array(); - $this->incoming_cookies = array(); + $this->incoming_headers = []; + $this->incoming_cookies = []; foreach ($header_array as $header_line) { $arr = explode(':', $header_line, 2); if (count($arr) > 1) { @@ -3474,13 +3481,14 @@ public function parseCookie($cookie_str) if ($sep_pos) { $name = substr($value_str, 0, $sep_pos); $value = substr($value_str, $sep_pos + 1); - $cookie = array('name' => $name, - 'value' => $value, - 'domain' => $domain, - 'path' => $path, + $cookie = [ + 'name' => $name, + 'value' => $value, + 'domain' => $domain, + 'path' => $path, 'expires' => $expires, - 'secure' => $secure - ); + 'secure' => $secure + ]; return $cookie; } return false; @@ -3554,7 +3562,7 @@ class nusoap_server extends nusoap_base * @var array * @access private */ - public $headers = array(); + public $headers = []; /** * HTTP request * @@ -3610,7 +3618,7 @@ class nusoap_server extends nusoap_base * @var array * @access private */ - public $methodparams = array(); + public $methodparams = []; /** * SOAP Action from request * @@ -3639,7 +3647,7 @@ class nusoap_server extends nusoap_base * @var array * @access public */ - public $outgoing_headers = array(); + public $outgoing_headers = []; /** * HTTP response * @@ -3697,7 +3705,7 @@ class nusoap_server extends nusoap_base * @var array * @access private */ - public $operations = array(); + public $operations = []; /** * wsdl instance (if one) * @@ -4188,16 +4196,16 @@ public function invoke_method() $call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case after call_user_func_array() } elseif ($delim == '..') { $this->debug('in invoke_method, calling class method using call_user_func_array()'); - $call_arg = array($class, $method); + $call_arg = [$class, $method]; } else { $this->debug('in invoke_method, calling instance method using call_user_func_array()'); $instance = new $class(); - $call_arg = array(&$instance, $method); + $call_arg = [&$instance, $method]; } if (is_array($this->methodparams)) { $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams)); } else { - $this->methodreturn = call_user_func_array($call_arg, array()); + $this->methodreturn = call_user_func_array($call_arg, []); } } $this->debug('in invoke_method, methodreturn:'); @@ -4240,7 +4248,7 @@ public function serialize_return() //foreach ($this->opData['output']['parts'] as $name => $type) { // $this->debug('wrap in element named ' . $name); //} - $opParams = array($this->methodreturn); + $opParams = [$this->methodreturn]; } $return_val = $this->wsdl->serializeRPCParameters($this->methodname, 'output', $opParams); $this->appendDebug($this->wsdl->getDebug()); @@ -4517,7 +4525,7 @@ public function getHTTPContentTypeCharset() */ public function add_to_map($methodname, $in, $out) { - $this->operations[$methodname] = array('name' => $methodname, 'in' => $in, 'out' => $out); + $this->operations[$methodname] = ['name' => $methodname, 'in' => $in, 'out' => $out]; } /** @@ -4534,7 +4542,7 @@ public function add_to_map($methodname, $in, $out) * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) * @access public */ - public function register($name, $in = array(), $out = array(), $namespace = false, $soapaction = false, $style = false, $use = false, $documentation = '', $encodingStyle = '') + public function register($name, $in = [], $out = [], $namespace = false, $soapaction = false, $style = false, $use = false, $documentation = '', $encodingStyle = '') { global $HTTP_SERVER_VARS; @@ -4581,13 +4589,14 @@ public function register($name, $in = array(), $out = array(), $namespace = fals $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; } - $this->operations[$name] = array( + $this->operations[$name] = [ 'name' => $name, 'in' => $in, 'out' => $out, 'namespace' => $namespace, 'soapaction' => $soapaction, - 'style' => $style); + 'style' => $style + ]; if ($this->wsdl) { $this->wsdl->addOperation($name, $in, $out, $namespace, $soapaction, $style, $use, $documentation, $encodingStyle); } @@ -4682,17 +4691,19 @@ public function configureWSDL($serviceName, $namespace = false, $endpoint = fals $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified'; } $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace; - $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true); - $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true); - $this->wsdl->bindings[$serviceName . 'Binding'] = array( + $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = ['location' => '', 'loaded' => true]; + $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = ['location' => '', 'loaded' => true]; + $this->wsdl->bindings[$serviceName . 'Binding'] = [ 'name' => $serviceName . 'Binding', 'style' => $style, 'transport' => $transport, - 'portType' => $serviceName . 'PortType'); - $this->wsdl->ports[$serviceName . 'Port'] = array( + 'portType' => $serviceName . 'PortType' + ]; + $this->wsdl->ports[$serviceName . 'Port'] = [ 'binding' => $serviceName . 'Binding', 'location' => $endpoint, - 'bindingType' => 'http://schemas.xmlsoap.org/wsdl/soap/'); + 'bindingType' => 'http://schemas.xmlsoap.org/wsdl/soap/' + ]; } } @@ -4718,30 +4729,30 @@ class wsdl extends nusoap_base // URL or filename of the root of this WSDL public $wsdl; // define internal arrays of bindings, ports, operations, messages, etc. - public $schemas = array(); + public $schemas = []; public $currentSchema; - public $message = array(); - public $complexTypes = array(); - public $messages = array(); + public $message = []; + public $complexTypes = []; + public $messages = []; public $currentMessage; public $currentOperation; - public $portTypes = array(); + public $portTypes = []; public $currentPortType; - public $bindings = array(); + public $bindings = []; public $currentBinding; - public $ports = array(); + public $ports = []; public $currentPort; - public $opData = array(); + public $opData = []; public $status = ''; public $documentation = false; public $endpoint = ''; // array of wsdl docs to import - public $import = array(); + public $import = []; // parser vars public $parser; public $position = 0; public $depth = 0; - public $depth_array = array(); + public $depth_array = []; // for getting wsdl public $proxyhost = ''; public $proxyport = ''; @@ -4749,13 +4760,13 @@ class wsdl extends nusoap_base public $proxypassword = ''; public $timeout = 0; public $response_timeout = 30; - public $curl_options = array(); // User-specified cURL options + public $curl_options = []; // User-specified cURL options public $use_curl = false; // whether to always try to use cURL // for HTTP authentication public $username = ''; // Username for HTTP authentication public $password = ''; // Password for HTTP authentication public $authtype = ''; // Type of HTTP authentication - public $certRequest = array(); // Certificate for HTTP SSL authentication + public $certRequest = []; // Certificate for HTTP SSL authentication /** * constructor @@ -4803,7 +4814,7 @@ public function fetchWSDL($wsdl) } // imports // TODO: handle imports more properly, grabbing them in-line and nesting them - $imported_urls = array(); + $imported_urls = []; $imported = 1; while ($imported > 0) { $imported = 0; @@ -4920,7 +4931,7 @@ public function parseWSDL($wsdl = '') $tr->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword); } if ($this->authtype != '') { - $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); + $tr->setCredentials($this->username, $this->password, $this->authtype, [], $this->certRequest); } $tr->setEncoding('gzip, deflate'); $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout); @@ -5025,7 +5036,7 @@ public function start_element($parser, $name, $attrs) $depth = $this->depth++; // set self as current value for this depth $this->depth_array[$depth] = $pos; - $this->message[$pos] = array('cdata' => ''); + $this->message[$pos] = ['cdata' => '']; // process attributes if (count($attrs) > 0) { // register namespace declarations @@ -5052,7 +5063,7 @@ public function start_element($parser, $name, $attrs) } $attrs = $eAttrs; } else { - $attrs = array(); + $attrs = []; } // Set default prefix and namespace // to prevent error Undefined variable $prefix and $namespace if (preg_match('/:/', $name)) return 0 or FALSE @@ -5164,10 +5175,10 @@ public function start_element($parser, $name, $attrs) switch ($name) { case 'import': if (isset($attrs['location'])) { - $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false); + $this->import[$attrs['namespace']][] = ['location' => $attrs['location'], 'loaded' => false]; $this->debug('parsing import ' . $attrs['namespace'] . ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]) . ')'); } else { - $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true); + $this->import[$attrs['namespace']][] = ['location' => '', 'loaded' => true]; if (!$this->getPrefixFromNamespace($attrs['namespace'])) { $this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace']; } @@ -5180,12 +5191,12 @@ public function start_element($parser, $name, $attrs) // break; case 'message': $this->status = 'message'; - $this->messages[$attrs['name']] = array(); + $this->messages[$attrs['name']] = []; $this->currentMessage = $attrs['name']; break; case 'portType': $this->status = 'portType'; - $this->portTypes[$attrs['name']] = array(); + $this->portTypes[$attrs['name']] = []; $this->currentPortType = $attrs['name']; break; case "binding": @@ -5275,7 +5286,7 @@ public function character_data($parser, $data) * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) * @access public */ - public function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) + public function setCredentials($username, $password, $authtype = 'basic', $certRequest = []) { $this->debug("setCredentials username=$username authtype=$authtype certRequest="); $this->appendDebug($this->varDump($certRequest)); @@ -5302,7 +5313,7 @@ public function getBindingData($binding) */ public function getOperations($portName = '', $bindingType = 'soap') { - $ops = array(); + $ops = []; if ($bindingType == 'soap') { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; } elseif ($bindingType == 'soap12') { @@ -5882,7 +5893,7 @@ public function serializeRPCParameters($operation, $direction, $parameters, $bin $this->debug('check whether caller\'s parameters match the wrapped ones'); if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) { $this->debug('wrap the parameters for the caller'); - $parameters = array('parameters' => $parameters); + $parameters = ['parameters' => $parameters]; $parameter_count = 1; } } @@ -6256,7 +6267,7 @@ public function serializeType($name, $type, $value, $use = 'encoded', $encodingS return $xml; } if (isset($typeDef['multidimensional'])) { - $nv = array(); + $nv = []; foreach ($value as $v) { $cols = ',' . sizeof($v); $nv = array_merge($nv, $v); @@ -6355,7 +6366,7 @@ public function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) $xvalue = get_object_vars($value); } else { $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType"); - $xvalue = array(); + $xvalue = []; } foreach ($typeDef['attrs'] as $aName => $attrs) { if (isset($xvalue['!' . $aName])) { @@ -6419,7 +6430,7 @@ public function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $us $xvalue = get_object_vars($value); } else { $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType"); - $xvalue = array(); + $xvalue = []; } // toggle whether all elements are present - ideally should validate against schema if (count($typeDef['elements']) != count($xvalue)) { @@ -6503,13 +6514,13 @@ public function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $us * @see nusoap_xmlschema * @access public */ - public function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') + public function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = [], $attrs = [], $arrayType = '') { if (count($elements) > 0) { - $eElements = array(); + $eElements = []; foreach ($elements as $n => $e) { // expand each element - $ee = array(); + $ee = []; foreach ($e as $k => $v) { $k = strpos($k, ':') ? $this->expandQname($k) : $k; $v = strpos($v, ':') ? $this->expandQname($v) : $v; @@ -6551,7 +6562,7 @@ public function addComplexType($name, $typeClass = 'complexType', $phpType = 'ar * @see nusoap_xmlschema * @access public */ - public function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) + public function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = []) { $restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase; @@ -6593,46 +6604,49 @@ public function addOperation($name, $in = false, $out = false, $namespace = fals } if ($style == 'document') { - $elements = array(); + $elements = []; foreach ($in as $n => $t) { - $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified'); + $elements[$n] = ['name' => $n, 'type' => $t, 'form' => 'unqualified']; } $this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements); - $this->addElement(array('name' => $name, 'type' => $name . 'RequestType')); - $in = array('parameters' => 'tns:' . $name . '^'); + $this->addElement(['name' => $name, 'type' => $name . 'RequestType']); + $in = ['parameters' => 'tns:' . $name . '^']; - $elements = array(); + $elements = []; foreach ($out as $n => $t) { - $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified'); + $elements[$n] = ['name' => $n, 'type' => $t, 'form' => 'unqualified']; } $this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements); - $this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified')); - $out = array('parameters' => 'tns:' . $name . 'Response' . '^'); + $this->addElement(['name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified']); + $out = ['parameters' => 'tns:' . $name . 'Response' . '^']; } // get binding $this->bindings[$this->serviceName . 'Binding']['operations'][$name] = - array( + [ 'name' => $name, 'binding' => $this->serviceName . 'Binding', 'endpoint' => $this->endpoint, 'soapAction' => $soapaction, 'style' => $style, - 'input' => array( + 'input' => [ 'use' => $use, 'namespace' => $namespace, 'encodingStyle' => $encodingStyle, 'message' => $name . 'Request', - 'parts' => $in), - 'output' => array( + 'parts' => $in + ], + 'output' => [ 'use' => $use, 'namespace' => $namespace, 'encodingStyle' => $encodingStyle, 'message' => $name . 'Response', - 'parts' => $out), + 'parts' => $out + ], 'namespace' => $namespace, 'transport' => 'http://schemas.xmlsoap.org/soap/http', - 'documentation' => $documentation); + 'documentation' => $documentation + ]; // add portTypes // add messages if ($in) { @@ -6684,14 +6698,14 @@ class nusoap_parser extends nusoap_base public $position = 0; public $depth = 0; public $default_namespace = ''; - public $namespaces = array(); - public $message = array(); + public $namespaces = []; + public $message = []; public $parent = ''; public $fault = false; public $fault_code = ''; public $fault_str = ''; public $fault_detail = ''; - public $depth_array = array(); + public $depth_array = []; public $debug_flag = true; public $soapresponse = null; // parsed SOAP Body public $soapheader = null; // parsed SOAP Header @@ -6699,9 +6713,9 @@ class nusoap_parser extends nusoap_base public $body_position = 0; // for multiref parsing: // array of id => pos - public $ids = array(); + public $ids = []; // array of id => hrefs => pos - public $multirefs = array(); + public $multirefs = []; // toggle for auto-decoding element content public $decode_utf8 = true; @@ -6818,7 +6832,7 @@ public function start_element($parser, $name, $attrs) // update class level pos $pos = $this->position++; // and set mine - $this->message[$pos] = array('pos' => $pos, 'children' => '', 'cdata' => ''); + $this->message[$pos] = ['pos' => $pos, 'children' => '', 'cdata' => '']; // depth = how many levels removed from root? // set mine as current global depth and increment global depth value $this->message[$pos]['depth'] = $this->depth++; @@ -7181,7 +7195,7 @@ public function decodeSimple($value, $type, $typens) } // bogus: parser treats array with no elements as a simple type if ($type == 'array') { - return array(); + return []; } // everything else return (string) $value; @@ -7250,7 +7264,7 @@ public function buildVal($pos) if (isset($params[$this->message[$child_pos]['name']])) { // de-serialize repeated element name into an array if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { - $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); + $params[$this->message[$child_pos]['name']] = [$params[$this->message[$child_pos]['name']]]; } $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; } else { @@ -7279,7 +7293,7 @@ public function buildVal($pos) } } } - $ret = is_array($params) ? $params : array(); + $ret = is_array($params) ? $params : []; $this->debug('in buildVal, return:'); $this->appendDebug($this->varDump($ret)); return $ret; @@ -7338,7 +7352,7 @@ class nusoap_client extends nusoap_base public $username = ''; // Username for HTTP authentication public $password = ''; // Password for HTTP authentication public $authtype = ''; // Type of HTTP authentication - public $certRequest = array(); // Certificate for HTTP SSL authentication + public $certRequest = []; // Certificate for HTTP SSL authentication public $requestHeaders = false; // SOAP headers in request (text) public $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text) public $responseHeader = null; // SOAP Header from response (parsed) @@ -7360,10 +7374,10 @@ class nusoap_client extends nusoap_base public $request = ''; // HTTP request public $response = ''; // HTTP response public $responseData = ''; // SOAP payload of response - public $cookies = array(); // Cookies from response or for request + public $cookies = []; // Cookies from response or for request public $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode() - public $operations = array(); // WSDL operations, empty for WSDL initialization error - public $curl_options = array(); // User-specified cURL options + public $operations = []; // WSDL operations, empty for WSDL initialization error + public $curl_options = []; // User-specified cURL options public $bindingType = ''; // WSDL operation binding type public $use_curl = false; // whether to always try to use cURL @@ -7465,7 +7479,7 @@ public function __construct($endpoint, $wsdl = false, $proxyhost = false, $proxy * @return mixed response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors * @access public */ - public function call($operation, $params = array(), $namespace = 'http://tempuri.org', $soapAction = '', $headers = false, $rpcParams = null, $style = 'rpc', $use = 'encoded') + public function call($operation, $params = [], $namespace = 'http://tempuri.org', $soapAction = '', $headers = false, $rpcParams = null, $style = 'rpc', $use = 'encoded') { $this->operation = $operation; $this->fault = false; @@ -7475,7 +7489,7 @@ public function call($operation, $params = array(), $namespace = 'http://tempuri $this->responseData = ''; $this->faultstring = ''; $this->faultcode = ''; - $this->opData = array(); + $this->opData = []; $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType"); $this->appendDebug('params=' . $this->varDump($params)); @@ -7563,7 +7577,7 @@ public function call($operation, $params = array(), $namespace = 'http://tempuri $this->setError('params must be array or string'); return false; } - $usedNamespaces = array(); + $usedNamespaces = []; if ($use == 'encoded') { $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; } else { @@ -7754,7 +7768,7 @@ public function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 3 $http->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword); } if ($this->authtype != '') { - $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); + $http->setCredentials($this->username, $this->password, $this->authtype, [], $this->certRequest); } if ($this->http_encoding != '') { $http->setEncoding($this->http_encoding); @@ -7949,7 +7963,7 @@ public function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxy * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) * @access public */ - public function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) + public function setCredentials($username, $password, $authtype = 'basic', $certRequest = []) { $this->debug("setCredentials username=$username authtype=$authtype certRequest="); $this->appendDebug($this->varDump($certRequest)); @@ -8212,7 +8226,7 @@ public function setCookie($name, $value) if (strlen($name) == 0) { return false; } - $this->cookies[] = array('name' => $name, 'value' => $value); + $this->cookies[] = ['name' => $name, 'value' => $value]; return true; } @@ -8240,7 +8254,7 @@ public function checkCookies() } $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies'); $curr_cookies = $this->cookies; - $this->cookies = array(); + $this->cookies = []; foreach ($curr_cookies as $cookie) { if (!is_array($cookie)) { $this->debug('Remove cookie that is not an array'); From 98f13dafc7383461990e6f3f7055e253f7b55e19 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 10 Jun 2018 19:50:02 -0400 Subject: [PATCH 05/40] private access --- src/nusoap.php | 238 ++++++++++++++++++++++++------------------------- 1 file changed, 119 insertions(+), 119 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index 5697c51..a94dd60 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -91,35 +91,35 @@ class nusoap_base * @var string * @access private */ - public $title = 'NuSOAP'; + private $title = 'NuSOAP'; /** * Version for HTTP headers. * * @var string * @access private */ - public $version = '0.9.6'; + private $version = '0.9.6'; /** * CVS revision for HTTP headers. * * @var string * @access private */ - public $revision = '$Revision: 1.123 $'; + private $revision = '$Revision: 1.123 $'; /** * Current error string (manipulated by getError/setError) * * @var string * @access private */ - public $error_str = ''; + private $error_str = ''; /** * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment) * * @var string * @access private */ - public $debug_str = ''; + private $debug_str = ''; /** * toggles automatic encoding of special characters as entities * (should always be true, I think) @@ -127,14 +127,14 @@ class nusoap_base * @var boolean * @access private */ - public $charencoding = true; + private $charencoding = true; /** * the debug level for this instance * * @var integer * @access private */ - public $debugLevel; + private $debugLevel; /** * set schema version @@ -174,7 +174,7 @@ class nusoap_base * @var array * @access private */ - public $usedNamespaces = []; + private $usedNamespaces = []; /** * XML Schema types in an array of uri => (array of xml type => php type) @@ -285,7 +285,7 @@ public function setDebugLevel($level) * @param string $string debug data * @access private */ - public function debug($string) + private function debug($string) { if ($this->debugLevel > 0) { $this->appendDebug($this->getmicrotime() . ' ' . get_class($this) . ": $string\n"); @@ -356,7 +356,7 @@ public function &getDebugAsXMLComment() * @param string $val The string in which to expand entities. * @access private */ - public function expandEntities($val) + private function expandEntities($val) { if ($this->charencoding) { $val = str_replace('&', '&', $val); @@ -388,7 +388,7 @@ public function getError() * @return boolean $string error string * @access private */ - public function setError($str) + private function setError($str) { $this->error_str = $str; } @@ -400,7 +400,7 @@ public function setError($str) * @return string (arraySimple|arrayStruct) * @access private */ - public function isArraySimpleOrStruct($val) + private function isArraySimpleOrStruct($val) { $keyList = array_keys($val); foreach ($keyList as $keyListValue) { @@ -415,14 +415,14 @@ public function isArraySimpleOrStruct($val) * serializes PHP values in accordance w/ section 5. Type information is * not serialized if $use == 'literal'. * - * @param mixed $val The value to serialize + * @param mixed $val The value to serialize * @param string $name The name (local part) of the XML element * @param string $type The XML schema type (local part) for the element * @param string $name_ns The namespace for the name of the XML element * @param string $type_ns The namespace for the type of the element * @param array $attributes The attributes to serialize as name=>value pairs - * @param string $use The WSDL "use" (encoded|literal) - * @param boolean $soapval Whether this is called from soapval. + * @param string $use The WSDL "use" (encoded|literal) + * @param boolean $soapval Whether this is called from soapval. * @return string The serialized element, possibly with child elements * @access public */ @@ -762,7 +762,7 @@ public function formatDump($str) * @return string contracted qname * @access private */ - public function contractQName($qname) + private function contractQName($qname) { // get element namespace //$this->xdebug("Contract $qname"); @@ -788,7 +788,7 @@ public function contractQName($qname) * @return string expanded qname * @access private */ - public function expandQname($qname) + private function expandQname($qname) { // get element prefix if (strpos($qname, ':') && !preg_match('/^http:\/\//', $qname)) { @@ -1044,28 +1044,28 @@ class nusoap_fault extends nusoap_base * @var string * @access private */ - public $faultcode; + private $faultcode; /** * The fault actor * * @var string * @access private */ - public $faultactor; + private $faultactor; /** * The fault string, a description of the fault * * @var string * @access private */ - public $faultstring; + private $faultstring; /** * The fault detail, typically a string or array of string * * @var mixed * @access private */ - public $faultdetail; + private $faultdetail; /** * constructor @@ -1165,8 +1165,8 @@ class nusoap_xmlschema extends nusoap_base /** * constructor * - * @param string $schema schema document URI - * @param string $xml xml document URI + * @param string $schema schema document URI + * @param string $xml xml document URI * @param string $namespaces namespaces defined in enclosing XML * @access public */ @@ -1230,7 +1230,7 @@ public function parseFile($xml, $type) * @param string $type (schema|xml) * @access private */ - public function parseString($xml, $type) + private function parseString($xml, $type) { // parse xml string if ($xml != "") { @@ -1280,7 +1280,7 @@ public function parseString($xml, $type) * @return string A type name for an unnamed type * @access private */ - public function CreateTypeName($ename) + private function CreateTypeName($ename) { $scope = ''; for ($i = 0; $i < count($this->complexTypeStack); $i++) { @@ -1297,7 +1297,7 @@ public function CreateTypeName($ename) * @param string $attrs associative array of attributes * @access private */ - public function schemaStartElement($parser, $name, $attrs) + private function schemaStartElement($parser, $name, $attrs) { // position in the total number of elements, starting from 0 @@ -1625,7 +1625,7 @@ public function schemaStartElement($parser, $name, $attrs) * @param string $name element name * @access private */ - public function schemaEndElement($parser, $name) + private function schemaEndElement($parser, $name) { // bring depth down a notch $this->depth--; @@ -1665,7 +1665,7 @@ public function schemaEndElement($parser, $name) * @param string $data element content * @access private */ - public function schemaCharacterData($parser, $data) + private function schemaCharacterData($parser, $data) { $pos = $this->depth_array[$this->depth - 1]; $this->message[$pos]['cdata'] .= $data; @@ -1794,7 +1794,7 @@ public function serializeSchema() * @param string $string debug data * @access private */ - public function xdebug($string) + private function xdebug($string) { $this->debug('<' . $this->schemaTargetNamespace . '> ' . $string); } @@ -2033,7 +2033,7 @@ public function typeToForm($name, $type) * ) * @param arrayType : namespace:name (http://www.w3.org/2001/XMLSchema:string) * @access public - * @see getTypeDef + * @see getTypeDef */ public function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = [], $attrs = [], $arrayType = '') { @@ -2125,42 +2125,42 @@ class soapval extends nusoap_base * @var string * @access private */ - public $name; + private $name; /** * The XML type name (string or false) * * @var mixed * @access private */ - public $type; + private $type; /** * The PHP value * * @var mixed * @access private */ - public $value; + private $value; /** * The XML element namespace (string or false) * * @var mixed * @access private */ - public $element_ns; + private $element_ns; /** * The XML type namespace (string or false) * * @var mixed * @access private */ - public $type_ns; + private $type_ns; /** * The XML element attributes (array or false) * * @var mixed * @access private */ - public $attributes; + private $attributes; /** * constructor @@ -2284,7 +2284,7 @@ public function __construct($url, $curl_options = null, $use_curl = false) * @param mixed $value The cURL option value * @access private */ - public function setCurlOption($option, $value) + private function setCurlOption($option, $value) { $this->debug("setCurlOption option=$option, value="); $this->appendDebug($this->varDump($value)); @@ -2298,7 +2298,7 @@ public function setCurlOption($option, $value) * @param string $value The value of the header * @access private */ - public function setHeader($name, $value) + private function setHeader($name, $value) { $this->outgoing_headers[$name] = $value; $this->debug("set header $name: $value"); @@ -2310,7 +2310,7 @@ public function setHeader($name, $value) * @param string $name The name of the header * @access private */ - public function unsetHeader($name) + private function unsetHeader($name) { if (isset($this->outgoing_headers[$name])) { $this->debug("unset header $name"); @@ -2324,7 +2324,7 @@ public function unsetHeader($name) * @param string $url The URL to which to connect * @access private */ - public function setURL($url) + private function setURL($url) { $this->url = $url; @@ -2369,7 +2369,7 @@ public function setURL($url) * @return string I/O method to use (socket|curl|unknown) * @access private */ - public function io_method() + private function io_method() { if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) { return 'curl'; @@ -2388,7 +2388,7 @@ public function io_method() * @return boolean true if connected, false if not * @access private */ - public function connect($connection_timeout = 0, $response_timeout = 30) + private function connect($connection_timeout = 0, $response_timeout = 30) { // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like // "regular" socket. @@ -2827,7 +2827,7 @@ public function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypass * @returns boolean Whether a skippable header was found. * @access private */ - public function isSkippableCurlHeader(&$data) + private function isSkippableCurlHeader(&$data) { $skipHeaders = [ 'HTTP/1.1 100', @@ -2917,7 +2917,7 @@ public function decodeChunked($buffer, $lb) * @return void * @access private */ - public function buildPayload($data, $cookie_str = '') + private function buildPayload($data, $cookie_str = '') { // Note: for cURL connections, $this->outgoing_payload is ignored, // as is the Content-Length header, but these are still created as @@ -2967,7 +2967,7 @@ public function buildPayload($data, $cookie_str = '') * @return boolean true if OK, false if problem * @access private */ - public function sendRequest($data, $cookies = null) + private function sendRequest($data, $cookies = null) { // build cookie string $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https'))); @@ -3025,7 +3025,7 @@ public function sendRequest($data, $cookies = null) * @return string the response (also sets member variables like incoming_payload) * @access private */ - public function getResponse() + private function getResponse() { $this->incoming_payload = ''; @@ -3436,7 +3436,7 @@ public function usePersistentConnection() /* * TODO: allow a Set-Cookie string to be parsed into multiple cookies */ - public function parseCookie($cookie_str) + private function parseCookie($cookie_str) { $cookie_str = str_replace('; ', ';', $cookie_str) . ';'; $data = preg_split('/;/', $cookie_str); @@ -3502,7 +3502,7 @@ public function parseCookie($cookie_str) * @return string for Cookie-HTTP-Header * @access private */ - public function getCookiesForRequest($cookies, $secure = false) + private function getCookiesForRequest($cookies, $secure = false) { $cookie_str = ''; if ((!is_null($cookies)) && (is_array($cookies))) { @@ -3562,14 +3562,14 @@ class nusoap_server extends nusoap_base * @var array * @access private */ - public $headers = []; + private $headers = []; /** * HTTP request * * @var string * @access private */ - public $request = ''; + private $request = ''; /** * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text) * @@ -3604,28 +3604,28 @@ class nusoap_server extends nusoap_base * @var string * @access private */ - public $methodURI = ''; + private $methodURI = ''; /** * name of method requested * * @var string * @access private */ - public $methodname = ''; + private $methodname = ''; /** * method parameters from request * * @var array * @access private */ - public $methodparams = []; + private $methodparams = []; /** * SOAP Action from request * * @var string * @access private */ - public $SOAPAction = ''; + private $SOAPAction = ''; /** * character set encoding of incoming (request) messages * @@ -3654,7 +3654,7 @@ class nusoap_server extends nusoap_base * @var string * @access private */ - public $response = ''; + private $response = ''; /** * SOAP headers for response (text or array of soapval or associative array) * @@ -3668,14 +3668,14 @@ class nusoap_server extends nusoap_base * @var string * @access private */ - public $responseSOAP = ''; + private $responseSOAP = ''; /** * method return value to place in response * * @var mixed * @access private */ - public $methodreturn = false; + private $methodreturn = false; /** * whether $methodreturn is a string of literal XML * @@ -3689,14 +3689,14 @@ class nusoap_server extends nusoap_base * @var mixed * @access private */ - public $fault = false; + private $fault = false; /** * text indication of result (for debugging) * * @var string * @access private */ - public $result = 'successful'; + private $result = 'successful'; /** * assoc array of operations => opData; operations are added by the register() @@ -3705,21 +3705,21 @@ class nusoap_server extends nusoap_base * @var array * @access private */ - public $operations = []; + private $operations = []; /** * wsdl instance (if one) * * @var mixed * @access private */ - public $wsdl = false; + private $wsdl = false; /** * URL for WSDL (if one) * * @var mixed * @access private */ - public $externalWSDLURL = false; + private $externalWSDLURL = false; /** * whether to append debug to response as XML comment * @@ -3885,7 +3885,7 @@ public function service($data) * * @access private */ - public function parse_http_headers() + private function parse_http_headers() { global $HTTP_SERVER_VARS; @@ -4014,7 +4014,7 @@ public function parse_http_headers() * @param string $data XML string * @access private */ - public function parse_request($data = '') + private function parse_request($data = '') { $this->debug('entering parse_request()'); $this->parse_http_headers(); @@ -4062,7 +4062,7 @@ public function parse_request($data = '') * * @access private */ - public function invoke_method() + private function invoke_method() { $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction); @@ -4224,7 +4224,7 @@ public function invoke_method() * * @access private */ - public function serialize_return() + private function serialize_return() { $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI); // if fault @@ -4325,7 +4325,7 @@ public function serialize_return() * * @access private */ - public function send_response() + private function send_response() { $this->debug('Enter send_response'); if ($this->fault) { @@ -4405,7 +4405,7 @@ public function send_response() * @return boolean Whether the operation was found * @access private */ - public function verify_method($operation, $request) + private function verify_method($operation, $request) { if (isset($this->wsdl) && is_object($this->wsdl)) { if ($this->wsdl->getOperationData($operation)) { @@ -4425,7 +4425,7 @@ public function verify_method($operation, $request) * @return mixed value of the message, decoded into a PHP type * @access private */ - public function parseRequest($headers, $data) + private function parseRequest($headers, $data) { $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:'); $this->appendDebug($this->varDump($headers)); @@ -4482,7 +4482,7 @@ public function parseRequest($headers, $data) * @return string The HTTP body, which includes the SOAP payload * @access private */ - public function getHTTPBody($soapmsg) + private function getHTTPBody($soapmsg) { return $soapmsg; } @@ -4495,7 +4495,7 @@ public function getHTTPBody($soapmsg) * @return string the HTTP content type for the current response. * @access private */ - public function getHTTPContentType() + private function getHTTPContentType() { return 'text/xml'; } @@ -4509,7 +4509,7 @@ public function getHTTPContentType() * @return string the HTTP content type charset for the current response. * @access private */ - public function getHTTPContentTypeCharset() + private function getHTTPContentTypeCharset() { return $this->soap_defencoding; } @@ -4771,15 +4771,15 @@ class wsdl extends nusoap_base /** * constructor * - * @param string $wsdl WSDL document URL + * @param string $wsdl WSDL document URL * @param string $proxyhost * @param string $proxyport * @param string $proxyusername * @param string $proxypassword - * @param integer $timeout set the connection timeout + * @param integer $timeout set the connection timeout * @param integer $response_timeout set the response timeout - * @param array $curl_options user-specified cURL options - * @param boolean $use_curl try to use cURL + * @param array $curl_options user-specified cURL options + * @param boolean $use_curl try to use cURL * @access public */ public function __construct($wsdl = '', $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $curl_options = null, $use_curl = false) @@ -4908,7 +4908,7 @@ public function fetchWSDL($wsdl) * @param string $wsdl path or URL * @access private */ - public function parseWSDL($wsdl = '') + private function parseWSDL($wsdl = '') { $this->debug("parse WSDL at path=$wsdl"); @@ -5016,7 +5016,7 @@ public function parseWSDL($wsdl = '') * @param string $attrs associative array of attributes * @access private */ - public function start_element($parser, $name, $attrs) + private function start_element($parser, $name, $attrs) { if ($this->status == 'schema') { $this->currentSchema->schemaStartElement($parser, $name, $attrs); @@ -5233,7 +5233,7 @@ public function start_element($parser, $name, $attrs) * @param string $name element name * @access private */ - public function end_element($parser, $name) + private function end_element($parser, $name) { // unset schema status if (/*preg_match('/types$/', $name) ||*/ @@ -5266,7 +5266,7 @@ public function end_element($parser, $name) * @param string $data element content * @access private */ - public function character_data($parser, $data) + private function character_data($parser, $data) { $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0; if (isset($this->message[$pos]['cdata'])) { @@ -5484,7 +5484,7 @@ public function getTypeDef($type, $ns) * * @access private */ - public function webDescription() + private function webDescription() { global $HTTP_SERVER_VARS; @@ -5758,7 +5758,7 @@ public function serialize($debug = 0) * @return boolean whether they parameters are unwrapped (and should be wrapped) * @access private */ - public function parametersMatchWrapped($type, &$parameters) + private function parametersMatchWrapped($type, &$parameters) { $this->debug("in parametersMatchWrapped type=$type, parameters="); $this->appendDebug($this->varDump($parameters)); @@ -6013,16 +6013,16 @@ public function serializeParameters($operation, $direction, $parameters) /** * serializes a PHP value according a given type definition * - * @param string $name name of value (part or element) - * @param string $type XML schema type of value (type or element) - * @param mixed $value a native PHP value (parameter value) - * @param string $use use for part (encoded|literal) + * @param string $name name of value (part or element) + * @param string $type XML schema type of value (type or element) + * @param mixed $value a native PHP value (parameter value) + * @param string $use use for part (encoded|literal) * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style) - * @param boolean $unqualified a kludge for what should be XML namespace form handling + * @param boolean $unqualified a kludge for what should be XML namespace form handling * @return string value serialized as an XML string * @access private */ - public function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle = false, $unqualified = false) + private function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle = false, $unqualified = false) { $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified")); $this->appendDebug("value=" . $this->varDump($value)); @@ -6341,7 +6341,7 @@ public function serializeType($name, $type, $value, $use = 'encoded', $encodingS * @return string value serialized as an XML string * @access private */ - public function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) + private function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) { $this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType"); $xml = ''; @@ -6396,16 +6396,16 @@ public function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) /** * serializes the elements for a complexType * - * @param array $typeDef our internal representation of an XML schema type (or element) - * @param mixed $value a native PHP value (parameter value) - * @param string $ns the namespace of the type - * @param string $uqType the local part of the type - * @param string $use use for part (encoded|literal) + * @param array $typeDef our internal representation of an XML schema type (or element) + * @param mixed $value a native PHP value (parameter value) + * @param string $ns the namespace of the type + * @param string $uqType the local part of the type + * @param string $use use for part (encoded|literal) * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style) * @return string value serialized as an XML string * @access private */ - public function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use = 'encoded', $encodingStyle = false) + private function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use = 'encoded', $encodingStyle = false) { $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType"); $xml = ''; @@ -6586,13 +6586,13 @@ public function addElement($attrs) /** * register an operation with the server * - * @param string $name operation (method) name + * @param string $name operation (method) name * @param array $in assoc array of input values: key = param name, value = param type * @param array $out assoc array of output values: key = param name, value = param type * @param string $namespace optional The namespace for the operation * @param string $soapaction optional The soapaction for the operation - * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically - * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now) + * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically + * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now) * @param string $documentation optional The description to include in the WSDL * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) * @access public @@ -6722,9 +6722,9 @@ class nusoap_parser extends nusoap_base /** * constructor that actually does the parsing * - * @param string $xml SOAP message - * @param string $encoding character encoding scheme of message - * @param string $method method for which XML is parsed (unused?) + * @param string $xml SOAP message + * @param string $encoding character encoding scheme of message + * @param string $method method for which XML is parsed (unused?) * @param string $decode_utf8 whether to decode UTF-8 to ISO-8859-1 * @access public */ @@ -6826,7 +6826,7 @@ public function __construct($xml, $encoding = 'UTF-8', $method = '', $decode_utf * @param array $attrs associative array of attributes * @access private */ - public function start_element($parser, $name, $attrs) + private function start_element($parser, $name, $attrs) { // position in a total number of elements, starting from 0 // update class level pos @@ -6982,7 +6982,7 @@ public function start_element($parser, $name, $attrs) * @param string $name element name * @access private */ - public function end_element($parser, $name) + private function end_element($parser, $name) { // position of current element is equal to the last value left in depth_array for my depth $pos = $this->depth_array[$this->depth--]; @@ -7089,7 +7089,7 @@ public function end_element($parser, $name) * @param string $data element content * @access private */ - public function character_data($parser, $data) + private function character_data($parser, $data) { $pos = $this->depth_array[$this->depth]; if ($this->xml_encoding == 'UTF-8') { @@ -7163,7 +7163,7 @@ public function getHeaders() * @return mixed PHP value * @access private */ - public function decodeSimple($value, $type, $typens) + private function decodeSimple($value, $type, $typens) { // TODO: use the namespace! if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { @@ -7209,7 +7209,7 @@ public function decodeSimple($value, $type, $typens) * @return mixed PHP value * @access private */ - public function buildVal($pos) + private function buildVal($pos) { if (!isset($this->message[$pos]['type'])) { $this->message[$pos]['type'] = ''; @@ -7408,15 +7408,15 @@ class nusoap_client extends nusoap_base /** * constructor * - * @param mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object) - * @param mixed $wsdl optional, set to 'wsdl' or true if using WSDL + * @param mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object) + * @param mixed $wsdl optional, set to 'wsdl' or true if using WSDL * @param string $proxyhost optional * @param string $proxyport optional * @param string $proxyusername optional * @param string $proxypassword optional - * @param integer $timeout set the connection timeout + * @param integer $timeout set the connection timeout * @param integer $response_timeout set the response timeout - * @param string $portName optional portName in WSDL document + * @param string $portName optional portName in WSDL document * @access public */ public function __construct($endpoint, $wsdl = false, $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = '') @@ -7667,7 +7667,7 @@ public function call($operation, $params = [], $namespace = 'http://tempuri.org' * * @access private */ - public function checkWSDL() + private function checkWSDL() { $this->appendDebug($this->wsdl->getDebug()); $this->wsdl->clearDebug(); @@ -7746,7 +7746,7 @@ public function getOperationData($operation) * @return mixed native PHP types. * @access private */ - public function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30) + private function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30) { $this->checkCookies(); // detect transport @@ -7826,7 +7826,7 @@ public function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 3 * @return mixed value of the message, decoded into a PHP type * @access private */ - public function parseResponse($headers, $data) + private function parseResponse($headers, $data) { $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:'); $this->appendDebug($this->varDump($headers)); @@ -8096,7 +8096,7 @@ public function getProxy() * @return string PHP/NuSOAP code for the proxy class * @access private */ - public function _getProxyClassCode($r) + private function _getProxyClassCode($r) { $this->debug("in getProxy endpointType=$this->endpointType"); $this->appendDebug("wsdl=" . $this->varDump($this->wsdl)); @@ -8169,7 +8169,7 @@ public function getProxyClassCode() * @return string The HTTP body, which includes the SOAP payload * @access private */ - public function getHTTPBody($soapmsg) + private function getHTTPBody($soapmsg) { return $soapmsg; } @@ -8182,7 +8182,7 @@ public function getHTTPBody($soapmsg) * @return string the HTTP content type for the current request. * @access private */ - public function getHTTPContentType() + private function getHTTPContentType() { return 'text/xml'; } @@ -8196,7 +8196,7 @@ public function getHTTPContentType() * @return string the HTTP content type charset for the current request. * @access private */ - public function getHTTPContentTypeCharset() + private function getHTTPContentTypeCharset() { return $this->soap_defencoding; } @@ -8247,7 +8247,7 @@ public function getCookies() * @return boolean always return true * @access private */ - public function checkCookies() + private function checkCookies() { if (sizeof($this->cookies) == 0) { return true; @@ -8281,7 +8281,7 @@ public function checkCookies() * @return boolean always return true * @access private */ - public function UpdateCookies($cookies) + private function UpdateCookies($cookies) { if (sizeof($this->cookies) == 0) { // no existing cookies: take whatever is new From 2c1f783fcd3815c878997b230d11f9fe16852a17 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 10 Jun 2018 19:53:45 -0400 Subject: [PATCH 06/40] Field 'namespaces' is already defined in \nusoap_base --- src/nusoap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nusoap.php b/src/nusoap.php index a94dd60..c7a9f5c 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -6698,7 +6698,7 @@ class nusoap_parser extends nusoap_base public $position = 0; public $depth = 0; public $default_namespace = ''; - public $namespaces = []; +// public $namespaces = []; //Field 'namespaces' is already defined in \nusoap_base public $message = []; public $parent = ''; public $fault = false; From 460228e008737bae2a760f8d8889a31e350ea64e Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 10 Jun 2018 19:55:43 -0400 Subject: [PATCH 07/40] Unnecessary double quotes --- src/nusoap.php | 304 ++++++++++++++++++++++++------------------------- 1 file changed, 150 insertions(+), 154 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index c7a9f5c..e4402c3 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -433,7 +433,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal $this->appendDebug('attributes=' . $this->varDump($attributes)); if (is_object($val) && get_class($val) == 'soapval' && (!$soapval)) { - $this->debug("serialize_val: serialize soapval"); + $this->debug('serialize_val: serialize soapval'); $xml = $val->serialize($use); $this->appendDebug($val->getDebug()); $val->clearDebug(); @@ -471,7 +471,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } // serialize null value if (is_null($val)) { - $this->debug("serialize_val: serialize null"); + $this->debug('serialize_val: serialize null'); if ($use == 'literal') { // TODO: depends on minOccurs $xml = "<$name$xmlns$atts/>"; @@ -490,7 +490,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } // serialize if an xsd built-in primitive type if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) { - $this->debug("serialize_val: serialize xsd built-in primitive type"); + $this->debug('serialize_val: serialize xsd built-in primitive type'); if (is_bool($val)) { if ($type == 'boolean') { $val = $val ? 'true' : 'false'; @@ -514,7 +514,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal $xml = ''; switch (true) { case (is_bool($val) || $type == 'boolean'): - $this->debug("serialize_val: serialize boolean"); + $this->debug('serialize_val: serialize boolean'); if ($type == 'boolean') { $val = $val ? 'true' : 'false'; } elseif (!$val) { @@ -527,7 +527,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } break; case (is_int($val) || is_long($val) || $type == 'int'): - $this->debug("serialize_val: serialize int"); + $this->debug('serialize_val: serialize int'); if ($use == 'literal') { $xml .= "<$name$xmlns$atts>$val"; } else { @@ -535,7 +535,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } break; case (is_float($val) || is_double($val) || $type == 'float'): - $this->debug("serialize_val: serialize float"); + $this->debug('serialize_val: serialize float'); if ($use == 'literal') { $xml .= "<$name$xmlns$atts>$val"; } else { @@ -543,7 +543,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } break; case (is_string($val) || $type == 'string'): - $this->debug("serialize_val: serialize string"); + $this->debug('serialize_val: serialize string'); $val = $this->expandEntities($val); if ($use == 'literal') { $xml .= "<$name$xmlns$atts>$val"; @@ -552,9 +552,9 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } break; case is_object($val): - $this->debug("serialize_val: serialize object"); + $this->debug('serialize_val: serialize object'); if (get_class($val) == 'soapval') { - $this->debug("serialize_val: serialize soapval object"); + $this->debug('serialize_val: serialize soapval object'); $pXml = $val->serialize($use); $this->appendDebug($val->getDebug()); $val->clearDebug(); @@ -585,7 +585,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal // detect if struct or array $valueType = $this->isArraySimpleOrStruct($val); if ($valueType == 'arraySimple' || preg_match('/^ArrayOf/', $type)) { - $this->debug("serialize_val: serialize array"); + $this->debug('serialize_val: serialize array'); $i = 0; if (is_array($val) && count($val) > 0) { foreach ($val as $v) { @@ -631,7 +631,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } elseif (isset($type) && isset($type_prefix)) { $type_str = " xsi:type=\"$type_prefix:$type\""; } else { - $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"" . $array_typename . "[$array_type]\""; + $type_str = ' xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="' . $array_typename . "[$array_type]\""; } // empty array } else { @@ -640,14 +640,14 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } elseif (isset($type) && isset($type_prefix)) { $type_str = " xsi:type=\"$type_prefix:$type\""; } else { - $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\""; + $type_str = ' xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[0]"'; } } // TODO: for array in literal, there is no wrapper here $xml = "<$name$xmlns$type_str$atts>" . $xml . ""; } else { // got a struct - $this->debug("serialize_val: serialize struct"); + $this->debug('serialize_val: serialize struct'); if (isset($type) && isset($type_prefix)) { $type_str = " xsi:type=\"$type_prefix:$type\""; } else { @@ -673,7 +673,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } break; default: - $this->debug("serialize_val: serialize unknown"); + $this->debug('serialize_val: serialize unknown'); $xml .= 'not detected, got ' . gettype($val) . ' for ' . $val; break; } @@ -699,10 +699,10 @@ public function serializeEnvelope($body, $headers = false, $namespaces = [], $st // if $this->soap_defencoding is UTF-8. Not doing this automatically allows // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1 - $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle"); - $this->debug("headers:"); + $this->debug('In serializeEnvelope length=' . strlen($body) . ' body (max 1000 characters)=' . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle"); + $this->debug('headers:'); $this->appendDebug($this->varDump($headers)); - $this->debug("namespaces:"); + $this->debug('namespaces:'); $this->appendDebug($this->varDump($namespaces)); // serialize namespaces @@ -728,17 +728,14 @@ public function serializeEnvelope($body, $headers = false, $namespaces = [], $st $headers = $xml; $this->debug("In serializeEnvelope, serialized array of headers to $headers"); } - $headers = "" . $headers . ""; + $headers = '' . $headers . ''; } // serialize envelope return - 'soap_defencoding . '"?' . ">" . - '" . - $headers . - "" . - $body . - "" . - ""; + 'soap_defencoding . '"?' . '>' . + '' . + $headers . '' . + $body . '' . ''; } /** @@ -938,9 +935,9 @@ public function __toString() function timestamp_to_iso8601($timestamp, $utc = true) { $datestr = date('Y-m-d\TH:i:sO', $timestamp); - $pos = strrpos($datestr, "+"); + $pos = strrpos($datestr, '+'); if ($pos === false) { - $pos = strrpos($datestr, "-"); + $pos = strrpos($datestr, '-'); } if ($pos !== false) { if (strlen($datestr) == $pos + 5) { @@ -1206,9 +1203,9 @@ public function __construct($schema = '', $xml = '', $namespaces = []) public function parseFile($xml, $type) { // parse xml file - if ($xml != "") { - $xmlStr = @join("", @file($xml)); - if ($xmlStr == "") { + if ($xml != '') { + $xmlStr = @join('', @file($xml)); + if ($xmlStr == '') { $msg = 'Error reading XML from ' . $xml; $this->setError($msg); $this->debug($msg); @@ -1233,7 +1230,7 @@ public function parseFile($xml, $type) private function parseString($xml, $type) { // parse xml string - if ($xml != "") { + if ($xml != '') { // Create an XML parser. $this->parser = xml_parser_create(); @@ -1244,10 +1241,10 @@ private function parseString($xml, $type) xml_set_object($this->parser, $this); // Set the element handlers for the parser. - if ($type == "schema") { + if ($type == 'schema') { xml_set_element_handler($this->parser, 'schemaStartElement', 'schemaEndElement'); xml_set_character_data_handler($this->parser, 'schemaCharacterData'); - } elseif ($type == "xml") { + } elseif ($type == 'xml') { xml_set_element_handler($this->parser, 'xmlStartElement', 'xmlEndElement'); xml_set_character_data_handler($this->parser, 'xmlCharacterData'); } @@ -1366,7 +1363,7 @@ private function schemaStartElement($parser, $name, $attrs) break; case 'attribute': // complexType attribute //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']); - $this->xdebug("parsing attribute:"); + $this->xdebug('parsing attribute:'); $this->appendDebug($this->varDump($attrs)); if (!isset($attrs['form'])) { // TODO: handle globals @@ -1478,7 +1475,7 @@ private function schemaStartElement($parser, $name, $attrs) } } if (isset($attrs['type'])) { - $this->xdebug("processing typed element " . $attrs['name'] . " of type " . $attrs['type']); + $this->xdebug('processing typed element ' . $attrs['name'] . ' of type ' . $attrs['type']); if (!$this->getPrefix($attrs['type'])) { if ($this->defaultNamespace[$pos]) { $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type']; @@ -1499,12 +1496,12 @@ private function schemaStartElement($parser, $name, $attrs) $this->currentElement = $attrs['name']; $ename = $attrs['name']; } elseif (isset($attrs['ref'])) { - $this->xdebug("processing element as ref to " . $attrs['ref']); - $this->currentElement = "ref to " . $attrs['ref']; + $this->xdebug('processing element as ref to ' . $attrs['ref']); + $this->currentElement = 'ref to ' . $attrs['ref']; $ename = $this->getLocalPart($attrs['ref']); } else { $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']); - $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type); + $this->xdebug('processing untyped element ' . $attrs['name'] . ' type ' . $type); $this->currentElement = $attrs['name']; $attrs['type'] = $this->schemaTargetNamespace . ':' . $type; $ename = $attrs['name']; @@ -1596,7 +1593,7 @@ private function schemaStartElement($parser, $name, $attrs) case 'simpleType': array_push($this->simpleTypeStack, $this->currentSimpleType); if (isset($attrs['name'])) { - $this->xdebug("processing simpleType for name " . $attrs['name']); + $this->xdebug('processing simpleType for name ' . $attrs['name']); $this->currentSimpleType = $attrs['name']; $this->simpleTypes[$attrs['name']] = $attrs; $this->simpleTypes[$attrs['name']]['typeClass'] = 'simpleType'; @@ -1701,7 +1698,7 @@ public function serializeSchema() if (isset($eParts['ref'])) { $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; } else { - $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\""; + $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . '"'; foreach ($eParts as $aName => $aValue) { // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable if ($aName != 'name' && $aName != 'type') { @@ -1932,12 +1929,12 @@ public function serializeTypeDef($type) $str .= '<' . $type; if (is_array($typeDef['attrs'])) { foreach ($typeDef['attrs'] as $attName => $data) { - $str .= " $attName=\"{type = " . $data['type'] . "}\""; + $str .= " $attName=\"{type = " . $data['type'] . '}"'; } } - $str .= " xmlns=\"" . $this->schema['targetNamespace'] . "\""; + $str .= ' xmlns="' . $this->schema['targetNamespace'] . '"'; if (count($typeDef['elements']) > 0) { - $str .= ">"; + $str .= '>'; foreach ($typeDef['elements'] as $element => $eData) { $str .= $this->serializeTypeDef($element); } @@ -1945,7 +1942,7 @@ public function serializeTypeDef($type) } elseif ($typeDef['typeClass'] == 'element') { $str .= ">"; } else { - $str .= "/>"; + $str .= '/>'; } return $str; } @@ -2093,7 +2090,7 @@ public function addElement($attrs) $this->elements[$attrs['name']] = $attrs; $this->elements[$attrs['name']]['typeClass'] = 'element'; - $this->xdebug("addElement " . $attrs['name']); + $this->xdebug('addElement ' . $attrs['name']); $this->appendDebug($this->varDump($this->elements[$attrs['name']])); } } @@ -2691,7 +2688,7 @@ public function setCredentials($username, $password, $authtype = 'basic', $diges { $this->debug("setCredentials username=$username authtype=$authtype digestRequest="); $this->appendDebug($this->varDump($digestRequest)); - $this->debug("certRequest="); + $this->debug('certRequest='); $this->appendDebug($this->varDump($certRequest)); // cf. RFC 2617 if ($authtype == 'basic') { @@ -2729,7 +2726,7 @@ public function setCredentials($username, $password, $authtype = 'basic', $diges $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : ''; $cnonce = $nonce; if ($digestRequest['qop'] != '') { - $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2; + $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf('%08d', $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2; } else { $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2; } @@ -2741,7 +2738,7 @@ public function setCredentials($username, $password, $authtype = 'basic', $diges $opaque = ', opaque="' . $digestRequest['opaque'] . '"'; } - $this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"'); + $this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf('%08x', $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"'); } } elseif ($authtype == 'certificate') { $this->certRequest = $certRequest; @@ -3003,7 +3000,7 @@ private function sendRequest($data, $cookies = null) } $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers); $this->debug('set cURL HTTP headers'); - if ($this->request_method == "POST") { + if ($this->request_method == 'POST') { $this->setCurlOption(CURLOPT_POST, 1); $this->setCurlOption(CURLOPT_POSTFIELDS, $data); $this->debug('set cURL POST data'); @@ -3050,7 +3047,7 @@ private function getResponse() if ($tmplen == 0) { $this->incoming_payload = $data; $this->debug('socket read of headers timed out after length ' . strlen($data)); - $this->debug("read before timeout: " . $data); + $this->debug('read before timeout: ' . $data); $this->setError('socket read of headers timed out'); return false; } @@ -3104,7 +3101,7 @@ private function getResponse() if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') { $content_length = 2147483647; // ignore any content-length header $chunked = true; - $this->debug("want to read chunked content"); + $this->debug('want to read chunked content'); } elseif (isset($this->incoming_headers['content-length'])) { $content_length = $this->incoming_headers['content-length']; $chunked = false; @@ -3112,7 +3109,7 @@ private function getResponse() } else { $content_length = 2147483647; $chunked = false; - $this->debug("want to read content to EOF"); + $this->debug('want to read content to EOF'); } $data = ''; do { @@ -3221,7 +3218,7 @@ private function getResponse() // try removing skippable headers $savedata = $data; while ($this->isSkippableCurlHeader($data)) { - $this->debug("Found HTTP header to skip"); + $this->debug('Found HTTP header to skip'); if ($pos = strpos($data, "\r\n\r\n")) { $data = ltrim(substr($data, $pos)); } elseif ($pos = strpos($data, "\n\n")) { @@ -3296,7 +3293,7 @@ private function getResponse() // see if we need to resend the request with http digest authentication if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) { $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']); - if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) { + if (strstr($this->incoming_headers['www-authenticate'], 'Digest ')) { $this->debug('Server wants digest authentication'); // remove "Digest " from our elements $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']); @@ -3305,7 +3302,7 @@ private function getResponse() $digestElements = explode(',', $digestString); foreach ($digestElements as $val) { $tempElement = explode('=', trim($val), 2); - $digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]); + $digestRequest[$tempElement[0]] = str_replace('"', '', $tempElement[1]); } // should have (at least) qop, realm, nonce @@ -3510,7 +3507,7 @@ private function getCookiesForRequest($cookies, $secure = false) if (!is_array($cookie)) { continue; } - $this->debug("check cookie for validity: " . $cookie['name'] . '=' . $cookie['value']); + $this->debug('check cookie for validity: ' . $cookie['name'] . '=' . $cookie['value']); if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) { if (strtotime($cookie['expires']) <= time()) { $this->debug('cookie has expired'); @@ -3744,13 +3741,13 @@ public function __construct($wsdl = false) global $HTTP_SERVER_VARS; if (isset($_SERVER)) { - $this->debug("_SERVER is defined:"); + $this->debug('_SERVER is defined:'); $this->appendDebug($this->varDump($_SERVER)); } elseif (isset($HTTP_SERVER_VARS)) { - $this->debug("HTTP_SERVER_VARS is defined:"); + $this->debug('HTTP_SERVER_VARS is defined:'); $this->appendDebug($this->varDump($HTTP_SERVER_VARS)); } else { - $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined."); + $this->debug('Neither _SERVER nor HTTP_SERVER_VARS is defined.'); } if (isset($debug)) { @@ -3760,7 +3757,7 @@ public function __construct($wsdl = false) $qs = explode('&', $_SERVER['QUERY_STRING']); foreach ($qs as $v) { if (substr($v, 0, 6) == 'debug=') { - $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1"); + $this->debug('In nusoap_server, set debug_flag=' . substr($v, 6) . ' based on query string #1'); $this->debug_flag = substr($v, 6); } } @@ -3768,7 +3765,7 @@ public function __construct($wsdl = false) $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']); foreach ($qs as $v) { if (substr($v, 0, 6) == 'debug=') { - $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2"); + $this->debug('In nusoap_server, set debug_flag=' . substr($v, 6) . ' based on query string #2'); $this->debug_flag = substr($v, 6); } } @@ -3776,7 +3773,7 @@ public function __construct($wsdl = false) // wsdl if ($wsdl) { - $this->debug("In nusoap_server, WSDL is specified"); + $this->debug('In nusoap_server, WSDL is specified'); if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) { $this->wsdl = $wsdl; $this->externalWSDLURL = $this->wsdl->wsdl; @@ -3822,7 +3819,7 @@ public function service($data) $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data)); if ($rm == 'POST') { - $this->debug("In service, invoke the request"); + $this->debug('In service, invoke the request'); $this->parse_request($data); if (!$this->fault) { $this->invoke_method(); @@ -3832,15 +3829,15 @@ public function service($data) } $this->send_response(); } elseif (preg_match('/wsdl/', $qs)) { - $this->debug("In service, this is a request for WSDL"); + $this->debug('In service, this is a request for WSDL'); if ($this->externalWSDLURL) { - if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL - $this->debug("In service, re-direct for WSDL"); + if (strpos($this->externalWSDLURL, 'http://') !== false) { // assume URL + $this->debug('In service, re-direct for WSDL'); header('Location: ' . $this->externalWSDLURL); } else { // assume file - $this->debug("In service, use file passthru for WSDL"); + $this->debug('In service, use file passthru for WSDL'); header("Content-Type: text/xml\r\n"); - $pos = strpos($this->externalWSDLURL, "file://"); + $pos = strpos($this->externalWSDLURL, 'file://'); if ($pos === false) { $filename = $this->externalWSDLURL; } else { @@ -3850,7 +3847,7 @@ public function service($data) fpassthru($fp); } } elseif ($this->wsdl) { - $this->debug("In service, serialize WSDL"); + $this->debug('In service, serialize WSDL'); header("Content-Type: text/xml; charset=ISO-8859-1\r\n"); print $this->wsdl->serialize($this->debug_flag); if ($this->debug_flag) { @@ -3859,17 +3856,17 @@ public function service($data) print $this->getDebugAsXMLComment(); } } else { - $this->debug("In service, there is no WSDL"); + $this->debug('In service, there is no WSDL'); header("Content-Type: text/html; charset=ISO-8859-1\r\n"); - print "This service does not provide WSDL"; + print 'This service does not provide WSDL'; } } elseif ($this->wsdl) { - $this->debug("In service, return Web description"); + $this->debug('In service, return Web description'); print $this->wsdl->webDescription(); } else { - $this->debug("In service, no Web description"); + $this->debug('In service, no Web description'); header("Content-Type: text/html; charset=ISO-8859-1\r\n"); - print "This service does not provide a Web description"; + print 'This service does not provide a Web description'; } } @@ -3892,7 +3889,7 @@ private function parse_http_headers() $this->request = ''; $this->SOAPAction = ''; if (function_exists('getallheaders')) { - $this->debug("In parse_http_headers, use getallheaders"); + $this->debug('In parse_http_headers, use getallheaders'); $headers = getallheaders(); foreach ($headers as $k => $v) { $k = strtolower($k); @@ -3906,7 +3903,7 @@ private function parse_http_headers() } // get the character encoding of the incoming request if (isset($this->headers['content-type']) && strpos($this->headers['content-type'], '=')) { - $enc = str_replace('"', '', substr(strstr($this->headers["content-type"], '='), 1)); + $enc = str_replace('"', '', substr(strstr($this->headers['content-type'], '='), 1)); if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { $this->xml_encoding = strtoupper($enc); } else { @@ -3917,7 +3914,7 @@ private function parse_http_headers() $this->xml_encoding = 'ISO-8859-1'; } } elseif (isset($_SERVER) && is_array($_SERVER)) { - $this->debug("In parse_http_headers, use _SERVER"); + $this->debug('In parse_http_headers, use _SERVER'); foreach ($_SERVER as $k => $v) { if (substr($k, 0, 5) == 'HTTP_') { $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); @@ -3951,7 +3948,7 @@ private function parse_http_headers() $this->debug("$k: $v"); } } elseif (is_array($HTTP_SERVER_VARS)) { - $this->debug("In parse_http_headers, use HTTP_SERVER_VARS"); + $this->debug('In parse_http_headers, use HTTP_SERVER_VARS'); foreach ($HTTP_SERVER_VARS as $k => $v) { if (substr($k, 0, 5) == 'HTTP_') { $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); @@ -3987,8 +3984,8 @@ private function parse_http_headers() $this->debug("$k: $v"); } } else { - $this->debug("In parse_http_headers, HTTP headers not accessible"); - $this->setError("HTTP headers not accessible"); + $this->debug('In parse_http_headers, HTTP headers not accessible'); + $this->setError('HTTP headers not accessible'); } } @@ -4125,7 +4122,7 @@ private function invoke_method() $class = implode('\\', $split); } else { $try_class = ''; - $this->debug("in invoke_method, no class to try"); + $this->debug('in invoke_method, no class to try'); } // does method exist? @@ -4168,13 +4165,13 @@ private function invoke_method() } else { if ($delim == '..') { $this->debug('in invoke_method, calling class method using eval()'); - $funcCall = "\$this->methodreturn = " . $class . "::" . $method . "("; + $funcCall = '$this->methodreturn = ' . $class . '::' . $method . '('; } else { $this->debug('in invoke_method, calling instance method using eval()'); // generate unique instance name - $instname = "\$inst_" . time(); - $funcCall = $instname . " = new " . $class . "(); "; - $funcCall .= "\$this->methodreturn = " . $instname . "->" . $method . "("; + $instname = '$inst_' . time(); + $funcCall = $instname . ' = new ' . $class . '(); '; + $funcCall .= '$this->methodreturn = ' . $instname . '->' . $method . '('; } } if ($this->methodparams) { @@ -4278,13 +4275,13 @@ private function serialize_return() if ($this->opData['output']['use'] == 'literal') { // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace if ($this->methodURI) { - $payload = 'methodname . 'Response xmlns:ns1="' . $this->methodURI . '">' . $return_val . 'methodname . "Response>"; + $payload = 'methodname . 'Response xmlns:ns1="' . $this->methodURI . '">' . $return_val . 'methodname . 'Response>'; } else { $payload = '<' . $this->methodname . 'Response>' . $return_val . 'methodname . 'Response>'; } } else { if ($this->methodURI) { - $payload = 'methodname . 'Response xmlns:ns1="' . $this->methodURI . '">' . $return_val . 'methodname . "Response>"; + $payload = 'methodname . 'Response xmlns:ns1="' . $this->methodURI . '">' . $return_val . 'methodname . 'Response>'; } else { $payload = '<' . $this->methodname . 'Response>' . $return_val . 'methodname . 'Response>'; } @@ -4295,7 +4292,7 @@ private function serialize_return() } } else { $this->debug('do not have WSDL for serialization: assume rpc/encoded'); - $payload = 'methodname . 'Response xmlns:ns1="' . $this->methodURI . '">' . $return_val . 'methodname . "Response>"; + $payload = 'methodname . 'Response xmlns:ns1="' . $this->methodURI . '">' . $return_val . 'methodname . 'Response>'; } $this->result = 'successful'; if ($this->wsdl) { @@ -4312,7 +4309,7 @@ private function serialize_return() } else { $this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders); } - $this->debug("Leaving serialize_return"); + $this->debug('Leaving serialize_return'); } /** @@ -4330,8 +4327,8 @@ private function send_response() $this->debug('Enter send_response'); if ($this->fault) { $payload = $this->fault->serialize(); - $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error"; - $this->outgoing_headers[] = "Status: 500 Internal Server Error"; + $this->outgoing_headers[] = 'HTTP/1.0 500 Internal Server Error'; + $this->outgoing_headers[] = 'Status: 500 Internal Server Error'; } else { $payload = $this->responseSOAP; // Some combinations of PHP+Web server allow the Status @@ -4346,7 +4343,7 @@ private function send_response() } $this->outgoing_headers[] = "Server: $this->title Server v$this->version"; preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); - $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (" . $rev[1] . ")"; + $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (" . $rev[1] . ')'; // Let the Web server decide about this //$this->outgoing_headers[] = "Connection: Close\r\n"; $payload = $this->getHTTPBody($payload); @@ -4360,13 +4357,13 @@ private function send_response() if (strstr($this->headers['accept-encoding'], 'gzip')) { if (function_exists('gzencode')) { if (isset($this->debug_flag) && $this->debug_flag) { - $payload .= ""; + $payload .= ''; } - $this->outgoing_headers[] = "Content-Encoding: gzip"; + $this->outgoing_headers[] = 'Content-Encoding: gzip'; $payload = gzencode($payload); } else { if (isset($this->debug_flag) && $this->debug_flag) { - $payload .= ""; + $payload .= ''; } } } elseif (strstr($this->headers['accept-encoding'], 'deflate')) { @@ -4375,19 +4372,19 @@ private function send_response() // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5) if (function_exists('gzdeflate')) { if (isset($this->debug_flag) && $this->debug_flag) { - $payload .= ""; + $payload .= ''; } - $this->outgoing_headers[] = "Content-Encoding: deflate"; + $this->outgoing_headers[] = 'Content-Encoding: deflate'; $payload = gzdeflate($payload); } else { if (isset($this->debug_flag) && $this->debug_flag) { - $payload .= ""; + $payload .= ''; } } } } //end code - $this->outgoing_headers[] = "Content-Length: " . strlen($payload); + $this->outgoing_headers[] = 'Content-Length: ' . strlen($payload); reset($this->outgoing_headers); foreach ($this->outgoing_headers as $hdr) { header($hdr, false); @@ -4438,7 +4435,7 @@ private function parseRequest($headers, $data) return false; } if (strpos($headers['content-type'], '=')) { - $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); + $enc = str_replace('"', '', substr(strstr($headers['content-type'], '='), 1)); $this->debug('Got response encoding: ' . $enc); if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { $this->xml_encoding = strtoupper($enc); @@ -4570,7 +4567,7 @@ public function register($name, $in = [], $out = [], $namespace = false, $soapac $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME']; $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'; } else { - $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available"); + $this->setError('Neither _SERVER nor HTTP_SERVER_VARS is available'); } if ($HTTPS == '1' || $HTTPS == 'on') { $SCHEME = 'https'; @@ -4580,10 +4577,10 @@ public function register($name, $in = [], $out = [], $namespace = false, $soapac $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name"; } if (false == $style) { - $style = "rpc"; + $style = 'rpc'; } if (false == $use) { - $use = "encoded"; + $use = 'encoded'; } if ($use == 'encoded' && $encodingStyle == '') { $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; @@ -4648,10 +4645,10 @@ public function configureWSDL($serviceName, $namespace = false, $endpoint = fals $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME']; $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'; } else { - $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available"); + $this->setError('Neither _SERVER nor HTTP_SERVER_VARS is available'); } // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI) - $colon = strpos($SERVER_NAME, ":"); + $colon = strpos($SERVER_NAME, ':'); if ($colon) { $SERVER_NAME = substr($SERVER_NAME, 0, $colon); } @@ -4809,7 +4806,7 @@ public function fetchWSDL($wsdl) $this->debug("parse and process WSDL path=$wsdl"); $this->wsdl = $wsdl; // parse wsdl file - if ($this->wsdl != "") { + if ($this->wsdl != '') { $this->parseWSDL($this->wsdl); } // imports @@ -4839,7 +4836,7 @@ public function fetchWSDL($wsdl) $imported_urls[] = $url; } } else { - $this->debug("Unexpected scenario: empty URL for unloaded import"); + $this->debug('Unexpected scenario: empty URL for unloaded import'); } } } @@ -4865,7 +4862,7 @@ public function fetchWSDL($wsdl) $imported_urls[] = $url; } } else { - $this->debug("Unexpected scenario: empty URL for unloaded import"); + $this->debug('Unexpected scenario: empty URL for unloaded import'); } } } @@ -4947,7 +4944,7 @@ private function parseWSDL($wsdl = '') return false; } unset($tr); - $this->debug("got WSDL URL"); + $this->debug('got WSDL URL'); } else { // $wsdl is not http(s), so treat it as a file URL or plain file path if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) { @@ -5084,11 +5081,11 @@ private function start_element($parser, $name, $attrs) case 'message': if ($name == 'part') { if (isset($attrs['type'])) { - $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs)); + $this->debug('msg ' . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs)); $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; } if (isset($attrs['element'])) { - $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs)); + $this->debug('msg ' . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs)); $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^'; } } @@ -5199,7 +5196,7 @@ private function start_element($parser, $name, $attrs) $this->portTypes[$attrs['name']] = []; $this->currentPortType = $attrs['name']; break; - case "binding": + case 'binding': if (isset($attrs['name'])) { // get binding name if (strpos($attrs['name'], ':')) { @@ -5239,7 +5236,7 @@ private function end_element($parser, $name) if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name) ) { - $this->status = ""; + $this->status = ''; $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema; @@ -5493,7 +5490,7 @@ private function webDescription() } elseif (isset($HTTP_SERVER_VARS)) { $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; } else { - $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available"); + $this->setError('Neither _SERVER nor HTTP_SERVER_VARS is available'); } $b = ' @@ -5628,10 +5625,10 @@ public function serialize($debug = 0) } // 10.9.02 - add poulter fix for wsdl and tns declarations if (isset($this->namespaces['wsdl'])) { - $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\""; + $xml .= ' xmlns="' . $this->namespaces['wsdl'] . '"'; } if (isset($this->namespaces['tns'])) { - $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\""; + $xml .= ' targetNamespace="' . $this->namespaces['tns'] . '"'; } $xml .= '>'; // imports @@ -5785,7 +5782,7 @@ private function parametersMatchWrapped($type, &$parameters) $this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type."); return false; } - $this->debug("in parametersMatchWrapped: found typeDef="); + $this->debug('in parametersMatchWrapped: found typeDef='); $this->appendDebug($this->varDump($typeDef)); if (substr($uqType, -1) == '^') { $uqType = substr($uqType, 0, -1); @@ -5796,7 +5793,7 @@ private function parametersMatchWrapped($type, &$parameters) // we expect a complexType or element of complexType if ($phpType != 'struct') { - $this->debug("in parametersMatchWrapped: not a struct"); + $this->debug('in parametersMatchWrapped: not a struct'); return false; } @@ -6024,8 +6021,8 @@ public function serializeParameters($operation, $direction, $parameters) */ private function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle = false, $unqualified = false) { - $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified")); - $this->appendDebug("value=" . $this->varDump($value)); + $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? 'unqualified' : 'qualified')); + $this->appendDebug('value=' . $this->varDump($value)); if ($use == 'encoded' && $encodingStyle) { $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"'; } @@ -6042,7 +6039,7 @@ private function serializeType($name, $type, $value, $use = 'encoded', $encoding $this->debug("in serializeType: soapval overrides type to $type"); } else { $forceType = false; - $this->debug("in serializeType: soapval does not override type"); + $this->debug('in serializeType: soapval does not override type'); } $attrs = $value->attributes; $value = $value->value; @@ -6054,7 +6051,7 @@ private function serializeType($name, $type, $value, $use = 'encoded', $encoding foreach ($attrs as $n => $v) { $value['!' . $n] = $v; } - $this->debug("in serializeType: soapval provides attributes"); + $this->debug('in serializeType: soapval provides attributes'); } } else { $forceType = false; @@ -6073,7 +6070,7 @@ private function serializeType($name, $type, $value, $use = 'encoded', $encoding if ($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/') { $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type'); if ($unqualified && $use == 'literal') { - $elementNS = " xmlns=\"\""; + $elementNS = ' xmlns=""'; } else { $elementNS = ''; } @@ -6103,7 +6100,7 @@ private function serializeType($name, $type, $value, $use = 'encoded', $encoding $value = $this->expandEntities($value); } if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') { - $value = sprintf("%.0lf", $value); + $value = sprintf('%.0lf', $value); } // it's a scalar // TODO: what about null/nil values? @@ -6167,7 +6164,7 @@ private function serializeType($name, $type, $value, $use = 'encoded', $encoding $this->debug("in serializeType: $type ($uqType) is not a supported type."); return false; } else { - $this->debug("in serializeType: found typeDef"); + $this->debug('in serializeType: found typeDef'); $this->appendDebug('typeDef=' . $this->varDump($typeDef)); if (substr($uqType, -1) == '^') { $uqType = substr($uqType, 0, -1); @@ -6187,12 +6184,12 @@ private function serializeType($name, $type, $value, $use = 'encoded', $encoding if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) { $elementNS = " xmlns=\"$ns\""; } else { - $elementNS = " xmlns=\"\""; + $elementNS = ' xmlns=""'; } } else { $elementName = $name; if ($unqualified) { - $elementNS = " xmlns=\"\""; + $elementNS = ' xmlns=""'; } else { $elementNS = ''; } @@ -6235,8 +6232,8 @@ private function serializeType($name, $type, $value, $use = 'encoded', $encoding } $xml .= ""; } else { - $this->debug("in serializeType: phpType is struct, but value is not an array"); - $this->setError("phpType is struct, but value is not an array: see debug output for details"); + $this->debug('in serializeType: phpType is struct, but value is not an array'); + $this->setError('phpType is struct, but value is not an array: see debug output for details'); $xml = ''; } } elseif ($phpType == 'array') { @@ -6244,7 +6241,7 @@ private function serializeType($name, $type, $value, $use = 'encoded', $encoding $elementNS = " xmlns=\"$ns\""; } else { if ($unqualified) { - $elementNS = " xmlns=\"\""; + $elementNS = ' xmlns=""'; } else { $elementNS = ''; } @@ -6255,13 +6252,12 @@ private function serializeType($name, $type, $value, $use = 'encoded', $encoding $xml = "<$name$elementNS/>"; } else { $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . - $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') . - ":Array\" " . + $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') . ':Array" ' . $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') . ':arrayType="' . $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) . ':' . - $this->getLocalPart($typeDef['arrayType']) . "[0]\"/>"; + $this->getLocalPart($typeDef['arrayType']) . '[0]"/>'; } $this->debug("in serializeType: returning: $xml"); return $xml; @@ -6280,7 +6276,7 @@ private function serializeType($name, $type, $value, $use = 'encoded', $encoding $rows = sizeof($value); $contents = ''; foreach ($value as $k => $v) { - $this->debug("serializing array element: $k, " . (is_array($v) ? "array" : $v) . " of type: $typeDef[arrayType]"); + $this->debug("serializing array element: $k, " . (is_array($v) ? 'array' : $v) . " of type: $typeDef[arrayType]"); //if (strpos($typeDef['arrayType'], ':') ) { if (!in_array($typeDef['arrayType'], $this->typemap['http://www.w3.org/2001/XMLSchema'])) { $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use); @@ -6303,7 +6299,7 @@ private function serializeType($name, $type, $value, $use = 'encoded', $encoding $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') . ':arrayType="' . $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) - . ":" . $this->getLocalPart($typeDef['arrayType']) . "[$rows$cols]\">" + . ':' . $this->getLocalPart($typeDef['arrayType']) . "[$rows$cols]\">" . $contents . ""; } @@ -6312,7 +6308,7 @@ private function serializeType($name, $type, $value, $use = 'encoded', $encoding $elementNS = " xmlns=\"$ns\""; } else { if ($unqualified) { - $elementNS = " xmlns=\"\""; + $elementNS = ' xmlns=""'; } else { $elementNS = ''; } @@ -6384,7 +6380,7 @@ private function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) $this->debug("no value provided for attribute $aName"); } if ($xname) { - $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\""; + $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . '"'; } } } else { @@ -6652,7 +6648,7 @@ public function addOperation($name, $in = false, $out = false, $namespace = fals if ($in) { foreach ($in as $pName => $pType) { if (strpos($pType, ':')) { - $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)) . ":" . $this->getLocalPart($pType); + $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)) . ':' . $this->getLocalPart($pType); } $this->messages[$name . 'Request'][$pName] = $pType; } @@ -6662,7 +6658,7 @@ public function addOperation($name, $in = false, $out = false, $namespace = fals if ($out) { foreach ($out as $pName => $pType) { if (strpos($pType, ':')) { - $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)) . ":" . $this->getLocalPart($pType); + $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)) . ':' . $this->getLocalPart($pType); } $this->messages[$name . 'Response'][$pName] = $pType; } @@ -6968,10 +6964,10 @@ private function start_element($parser, $name, $attrs) } if ($this->status == 'header') { if ($this->root_header != $pos) { - $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; + $this->responseHeaders .= '<' . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; } } elseif ($this->root_struct_name != '') { - $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; + $this->document .= '<' . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; } } @@ -7060,10 +7056,10 @@ private function end_element($parser, $name) // for doclit if ($this->status == 'header') { if ($this->root_header != $pos) { - $this->responseHeaders .= ""; + $this->responseHeaders .= '"; } } elseif ($pos >= $this->root_struct) { - $this->document .= ""; + $this->document .= '"; } // switch status if ($pos == $this->root_struct) { @@ -7243,7 +7239,7 @@ private function buildVal($pos) } elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { $this->debug('in buildVal, Java Map ' . $this->message[$pos]['name']); foreach ($children as $child_pos) { - $kv = explode("|", $this->message[$child_pos]['children']); + $kv = explode('|', $this->message[$child_pos]['children']); $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; } // generic compound type @@ -7507,7 +7503,7 @@ public function call($operation, $params = [], $namespace = 'http://tempuri.org' if ($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)) { // use WSDL for operation $this->opData = $opData; - $this->debug("found operation"); + $this->debug('found operation'); $this->appendDebug('opData=' . $this->varDump($opData)); if (isset($opData['soapAction'])) { $soapAction = $opData['soapAction']; @@ -7587,7 +7583,7 @@ public function call($operation, $params = [], $namespace = 'http://tempuri.org' // wrap RPC calls with method element if ($style == 'rpc') { if ($use == 'literal') { - $this->debug("wrapping RPC request with literal method element"); + $this->debug('wrapping RPC request with literal method element'); if ($namespace) { // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . @@ -7597,7 +7593,7 @@ public function call($operation, $params = [], $namespace = 'http://tempuri.org' $payload = "<$operation>" . $payload . ""; } } else { - $this->debug("wrapping RPC request with encoded method element"); + $this->debug('wrapping RPC request with encoded method element'); if ($namespace) { $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . $payload . @@ -7656,7 +7652,7 @@ public function call($operation, $params = [], $namespace = 'http://tempuri.org' return $return; // nothing returned (ie, echoVoid) } else { - return ""; + return ''; } } } @@ -7839,7 +7835,7 @@ private function parseResponse($headers, $data) return false; } if (strpos($headers['content-type'], '=')) { - $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); + $enc = str_replace('"', '', substr(strstr($headers['content-type'], '='), 1)); $this->debug('Got response encoding: ' . $enc); if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { $this->xml_encoding = strtoupper($enc); @@ -7910,7 +7906,7 @@ public function setEndpoint($endpoint) */ public function setHeaders($headers) { - $this->debug("setHeaders headers="); + $this->debug('setHeaders headers='); $this->appendDebug($this->varDump($headers)); $this->requestHeaders = $headers; } @@ -8004,7 +8000,7 @@ public function setUseCURL($use) */ public function useHTTPPersistentConnection() { - $this->debug("useHTTPPersistentConnection"); + $this->debug('useHTTPPersistentConnection'); $this->persistentConnection = true; } @@ -8053,7 +8049,7 @@ public function getProxy() $evalStr = $this->_getProxyClassCode($r); //$this->debug("proxy class: $evalStr"); if ($this->getError()) { - $this->debug("Error from _getProxyClassCode, so return null"); + $this->debug('Error from _getProxyClassCode, so return null'); return null; } // eval the class @@ -8099,7 +8095,7 @@ public function getProxy() private function _getProxyClassCode($r) { $this->debug("in getProxy endpointType=$this->endpointType"); - $this->appendDebug("wsdl=" . $this->varDump($this->wsdl)); + $this->appendDebug('wsdl=' . $this->varDump($this->wsdl)); if ($this->endpointType != 'wsdl') { $evalStr = 'A proxy can only be created for a WSDL client'; $this->setError($evalStr); @@ -8109,7 +8105,7 @@ private function _getProxyClassCode($r) if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) { $this->loadWSDL(); if ($this->getError()) { - return "echo \"" . $this->getError() . "\";"; + return 'echo "' . $this->getError() . '";'; } } $evalStr = ''; From 98d3071943ae49536d9da71382565bb50ab02fd4 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 10 Jun 2018 20:02:08 -0400 Subject: [PATCH 08/40] Yoda conditions style --- src/nusoap.php | 604 +++++++++++++++++++++++++------------------------ 1 file changed, 303 insertions(+), 301 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index e4402c3..e1f9d3b 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -376,7 +376,7 @@ private function expandEntities($val) */ public function getError() { - if ($this->error_str != '') { + if ('' != $this->error_str) { return $this->error_str; } return false; @@ -432,7 +432,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal $this->appendDebug('value=' . $this->varDump($val)); $this->appendDebug('attributes=' . $this->varDump($attributes)); - if (is_object($val) && get_class($val) == 'soapval' && (!$soapval)) { + if (is_object($val) && 'soapval' == get_class($val) && (!$soapval)) { $this->debug('serialize_val: serialize soapval'); $xml = $val->serialize($use); $this->appendDebug($val->getDebug()); @@ -454,7 +454,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal $xmlns .= " xmlns:$prefix=\"$name_ns\""; } // if type is prefixed, create type prefix - if ($type_ns != '' && $type_ns == $this->namespaces['xsd']) { + if ('' != $type_ns && $type_ns == $this->namespaces['xsd']) { // need to fix this. shouldn't default to xsd if no ns specified // w/o checking against typemap $type_prefix = 'xsd'; @@ -472,7 +472,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal // serialize null value if (is_null($val)) { $this->debug('serialize_val: serialize null'); - if ($use == 'literal') { + if ('literal' == $use) { // TODO: depends on minOccurs $xml = "<$name$xmlns$atts/>"; $this->debug("serialize_val returning $xml"); @@ -489,10 +489,10 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } } // serialize if an xsd built-in primitive type - if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) { + if ('' != $type && isset($this->typemap[$this->XMLSchemaVersion][$type])) { $this->debug('serialize_val: serialize xsd built-in primitive type'); if (is_bool($val)) { - if ($type == 'boolean') { + if ('boolean' == $type) { $val = $val ? 'true' : 'false'; } elseif (!$val) { $val = 0; @@ -500,7 +500,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } elseif (is_string($val)) { $val = $this->expandEntities($val); } - if ($use == 'literal') { + if ('literal' == $use) { $xml = "<$name$xmlns$atts>$val"; $this->debug("serialize_val returning $xml"); return $xml; @@ -513,39 +513,39 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal // detect type and serialize $xml = ''; switch (true) { - case (is_bool($val) || $type == 'boolean'): + case (is_bool($val) || 'boolean' == $type): $this->debug('serialize_val: serialize boolean'); - if ($type == 'boolean') { + if ('boolean' == $type) { $val = $val ? 'true' : 'false'; } elseif (!$val) { $val = 0; } - if ($use == 'literal') { + if ('literal' == $use) { $xml .= "<$name$xmlns$atts>$val"; } else { $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val"; } break; - case (is_int($val) || is_long($val) || $type == 'int'): + case (is_int($val) || is_long($val) || 'int' == $type): $this->debug('serialize_val: serialize int'); - if ($use == 'literal') { + if ('literal' == $use) { $xml .= "<$name$xmlns$atts>$val"; } else { $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val"; } break; - case (is_float($val) || is_double($val) || $type == 'float'): + case (is_float($val) || is_double($val) || 'float' == $type): $this->debug('serialize_val: serialize float'); - if ($use == 'literal') { + if ('literal' == $use) { $xml .= "<$name$xmlns$atts>$val"; } else { $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val"; } break; - case (is_string($val) || $type == 'string'): + case (is_string($val) || 'string' == $type): $this->debug('serialize_val: serialize string'); $val = $this->expandEntities($val); - if ($use == 'literal') { + if ('literal' == $use) { $xml .= "<$name$xmlns$atts>$val"; } else { $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val"; @@ -553,7 +553,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal break; case is_object($val): $this->debug('serialize_val: serialize object'); - if (get_class($val) == 'soapval') { + if ('soapval' == get_class($val)) { $this->debug('serialize_val: serialize soapval object'); $pXml = $val->serialize($use); $this->appendDebug($val->getDebug()); @@ -574,7 +574,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } else { $type_str = ''; } - if ($use == 'literal') { + if ('literal' == $use) { $xml .= "<$name$xmlns$atts>$pXml"; } else { $xml .= "<$name$xmlns$type_str$atts>$pXml"; @@ -584,12 +584,12 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal case (is_array($val) || $type): // detect if struct or array $valueType = $this->isArraySimpleOrStruct($val); - if ($valueType == 'arraySimple' || preg_match('/^ArrayOf/', $type)) { + if ('arraySimple' == $valueType || preg_match('/^ArrayOf/', $type)) { $this->debug('serialize_val: serialize array'); $i = 0; if (is_array($val) && count($val) > 0) { foreach ($val as $v) { - if (is_object($v) && get_class($v) == 'soapval') { + if (is_object($v) && 'soapval' == get_class($v)) { $tt_ns = $v->type_ns; $tt = $v->type; } elseif (is_array($v)) { @@ -605,17 +605,17 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal if (count($array_types) > 1) { $array_typename = 'xsd:anyType'; } elseif (isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) { - if ($tt == 'integer') { + if ('integer' == $tt) { $tt = 'int'; } $array_typename = 'xsd:' . $tt; - } elseif (isset($tt) && $tt == 'arraySimple') { + } elseif (isset($tt) && 'arraySimple' == $tt) { $array_typename = 'SOAP-ENC:Array'; - } elseif (isset($tt) && $tt == 'arrayStruct') { + } elseif (isset($tt) && 'arrayStruct' == $tt) { $array_typename = 'unnamed_struct_use_soapval'; } else { // if type is prefixed, create type prefix - if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']) { + if ('' != $tt_ns && $tt_ns == $this->namespaces['xsd']) { $array_typename = 'xsd:' . $tt; } elseif ($tt_ns) { $tt_prefix = 'ns' . rand(1000, 9999); @@ -626,7 +626,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } } $array_type = $i; - if ($use == 'literal') { + if ('literal' == $use) { $type_str = ''; } elseif (isset($type) && isset($type_prefix)) { $type_str = " xsi:type=\"$type_prefix:$type\""; @@ -635,7 +635,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } // empty array } else { - if ($use == 'literal') { + if ('literal' == $use) { $type_str = ''; } elseif (isset($type) && isset($type_prefix)) { $type_str = " xsi:type=\"$type_prefix:$type\""; @@ -653,14 +653,14 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } else { $type_str = ''; } - if ($use == 'literal') { + if ('literal' == $use) { $xml .= "<$name$xmlns$atts>"; } else { $xml .= "<$name$xmlns$type_str$atts>"; } foreach ($val as $k => $v) { // Apache Map - if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') { + if ('Map' == $type && 'http://xml.apache.org/xml-soap' == $type_ns) { $xml .= ''; $xml .= $this->serialize_val($k, 'key', false, false, false, false, $use); $xml .= $this->serialize_val($v, 'value', false, false, false, false, $use); @@ -719,7 +719,7 @@ public function serializeEnvelope($body, $headers = false, $namespaces = [], $st if (is_array($headers)) { $xml = ''; foreach ($headers as $k => $v) { - if (is_object($v) && get_class($v) == 'soapval') { + if (is_object($v) && 'soapval' == get_class($v)) { $xml .= $this->serialize_val($v, false, false, false, false, false, $use); } else { $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); @@ -936,10 +936,10 @@ function timestamp_to_iso8601($timestamp, $utc = true) { $datestr = date('Y-m-d\TH:i:sO', $timestamp); $pos = strrpos($datestr, '+'); - if ($pos === false) { + if (false === $pos) { $pos = strrpos($datestr, '-'); } - if ($pos !== false) { + if (false !== $pos) { if (strlen($datestr) == $pos + 5) { $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2); } @@ -986,14 +986,14 @@ function iso8601_to_timestamp($datestr) '/'; if (preg_match($pattern, $datestr, $regs)) { // not utc - if ($regs[8] != 'Z') { + if ('Z' != $regs[8]) { $op = substr($regs[8], 0, 1); $h = substr($regs[8], 1, 2); $m = substr($regs[8], strlen($regs[8]) - 2, 2); - if ($op == '-') { + if ('-' == $op) { $regs[4] = $regs[4] + $h; $regs[5] = $regs[5] + $m; - } elseif ($op == '+') { + } elseif ('+' == $op) { $regs[4] = $regs[4] - $h; $regs[5] = $regs[5] - $m; } @@ -1180,13 +1180,13 @@ public function __construct($schema = '', $xml = '', $namespaces = []) $this->namespaces = array_merge($this->namespaces, $namespaces); // parse schema file - if ($schema != '') { + if ('' != $schema) { $this->debug('initial schema file: ' . $schema); $this->parseFile($schema, 'schema'); } // parse xml file - if ($xml != '') { + if ('' != $xml) { $this->debug('initial xml file: ' . $xml); $this->parseFile($xml, 'xml'); } @@ -1203,9 +1203,9 @@ public function __construct($schema = '', $xml = '', $namespaces = []) public function parseFile($xml, $type) { // parse xml file - if ($xml != '') { + if ('' != $xml) { $xmlStr = @join('', @file($xml)); - if ($xmlStr == '') { + if ('' == $xmlStr) { $msg = 'Error reading XML from ' . $xml; $this->setError($msg); $this->debug($msg); @@ -1230,7 +1230,7 @@ public function parseFile($xml, $type) private function parseString($xml, $type) { // parse xml string - if ($xml != '') { + if ('' != $xml) { // Create an XML parser. $this->parser = xml_parser_create(); @@ -1241,10 +1241,10 @@ private function parseString($xml, $type) xml_set_object($this->parser, $this); // Set the element handlers for the parser. - if ($type == 'schema') { + if ('schema' == $type) { xml_set_element_handler($this->parser, 'schemaStartElement', 'schemaEndElement'); xml_set_character_data_handler($this->parser, 'schemaCharacterData'); - } elseif ($type == 'xml') { + } elseif ('xml' == $type) { xml_set_element_handler($this->parser, 'xmlStartElement', 'xmlEndElement'); xml_set_character_data_handler($this->parser, 'xmlCharacterData'); } @@ -1333,7 +1333,7 @@ private function schemaStartElement($parser, $name, $attrs) $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v; } } - if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') { + if ('http://www.w3.org/2001/XMLSchema' == $v || 'http://www.w3.org/1999/XMLSchema' == $v || 'http://www.w3.org/2000/10/XMLSchema' == $v) { $this->XMLSchemaVersion = $v; $this->namespaces['xsi'] = $v . '-instance'; } @@ -1382,7 +1382,7 @@ private function schemaStartElement($parser, $name, $attrs) if (isset($attrs['name'])) { $this->attributes[$attrs['name']] = $attrs; $aname = $attrs['name']; - } elseif (isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType') { + } elseif (isset($attrs['ref']) && 'http://schemas.xmlsoap.org/soap/encoding/:arrayType' == $attrs['ref']) { if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; } else { @@ -1397,7 +1397,7 @@ private function schemaStartElement($parser, $name, $attrs) $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; } // arrayType attribute - if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType') { + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || 'arrayType' == $this->getLocalPart($aname)) { $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; $prefix = $this->getPrefix($aname); if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { @@ -1489,7 +1489,7 @@ private function schemaStartElement($parser, $name, $attrs) // minOccurs="0" maxOccurs="unbounded" /> // // - if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') { + if ($this->currentComplexType && 'array' == $this->complexTypes[$this->currentComplexType]['phpType']) { $this->xdebug('arrayType for unusual array is ' . $attrs['type']); $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type']; } @@ -1527,7 +1527,7 @@ private function schemaStartElement($parser, $name, $attrs) $this->xdebug('extension ' . $attrs['base']); if ($this->currentComplexType) { $ns = $this->getPrefix($attrs['base']); - if ($ns == '') { + if ('' == $ns) { $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base']; } else { $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base']; @@ -1565,7 +1565,7 @@ private function schemaStartElement($parser, $name, $attrs) $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base']; } elseif ($this->currentComplexType) { $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; - if (strstr($attrs['base'], ':') == ':Array') { + if (':Array' == strstr($attrs['base'], ':')) { $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; } } @@ -1638,17 +1638,17 @@ private function schemaEndElement($parser, $name) $prefix = ''; } // move on... - if ($name == 'complexType') { + if ('complexType' == $name) { $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)')); $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType])); $this->currentComplexType = array_pop($this->complexTypeStack); //$this->currentElement = false; } - if ($name == 'element') { + if ('element' == $name) { $this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)')); $this->currentElement = array_pop($this->elementStack); } - if ($name == 'simpleType') { + if ('simpleType' == $name) { $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)')); $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType])); $this->currentSimpleType = array_pop($this->simpleTypeStack); @@ -1681,7 +1681,7 @@ public function serializeSchema() if (sizeof($this->imports) > 0) { foreach ($this->imports as $ns => $list) { foreach ($list as $ii) { - if ($ii['location'] != '') { + if ('' != $ii['location']) { $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; } else { $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; @@ -1701,7 +1701,7 @@ public function serializeSchema() $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . '"'; foreach ($eParts as $aName => $aValue) { // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable - if ($aName != 'name' && $aName != 'type') { + if ('name' != $aName && 'type' != $aName) { $contentStr .= " $aName=\"$aValue\""; } } @@ -1709,7 +1709,7 @@ public function serializeSchema() } } // compositor wraps elements - if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) { + if (isset($attrs['compositor']) && ('' != $attrs['compositor'])) { $contentStr = " <$schemaPrefix:$attrs[compositor]>\n" . $contentStr . " \n"; } } @@ -1718,9 +1718,9 @@ public function serializeSchema() foreach ($attrs['attrs'] as $attr => $aParts) { $contentStr .= " <$schemaPrefix:attribute"; foreach ($aParts as $a => $v) { - if ($a == 'ref' || $a == 'type') { + if ('ref' == $a || 'type' == $a) { $contentStr .= " $a=\"" . $this->contractQName($v) . '"'; - } elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') { + } elseif ('http://schemas.xmlsoap.org/wsdl/:arrayType' == $a) { $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl']; $contentStr .= ' wsdl:arrayType="' . $this->contractQName($v) . '"'; } else { @@ -1731,7 +1731,7 @@ public function serializeSchema() } } // if restriction - if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != '') { + if (isset($attrs['restrictionBase']) && '' != $attrs['restrictionBase']) { $contentStr = " <$schemaPrefix:restriction base=\"" . $this->contractQName($attrs['restrictionBase']) . "\">\n" . $contentStr . " \n"; // complex or simple content if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)) { @@ -1739,7 +1739,7 @@ public function serializeSchema() } } // finalize complex type - if ($contentStr != '') { + if ('' != $contentStr) { $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n" . $contentStr . " \n"; } else { $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; @@ -1773,7 +1773,7 @@ public function serializeSchema() // finish 'er up $attr = ''; foreach ($this->schemaInfo as $k => $v) { - if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') { + if ('elementFormDefault' == $k || 'attributeFormDefault' == $k) { $attr .= " $k=\"$v\""; } } @@ -1845,7 +1845,7 @@ public function getPHPType($type, $ns) public function getTypeDef($type) { //$this->debug("in getTypeDef for type $type"); - if (substr($type, -1) == '^') { + if ('^' == substr($type, -1)) { $is_element = 1; $type = substr($type, 0, -1); } else { @@ -1894,7 +1894,7 @@ public function getTypeDef($type) if (isset($etype['extensionBase'])) { $this->elements[$type]['extensionBase'] = $etype['extensionBase']; } - } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') { + } elseif ('http://www.w3.org/2001/XMLSchema' == $ns) { $this->xdebug("in getTypeDef, element $type is an XSD type"); $this->elements[$type]['phpType'] = 'scalar'; } @@ -1939,7 +1939,7 @@ public function serializeTypeDef($type) $str .= $this->serializeTypeDef($element); } $str .= ""; - } elseif ($typeDef['typeClass'] == 'element') { + } elseif ('element' == $typeDef['typeClass']) { $str .= ">"; } else { $str .= '/>'; @@ -1964,7 +1964,7 @@ public function typeToForm($name, $type) // get typedef if ($typeDef = $this->getTypeDef($type)) { // if struct - if ($typeDef['phpType'] == 'struct') { + if ('struct' == $typeDef['phpType']) { $buffer .= ''; foreach ($typeDef['elements'] as $child => $childDef) { $buffer .= " @@ -1973,7 +1973,7 @@ public function typeToForm($name, $type) } $buffer .= '
'; // if array - } elseif ($typeDef['phpType'] == 'array') { + } elseif ('array' == $typeDef['phpType']) { $buffer .= ''; for ($i = 0; $i < 3; $i++) { $buffer .= " @@ -2332,13 +2332,13 @@ private function setURL($url) } // add any GET params to path - if (isset($u['query']) && $u['query'] != '') { + if (isset($u['query']) && '' != $u['query']) { $this->path .= '?' . $u['query']; } // set default port if (!isset($u['port'])) { - if ($u['scheme'] == 'https') { + if ('https' == $u['scheme']) { $this->port = 443; } else { $this->port = 80; @@ -2355,7 +2355,7 @@ private function setURL($url) $this->setHeader('Host', $this->host . ':' . $this->port); } - if (isset($u['user']) && $u['user'] != '') { + if (isset($u['user']) && '' != $u['user']) { $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : ''); } } @@ -2368,10 +2368,10 @@ private function setURL($url) */ private function io_method() { - if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) { + if ($this->use_curl || ('https' == $this->scheme) || ('http' == $this->scheme && 'ntlm' == $this->authtype) || ('http' == $this->scheme && is_array($this->proxy) && 'ntlm' == $this->proxy['authtype'])) { return 'curl'; } - if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) { + if (('http' == $this->scheme || 'ssl' == $this->scheme) && 'ntlm' != $this->authtype && (!is_array($this->proxy) || 'ntlm' != $this->proxy['authtype'])) { return 'socket'; } return 'unknown'; @@ -2400,7 +2400,7 @@ private function connect($connection_timeout = 0, $response_timeout = 30) // } // } $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port"); - if ($this->io_method() == 'socket') { + if ('socket' == $this->io_method()) { if (!is_array($this->proxy)) { $host = $this->host; $port = $this->port; @@ -2420,7 +2420,7 @@ private function connect($connection_timeout = 0, $response_timeout = 30) } // munge host if using OpenSSL - if ($this->scheme == 'ssl') { + if ('ssl' == $this->scheme) { $host = 'ssl://' . $host; } $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout); @@ -2451,7 +2451,7 @@ private function connect($connection_timeout = 0, $response_timeout = 30) $this->debug('socket connected'); return true; - } elseif ($this->io_method() == 'curl') { + } elseif ('curl' == $this->io_method()) { if (!extension_loaded('curl')) { // $this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS'); $this->setError('The PHP cURL Extension is required for HTTPS or NLTM. You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.'); @@ -2493,7 +2493,7 @@ private function connect($connection_timeout = 0, $response_timeout = 30) // init CURL $this->ch = curl_init(); // set url - $hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host"; + $hostURL = ('' != $this->port) ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host"; // add path $hostURL .= $this->path; $this->setCurlOption(CURLOPT_URL, $hostURL); @@ -2527,14 +2527,14 @@ private function connect($connection_timeout = 0, $response_timeout = 30) $this->setHeader('Connection', 'close'); } // set timeouts - if ($connection_timeout != 0) { + if (0 != $connection_timeout) { $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout); } - if ($response_timeout != 0) { + if (0 != $response_timeout) { $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout); } - if ($this->scheme == 'https') { + if ('https' == $this->scheme) { $this->debug('set cURL SSL verify options'); // recent versions of cURL turn on peer/host checking by default, // while PHP binaries are not compiled with a default location for the @@ -2544,7 +2544,7 @@ private function connect($connection_timeout = 0, $response_timeout = 30) $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0); // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo) - if ($this->authtype == 'certificate') { + if ('certificate' == $this->authtype) { $this->debug('set cURL certificate options'); if (isset($this->certRequest['cainfofile'])) { $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']); @@ -2573,27 +2573,27 @@ private function connect($connection_timeout = 0, $response_timeout = 30) } } } - if ($this->authtype && ($this->authtype != 'certificate')) { + if ($this->authtype && ('certificate' != $this->authtype)) { if ($this->username) { $this->debug('set cURL username/password'); $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password"); } - if ($this->authtype == 'basic') { + if ('basic' == $this->authtype) { $this->debug('set cURL for Basic authentication'); $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC); } - if ($this->authtype == 'digest') { + if ('digest' == $this->authtype) { $this->debug('set cURL for digest authentication'); $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST); } - if ($this->authtype == 'ntlm') { + if ('ntlm' == $this->authtype) { $this->debug('set cURL for NTLM authentication'); $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM); } } if (is_array($this->proxy)) { $this->debug('set cURL proxy options'); - if ($this->proxy['port'] != '') { + if ('' != $this->proxy['port']) { $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'] . ':' . $this->proxy['port']); } else { $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']); @@ -2601,10 +2601,10 @@ private function connect($connection_timeout = 0, $response_timeout = 30) if ($this->proxy['username'] || $this->proxy['password']) { $this->debug('set cURL proxy authentication options'); $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'] . ':' . $this->proxy['password']); - if ($this->proxy['authtype'] == 'basic') { + if ('basic' == $this->proxy['authtype']) { $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC); } - if ($this->proxy['authtype'] == 'ntlm') { + if ('ntlm' == $this->proxy['authtype']) { $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM); } } @@ -2691,9 +2691,9 @@ public function setCredentials($username, $password, $authtype = 'basic', $diges $this->debug('certRequest='); $this->appendDebug($this->varDump($certRequest)); // cf. RFC 2617 - if ($authtype == 'basic') { + if ('basic' == $authtype) { $this->setHeader('Authorization', 'Basic ' . base64_encode(str_replace(':', '', $username) . ':' . $password)); - } elseif ($authtype == 'digest') { + } elseif ('digest' == $authtype) { if (isset($digestRequest['nonce'])) { $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1; @@ -2725,7 +2725,7 @@ public function setCredentials($username, $password, $authtype = 'basic', $diges $unhashedDigest = ''; $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : ''; $cnonce = $nonce; - if ($digestRequest['qop'] != '') { + if ('' != $digestRequest['qop']) { $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf('%08d', $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2; } else { $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2; @@ -2740,10 +2740,10 @@ public function setCredentials($username, $password, $authtype = 'basic', $diges $this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf('%08x', $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"'); } - } elseif ($authtype == 'certificate') { + } elseif ('certificate' == $authtype) { $this->certRequest = $certRequest; $this->debug('Authorization header not set for certificate'); - } elseif ($authtype == 'ntlm') { + } elseif ('ntlm' == $authtype) { // do nothing $this->debug('Authorization header not set for ntlm'); } @@ -2805,7 +2805,7 @@ public function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypass 'password' => $proxypassword, 'authtype' => $proxyauthtype ]; - if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') { + if ('' != $proxyusername && '' != $proxypassword && $proxyauthtype = 'basic') { $this->setHeader('Proxy-Authorization', ' Basic ' . base64_encode($proxyusername . ':' . $proxypassword)); } } else { @@ -2865,7 +2865,7 @@ public function decodeChunked($buffer, $lb) // read chunk-size, chunk-extension (if any) and CRLF // get the position of the linebreak $chunkend = strpos($buffer, $lb); - if ($chunkend == false) { + if (false == $chunkend) { $this->debug('no linebreak found in decodeChunked'); return $new; } @@ -2878,7 +2878,7 @@ public function decodeChunked($buffer, $lb) $chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size); // Just in case we got a broken connection - if ($chunkend == false) { + if (false == $chunkend) { $chunk = substr($buffer, $chunkstart); // append chunk-data to entity-body $new .= $chunk; @@ -2896,7 +2896,7 @@ public function decodeChunked($buffer, $lb) $chunkstart = $chunkend + strlen($lb); $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb); - if ($chunkend == false) { + if (false == $chunkend) { break; //Just in case we got a broken connection } $temp = substr($buffer, $chunkstart, $chunkend - $chunkstart); @@ -2921,7 +2921,7 @@ private function buildPayload($data, $cookie_str = '') // debugging guides. // add content-length header - if ($this->request_method != 'GET') { + if ('GET' != $this->request_method) { $this->setHeader('Content-Length', strlen($data)); } @@ -2943,7 +2943,7 @@ private function buildPayload($data, $cookie_str = '') } // add any cookies - if ($cookie_str != '') { + if ('' != $cookie_str) { $hdr = 'Cookie: ' . $cookie_str; $this->debug("HTTP header: $hdr"); $this->outgoing_payload .= "$hdr\r\n"; @@ -2967,12 +2967,12 @@ private function buildPayload($data, $cookie_str = '') private function sendRequest($data, $cookies = null) { // build cookie string - $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https'))); + $cookie_str = $this->getCookiesForRequest($cookies, (('ssl' == $this->scheme) || ('https' == $this->scheme))); // build payload $this->buildPayload($data, $cookie_str); - if ($this->io_method() == 'socket') { + if ('socket' == $this->io_method()) { // send payload if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) { $this->setError('couldn\'t write message data to socket'); @@ -2981,7 +2981,7 @@ private function sendRequest($data, $cookies = null) } $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload)); return true; - } elseif ($this->io_method() == 'curl') { + } elseif ('curl' == $this->io_method()) { // set payload // cURL does say this should only be the verb, and in fact it // turns out that the URI and HTTP version are appended to this, which @@ -2989,18 +2989,18 @@ private function sendRequest($data, $cookies = null) //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload); $curl_headers = []; foreach ($this->outgoing_headers as $k => $v) { - if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') { + if ('Connection' == $k || 'Content-Length' == $k || 'Host' == $k || 'Authorization' == $k || 'Proxy-Authorization' == $k) { $this->debug("Skip cURL header $k: $v"); } else { $curl_headers[] = "$k: $v"; } } - if ($cookie_str != '') { + if ('' != $cookie_str) { $curl_headers[] = 'Cookie: ' . $cookie_str; } $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers); $this->debug('set cURL HTTP headers'); - if ($this->request_method == 'POST') { + if ('POST' == $this->request_method) { $this->setCurlOption(CURLOPT_POST, 1); $this->setCurlOption(CURLOPT_POSTFIELDS, $data); $this->debug('set cURL POST data'); @@ -3026,7 +3026,7 @@ private function getResponse() { $this->incoming_payload = ''; - if ($this->io_method() == 'socket') { + if ('socket' == $this->io_method()) { // loop until headers have been retrieved $data = ''; while (!isset($lb)) { @@ -3044,7 +3044,7 @@ private function getResponse() $tmplen = strlen($tmp); $this->debug("read line of $tmplen bytes: " . trim($tmp)); - if ($tmplen == 0) { + if (0 == $tmplen) { $this->incoming_payload = $data; $this->debug('socket read of headers timed out after length ' . strlen($data)); $this->debug('read before timeout: ' . $data); @@ -3081,7 +3081,7 @@ private function getResponse() if (count($arr) > 1) { $header_name = strtolower(trim($arr[0])); $this->incoming_headers[$header_name] = trim($arr[1]); - if ($header_name == 'set-cookie') { + if ('set-cookie' == $header_name) { // TODO: allow multiple cookies from parseCookie $cookie = $this->parseCookie(trim($arr[1])); if ($cookie) { @@ -3098,7 +3098,7 @@ private function getResponse() } // loop until msg has been received - if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') { + if (isset($this->incoming_headers['transfer-encoding']) && 'chunked' == strtolower($this->incoming_headers['transfer-encoding'])) { $content_length = 2147483647; // ignore any content-length header $chunked = true; $this->debug('want to read chunked content'); @@ -3117,7 +3117,7 @@ private function getResponse() $tmp = fgets($this->fp, 256); $tmplen = strlen($tmp); $this->debug("read chunk line of $tmplen bytes"); - if ($tmplen == 0) { + if (0 == $tmplen) { $this->incoming_payload = $data; $this->debug('socket read of chunk length timed out after length ' . strlen($data)); $this->debug("read before timeout:\n" . $data); @@ -3133,7 +3133,7 @@ private function getResponse() $tmp = fread($this->fp, $readlen); $tmplen = strlen($tmp); $this->debug("read buffer of $tmplen bytes"); - if (($tmplen == 0) && (!feof($this->fp))) { + if ((0 == $tmplen) && (!feof($this->fp))) { $this->incoming_payload = $data; $this->debug('socket read of body timed out after length ' . strlen($data)); $this->debug("read before timeout:\n" . $data); @@ -3147,7 +3147,7 @@ private function getResponse() $tmp = fgets($this->fp, 256); $tmplen = strlen($tmp); $this->debug("read chunk terminator of $tmplen bytes"); - if ($tmplen == 0) { + if (0 == $tmplen) { $this->incoming_payload = $data; $this->debug('socket read of chunk terminator timed out after length ' . strlen($data)); $this->debug("read before timeout:\n" . $data); @@ -3165,7 +3165,7 @@ private function getResponse() // close filepointer if ( - (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') || + (isset($this->incoming_headers['connection']) && 'close' == strtolower($this->incoming_headers['connection'])) || (!$this->persistentConnection) || feof($this->fp) ) { fclose($this->fp); @@ -3174,7 +3174,7 @@ private function getResponse() } // connection was closed unexpectedly - if ($this->incoming_payload == '') { + if ('' == $this->incoming_payload) { $this->setError('no response from server'); return false; } @@ -3189,14 +3189,14 @@ private function getResponse() // set decoded payload // $this->incoming_payload = $header_data.$lb.$lb.$data; // } - } elseif ($this->io_method() == 'curl') { + } elseif ('curl' == $this->io_method()) { // send and receive $this->debug('send and receive with cURL'); $this->incoming_payload = curl_exec($this->ch); $data = $this->incoming_payload; $cErr = curl_error($this->ch); - if ($cErr != '') { + if ('' != $cErr) { $err = 'cURL ERROR: ' . curl_errno($this->ch) . ': ' . $cErr . '
'; // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE foreach (curl_getinfo($this->ch) as $k => $v) { @@ -3226,7 +3226,7 @@ private function getResponse() } } - if ($data == '') { + if ('' == $data) { // have nothing left; just remove 100 header(s) $data = $savedata; while (preg_match('/^HTTP\/1.1 100/', $data)) { @@ -3259,7 +3259,7 @@ private function getResponse() if (count($arr) > 1) { $header_name = strtolower(trim($arr[0])); $this->incoming_headers[$header_name] = trim($arr[1]); - if ($header_name == 'set-cookie') { + if ('set-cookie' == $header_name) { // TODO: allow multiple cookies from parseCookie $cookie = $this->parseCookie(trim($arr[1])); if ($cookie) { @@ -3283,7 +3283,7 @@ private function getResponse() $http_reason = count($arr) > 2 ? $arr[2] : ''; // see if we need to resend the request with http digest authentication - if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) { + if (isset($this->incoming_headers['location']) && (301 == $http_status || 302 == $http_status)) { $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']); $this->setURL($this->incoming_headers['location']); $this->tryagain = true; @@ -3291,7 +3291,7 @@ private function getResponse() } // see if we need to resend the request with http digest authentication - if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) { + if (isset($this->incoming_headers['www-authenticate']) && 401 == $http_status) { $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']); if (strstr($this->incoming_headers['www-authenticate'], 'Digest ')) { $this->debug('Server wants digest authentication'); @@ -3327,8 +3327,8 @@ private function getResponse() } // decode content-encoding - if (isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != '') { - if (strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip') { + if (isset($this->incoming_headers['content-encoding']) && '' != $this->incoming_headers['content-encoding']) { + if ('deflate' == strtolower($this->incoming_headers['content-encoding']) || 'gzip' == strtolower($this->incoming_headers['content-encoding'])) { // if decoding works, use it. else assume data wasn't gzencoded if (function_exists('gzinflate')) { //$timer->setMarker('starting decoding of gzip/deflated content'); @@ -3336,7 +3336,7 @@ private function getResponse() // this means there are no Zlib headers, although there should be $this->debug('The gzinflate function exists'); $datalen = strlen($data); - if ($this->incoming_headers['content-encoding'] == 'deflate') { + if ('deflate' == $this->incoming_headers['content-encoding']) { if ($degzdata = @gzinflate($data)) { $data = $degzdata; $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes'); @@ -3352,7 +3352,7 @@ private function getResponse() $this->debug('Error using gzinflate to inflate the payload'); $this->setError('Error using gzinflate to inflate the payload'); } - } elseif ($this->incoming_headers['content-encoding'] == 'gzip') { + } elseif ('gzip' == $this->incoming_headers['content-encoding']) { if ($degzdata = @gzinflate(substr($data, 10))) { // do our best $data = $degzdata; $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes'); @@ -3385,7 +3385,7 @@ private function getResponse() $this->debug('No Content-Encoding header'); } - if (strlen($data) == 0) { + if (0 == strlen($data)) { $this->debug('no data after headers!'); $this->setError('no data present after HTTP headers'); return false; @@ -3467,7 +3467,7 @@ private function parseCookie($cookie_str) } $cookie_param = ';secure;'; - if (strpos($cookie_str, $cookie_param) !== false) { + if (false !== strpos($cookie_str, $cookie_param)) { $secure = true; } else { $secure = false; @@ -3756,7 +3756,7 @@ public function __construct($wsdl = false) } elseif (isset($_SERVER['QUERY_STRING'])) { $qs = explode('&', $_SERVER['QUERY_STRING']); foreach ($qs as $v) { - if (substr($v, 0, 6) == 'debug=') { + if ('debug=' == substr($v, 0, 6)) { $this->debug('In nusoap_server, set debug_flag=' . substr($v, 6) . ' based on query string #1'); $this->debug_flag = substr($v, 6); } @@ -3764,7 +3764,7 @@ public function __construct($wsdl = false) } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']); foreach ($qs as $v) { - if (substr($v, 0, 6) == 'debug=') { + if ('debug=' == substr($v, 0, 6)) { $this->debug('In nusoap_server, set debug_flag=' . substr($v, 6) . ' based on query string #2'); $this->debug_flag = substr($v, 6); } @@ -3774,7 +3774,7 @@ public function __construct($wsdl = false) // wsdl if ($wsdl) { $this->debug('In nusoap_server, WSDL is specified'); - if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) { + if (is_object($wsdl) && ('wsdl' == get_class($wsdl))) { $this->wsdl = $wsdl; $this->externalWSDLURL = $this->wsdl->wsdl; $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL); @@ -3818,7 +3818,7 @@ public function service($data) } $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data)); - if ($rm == 'POST') { + if ('POST' == $rm) { $this->debug('In service, invoke the request'); $this->parse_request($data); if (!$this->fault) { @@ -3831,14 +3831,14 @@ public function service($data) } elseif (preg_match('/wsdl/', $qs)) { $this->debug('In service, this is a request for WSDL'); if ($this->externalWSDLURL) { - if (strpos($this->externalWSDLURL, 'http://') !== false) { // assume URL + if (false !== strpos($this->externalWSDLURL, 'http://')) { // assume URL $this->debug('In service, re-direct for WSDL'); header('Location: ' . $this->externalWSDLURL); } else { // assume file $this->debug('In service, use file passthru for WSDL'); header("Content-Type: text/xml\r\n"); $pos = strpos($this->externalWSDLURL, 'file://'); - if ($pos === false) { + if (false === $pos) { $filename = $this->externalWSDLURL; } else { $filename = substr($this->externalWSDLURL, $pos + 7); @@ -3916,18 +3916,18 @@ private function parse_http_headers() } elseif (isset($_SERVER) && is_array($_SERVER)) { $this->debug('In parse_http_headers, use _SERVER'); foreach ($_SERVER as $k => $v) { - if (substr($k, 0, 5) == 'HTTP_') { + if ('HTTP_' == substr($k, 0, 5)) { $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); } else { $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); } - if ($k == 'soapaction') { + if ('soapaction' == $k) { // get SOAPAction header $k = 'SOAPAction'; $v = str_replace('"', '', $v); $v = str_replace('\\', '', $v); $this->SOAPAction = $v; - } elseif ($k == 'content-type') { + } elseif ('content-type' == $k) { // get the character encoding of the incoming request if (strpos($v, '=')) { $enc = substr(strstr($v, '='), 1); @@ -3950,20 +3950,20 @@ private function parse_http_headers() } elseif (is_array($HTTP_SERVER_VARS)) { $this->debug('In parse_http_headers, use HTTP_SERVER_VARS'); foreach ($HTTP_SERVER_VARS as $k => $v) { - if (substr($k, 0, 5) == 'HTTP_') { + if ('HTTP_' == substr($k, 0, 5)) { $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); $k = strtolower(substr($k, 5)); } else { $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); $k = strtolower($k); } - if ($k == 'soapaction') { + if ('soapaction' == $k) { // get SOAPAction header $k = 'SOAPAction'; $v = str_replace('"', '', $v); $v = str_replace('\\', '', $v); $this->SOAPAction = $v; - } elseif ($k == 'content-type') { + } elseif ('content-type' == $k) { // get the character encoding of the incoming request if (strpos($v, '=')) { $enc = substr(strstr($v, '='), 1); @@ -4017,14 +4017,14 @@ private function parse_request($data = '') $this->parse_http_headers(); $this->debug('got character encoding: ' . $this->xml_encoding); // uncompress if necessary - if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') { + if (isset($this->headers['content-encoding']) && '' != $this->headers['content-encoding']) { $this->debug('got content encoding: ' . $this->headers['content-encoding']); - if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') { + if ('deflate' == $this->headers['content-encoding'] || 'gzip' == $this->headers['content-encoding']) { // if decoding works, use it. else assume data wasn't gzencoded if (function_exists('gzuncompress')) { - if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) { + if ('deflate' == $this->headers['content-encoding'] && $degzdata = @gzuncompress($data)) { $data = $degzdata; - } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) { + } elseif ('gzip' == $this->headers['content-encoding'] && $degzdata = gzinflate(substr($data, 10))) { $data = $degzdata; } else { $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data'); @@ -4106,7 +4106,7 @@ private function invoke_method() $class = ''; $method = ''; - if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) { + if (strlen($delim) > 0 && 1 == substr_count($this->methodname, $delim)) { $try_class = substr($this->methodname, 0, strpos($this->methodname, $delim)); if (class_exists($try_class)) { // get the class and method name @@ -4126,7 +4126,7 @@ private function invoke_method() } // does method exist? - if ($class == '') { + if ('' == $class) { if (!function_exists($this->methodname)) { $this->debug("in invoke_method, function '$this->methodname' not found!"); $this->result = 'fault: method not found'; @@ -4134,7 +4134,7 @@ private function invoke_method() return; } } else { - $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method; + $method_to_compare = ('4.' == substr(phpversion(), 0, 2)) ? strtolower($method) : $method; if (!in_array($method_to_compare, get_class_methods($class))) { $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!"); $this->result = 'fault: method not found'; @@ -4159,11 +4159,11 @@ private function invoke_method() $this->appendDebug($this->varDump($this->methodparams)); $this->debug("in invoke_method, calling '$this->methodname'"); if (!function_exists('call_user_func_array')) { - if ($class == '') { + if ('' == $class) { $this->debug('in invoke_method, calling function using eval()'); $funcCall = "\$this->methodreturn = $this->methodname("; } else { - if ($delim == '..') { + if ('..' == $delim) { $this->debug('in invoke_method, calling class method using eval()'); $funcCall = '$this->methodreturn = ' . $class . '::' . $method . '('; } else { @@ -4188,10 +4188,10 @@ private function invoke_method() $this->debug('in invoke_method, function call: ' . $funcCall); @eval($funcCall); } else { - if ($class == '') { + if ('' == $class) { $this->debug('in invoke_method, calling function using call_user_func_array()'); $call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case after call_user_func_array() - } elseif ($delim == '..') { + } elseif ('..' == $delim) { $this->debug('in invoke_method, calling class method using call_user_func_array()'); $call_arg = [$class, $method]; } else { @@ -4225,7 +4225,7 @@ private function serialize_return() { $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI); // if fault - if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) { + if (isset($this->methodreturn) && is_object($this->methodreturn) && (('soap_fault' == get_class($this->methodreturn)) || ('nusoap_fault' == get_class($this->methodreturn)))) { $this->debug('got a fault object from method'); $this->fault = $this->methodreturn; return; @@ -4239,7 +4239,7 @@ private function serialize_return() if (sizeof($this->opData['output']['parts']) > 1) { $this->debug('more than one output part, so use the method return unchanged'); $opParams = $this->methodreturn; - } elseif (sizeof($this->opData['output']['parts']) == 1) { + } elseif (1 == sizeof($this->opData['output']['parts'])) { $this->debug('exactly one output part, so wrap the method return in a simple array'); // TODO: verify that it is not already wrapped! //foreach ($this->opData['output']['parts'] as $name => $type) { @@ -4270,9 +4270,9 @@ private function serialize_return() $this->debug('serializing response'); if ($this->wsdl) { $this->debug('have WSDL for serialization: style is ' . $this->opData['style']); - if ($this->opData['style'] == 'rpc') { + if ('rpc' == $this->opData['style']) { $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']); - if ($this->opData['output']['use'] == 'literal') { + if ('literal' == $this->opData['output']['use']) { // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace if ($this->methodURI) { $payload = 'methodname . 'Response xmlns:ns1="' . $this->methodURI . '">' . $return_val . 'methodname . 'Response>'; @@ -4569,7 +4569,7 @@ public function register($name, $in = [], $out = [], $namespace = false, $soapac } else { $this->setError('Neither _SERVER nor HTTP_SERVER_VARS is available'); } - if ($HTTPS == '1' || $HTTPS == 'on') { + if ('1' == $HTTPS || 'on' == $HTTPS) { $SCHEME = 'https'; } else { $SCHEME = 'http'; @@ -4582,7 +4582,7 @@ public function register($name, $in = [], $out = [], $namespace = false, $soapac if (false == $use) { $use = 'encoded'; } - if ($use == 'encoded' && $encodingStyle == '') { + if ('encoded' == $use && '' == $encodingStyle) { $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; } @@ -4612,7 +4612,7 @@ public function register($name, $in = [], $out = [], $namespace = false, $soapac */ public function fault($faultcode, $faultstring, $faultactor = '', $faultdetail = '') { - if ($faultdetail == '' && $this->debug_flag) { + if ('' == $faultdetail && $this->debug_flag) { $faultdetail = $this->getDebug(); } $this->fault = new nusoap_fault($faultcode, $faultactor, $faultstring, $faultdetail); @@ -4652,7 +4652,7 @@ public function configureWSDL($serviceName, $namespace = false, $endpoint = fals if ($colon) { $SERVER_NAME = substr($SERVER_NAME, 0, $colon); } - if ($SERVER_PORT == 80) { + if (80 == $SERVER_PORT) { $SERVER_PORT = ''; } else { $SERVER_PORT = ':' . $SERVER_PORT; @@ -4662,7 +4662,7 @@ public function configureWSDL($serviceName, $namespace = false, $endpoint = fals } if (false == $endpoint) { - if ($HTTPS == '1' || $HTTPS == 'on') { + if ('1' == $HTTPS || 'on' == $HTTPS) { $SCHEME = 'https'; } else { $SCHEME = 'http'; @@ -4684,7 +4684,7 @@ public function configureWSDL($serviceName, $namespace = false, $endpoint = fals $this->wsdl->namespaces['types'] = $schemaTargetNamespace; } $this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces); - if ($style == 'document') { + if ('document' == $style) { $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified'; } $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace; @@ -4806,7 +4806,7 @@ public function fetchWSDL($wsdl) $this->debug("parse and process WSDL path=$wsdl"); $this->wsdl = $wsdl; // parse wsdl file - if ($this->wsdl != '') { + if ('' != $this->wsdl) { $this->parseWSDL($this->wsdl); } // imports @@ -4824,7 +4824,7 @@ public function fetchWSDL($wsdl) if (!$list2[$ii]['loaded']) { $this->schemas[$ns][$ns2]->imports[$ns2][$ii]['loaded'] = true; $url = $list2[$ii]['location']; - if ($url != '') { + if ('' != $url) { $urlparts = parse_url($url); if (!isset($urlparts['host'])) { $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . @@ -4850,7 +4850,7 @@ public function fetchWSDL($wsdl) if (!$list[$ii]['loaded']) { $this->import[$ns][$ii]['loaded'] = true; $url = $list[$ii]['location']; - if ($url != '') { + if ('' != $url) { $urlparts = parse_url($url); if (!isset($urlparts['host'])) { $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . @@ -4909,7 +4909,7 @@ private function parseWSDL($wsdl = '') { $this->debug("parse WSDL at path=$wsdl"); - if ($wsdl == '') { + if ('' == $wsdl) { $this->debug('no wsdl passed to parseWSDL()!!'); $this->setError('no wsdl passed to parseWSDL()!!'); return false; @@ -4918,7 +4918,7 @@ private function parseWSDL($wsdl = '') // parse $wsdl for url format $wsdl_props = parse_url($wsdl); - if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) { + if (isset($wsdl_props['scheme']) && ('http' == $wsdl_props['scheme'] || 'https' == $wsdl_props['scheme'])) { $this->debug('getting WSDL http(s) URL ' . $wsdl); // get wsdl $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl); @@ -4927,7 +4927,7 @@ private function parseWSDL($wsdl = '') if ($this->proxyhost && $this->proxyport) { $tr->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword); } - if ($this->authtype != '') { + if ('' != $this->authtype) { $tr->setCredentials($this->username, $this->password, $this->authtype, [], $this->certRequest); } $tr->setEncoding('gzip, deflate'); @@ -4947,7 +4947,7 @@ private function parseWSDL($wsdl = '') $this->debug('got WSDL URL'); } else { // $wsdl is not http(s), so treat it as a file URL or plain file path - if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) { + if (isset($wsdl_props['scheme']) && ('file' == $wsdl_props['scheme']) && isset($wsdl_props['path'])) { $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path']; } else { $path = $wsdl; @@ -5015,7 +5015,7 @@ private function parseWSDL($wsdl = '') */ private function start_element($parser, $name, $attrs) { - if ($this->status == 'schema') { + if ('schema' == $this->status) { $this->currentSchema->schemaStartElement($parser, $name, $attrs); $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); @@ -5044,7 +5044,7 @@ private function start_element($parser, $name, $attrs) } else { $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v; } - if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') { + if ('http://www.w3.org/2001/XMLSchema' == $v || 'http://www.w3.org/1999/XMLSchema' == $v || 'http://www.w3.org/2000/10/XMLSchema' == $v) { $this->XMLSchemaVersion = $v; $this->namespaces['xsi'] = $v . '-instance'; } @@ -5053,7 +5053,7 @@ private function start_element($parser, $name, $attrs) // expand each attribute prefix to its namespace foreach ($attrs as $k => $v) { $k = strpos($k, ':') ? $this->expandQname($k) : $k; - if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') { + if ('location' != $k && 'soapAction' != $k && 'namespace' != $k) { $v = strpos($v, ':') ? $this->expandQname($v) : $v; } $eAttrs[$k] = $v; @@ -5079,7 +5079,7 @@ private function start_element($parser, $name, $attrs) // find status, register data switch ($this->status) { case 'message': - if ($name == 'part') { + if ('part' == $name) { if (isset($attrs['type'])) { $this->debug('msg ' . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs)); $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; @@ -5242,7 +5242,7 @@ private function end_element($parser, $name) $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema; $this->debug('Parsing WSDL schema done'); } - if ($this->status == 'schema') { + if ('schema' == $this->status) { $this->currentSchema->schemaEndElement($parser, $name); } else { // bring depth down a notch @@ -5311,9 +5311,9 @@ public function getBindingData($binding) public function getOperations($portName = '', $bindingType = 'soap') { $ops = []; - if ($bindingType == 'soap') { + if ('soap' == $bindingType) { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; - } elseif ($bindingType == 'soap12') { + } elseif ('soap12' == $bindingType) { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; } else { $this->debug("getOperations bindingType $bindingType may not be supported"); @@ -5322,7 +5322,7 @@ public function getOperations($portName = '', $bindingType = 'soap') // loop thru ports foreach ($this->ports as $port => $portData) { $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']); - if ($portName == '' || $port == $portName) { + if ('' == $portName || $port == $portName) { // binding type of port matches parameter if ($portData['bindingType'] == $bindingType) { $this->debug("getOperations found port $port bindingType $bindingType"); @@ -5335,7 +5335,7 @@ public function getOperations($portName = '', $bindingType = 'soap') } } } - if (count($ops) == 0) { + if (0 == count($ops)) { $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType"); } return $ops; @@ -5351,9 +5351,9 @@ public function getOperations($portName = '', $bindingType = 'soap') */ public function getOperationData($operation, $bindingType = 'soap') { - if ($bindingType == 'soap') { + if ('soap' == $bindingType) { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; - } elseif ($bindingType == 'soap12') { + } elseif ('soap12' == $bindingType) { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; } // loop thru ports @@ -5383,9 +5383,9 @@ public function getOperationData($operation, $bindingType = 'soap') */ public function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') { - if ($bindingType == 'soap') { + if ('soap' == $bindingType) { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; - } elseif ($bindingType == 'soap12') { + } elseif ('soap12' == $bindingType) { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; } // loop thru ports @@ -5429,7 +5429,7 @@ public function getTypeDef($type, $ns) } if (!isset($this->schemas[$ns])) { foreach ($this->schemas as $ns0 => $schema0) { - if (strcasecmp($ns, $ns0) == 0) { + if (0 == strcasecmp($ns, $ns0)) { $this->debug("in getTypeDef: replacing schema namespace $ns with $ns0"); $ns = $ns0; break; @@ -5582,10 +5582,10 @@ function popout(){ // Hides message $b .= "
'; foreach ($typeDef['elements'] as $child => $childDef) { $buffer .= " @@ -1972,7 +1972,7 @@ public function typeToForm($name, $type) } $buffer .= '
'; // if array - } elseif ('array' == $typeDef['phpType']) { + } elseif ('array' === $typeDef['phpType']) { $buffer .= ''; for ($i = 0; $i < 3; $i++) { $buffer .= " @@ -2337,7 +2337,7 @@ private function setURL($url) // set default port if (!isset($u['port'])) { - if ('https' == $u['scheme']) { + if ('https' === $u['scheme']) { $this->port = 443; } else { $this->port = 80; @@ -2367,10 +2367,10 @@ private function setURL($url) */ private function io_method() { - if ($this->use_curl || ('https' == $this->scheme) || ('http' == $this->scheme && 'ntlm' == $this->authtype) || ('http' == $this->scheme && is_array($this->proxy) && 'ntlm' == $this->proxy['authtype'])) { + if ($this->use_curl || ('https' === $this->scheme) || ('http' === $this->scheme && 'ntlm' === $this->authtype) || ('http' === $this->scheme && is_array($this->proxy) && 'ntlm' === $this->proxy['authtype'])) { return 'curl'; } - if (('http' == $this->scheme || 'ssl' == $this->scheme) && 'ntlm' != $this->authtype && (!is_array($this->proxy) || 'ntlm' != $this->proxy['authtype'])) { + if (('http' === $this->scheme || 'ssl' === $this->scheme) && 'ntlm' !== $this->authtype && (!is_array($this->proxy) || 'ntlm' !== $this->proxy['authtype'])) { return 'socket'; } return 'unknown'; @@ -2399,7 +2399,7 @@ private function connect($connection_timeout = 0, $response_timeout = 30) // } // } $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port"); - if ('socket' == $this->io_method()) { + if ('socket' === $this->io_method()) { if (!is_array($this->proxy)) { $host = $this->host; $port = $this->port; @@ -2419,7 +2419,7 @@ private function connect($connection_timeout = 0, $response_timeout = 30) } // munge host if using OpenSSL - if ('ssl' == $this->scheme) { + if ('ssl' === $this->scheme) { $host = 'ssl://' . $host; } $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout); @@ -2450,7 +2450,7 @@ private function connect($connection_timeout = 0, $response_timeout = 30) $this->debug('socket connected'); return true; - } elseif ('curl' == $this->io_method()) { + } elseif ('curl' === $this->io_method()) { if (!extension_loaded('curl')) { // $this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS'); $this->setError('The PHP cURL Extension is required for HTTPS or NLTM. You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.'); @@ -2533,7 +2533,7 @@ private function connect($connection_timeout = 0, $response_timeout = 30) $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout); } - if ('https' == $this->scheme) { + if ('https' === $this->scheme) { $this->debug('set cURL SSL verify options'); // recent versions of cURL turn on peer/host checking by default, // while PHP binaries are not compiled with a default location for the @@ -2543,7 +2543,7 @@ private function connect($connection_timeout = 0, $response_timeout = 30) $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0); // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo) - if ('certificate' == $this->authtype) { + if ('certificate' === $this->authtype) { $this->debug('set cURL certificate options'); if (isset($this->certRequest['cainfofile'])) { $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']); @@ -2572,20 +2572,20 @@ private function connect($connection_timeout = 0, $response_timeout = 30) } } } - if ($this->authtype && ('certificate' != $this->authtype)) { + if ($this->authtype && ('certificate' !== $this->authtype)) { if ($this->username) { $this->debug('set cURL username/password'); $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password"); } - if ('basic' == $this->authtype) { + if ('basic' === $this->authtype) { $this->debug('set cURL for Basic authentication'); $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC); } - if ('digest' == $this->authtype) { + if ('digest' === $this->authtype) { $this->debug('set cURL for digest authentication'); $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST); } - if ('ntlm' == $this->authtype) { + if ('ntlm' === $this->authtype) { $this->debug('set cURL for NTLM authentication'); $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM); } @@ -2600,10 +2600,10 @@ private function connect($connection_timeout = 0, $response_timeout = 30) if ($this->proxy['username'] || $this->proxy['password']) { $this->debug('set cURL proxy authentication options'); $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'] . ':' . $this->proxy['password']); - if ('basic' == $this->proxy['authtype']) { + if ('basic' === $this->proxy['authtype']) { $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC); } - if ('ntlm' == $this->proxy['authtype']) { + if ('ntlm' === $this->proxy['authtype']) { $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM); } } @@ -2690,9 +2690,9 @@ public function setCredentials($username, $password, $authtype = 'basic', $diges $this->debug('certRequest='); $this->appendDebug($this->varDump($certRequest)); // cf. RFC 2617 - if ('basic' == $authtype) { + if ('basic' === $authtype) { $this->setHeader('Authorization', 'Basic ' . base64_encode(str_replace(':', '', $username) . ':' . $password)); - } elseif ('digest' == $authtype) { + } elseif ('digest' === $authtype) { if (isset($digestRequest['nonce'])) { $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1; @@ -2739,10 +2739,10 @@ public function setCredentials($username, $password, $authtype = 'basic', $diges $this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf('%08x', $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"'); } - } elseif ('certificate' == $authtype) { + } elseif ('certificate' === $authtype) { $this->certRequest = $certRequest; $this->debug('Authorization header not set for certificate'); - } elseif ('ntlm' == $authtype) { + } elseif ('ntlm' === $authtype) { // do nothing $this->debug('Authorization header not set for ntlm'); } @@ -2920,7 +2920,7 @@ private function buildPayload($data, $cookie_str = '') // debugging guides. // add content-length header - if ('GET' != $this->request_method) { + if ('GET' !== $this->request_method) { $this->setHeader('Content-Length', strlen($data)); } @@ -2966,12 +2966,12 @@ private function buildPayload($data, $cookie_str = '') private function sendRequest($data, $cookies = null) { // build cookie string - $cookie_str = $this->getCookiesForRequest($cookies, (('ssl' == $this->scheme) || ('https' == $this->scheme))); + $cookie_str = $this->getCookiesForRequest($cookies, (('ssl' === $this->scheme) || ('https' === $this->scheme))); // build payload $this->buildPayload($data, $cookie_str); - if ('socket' == $this->io_method()) { + if ('socket' === $this->io_method()) { // send payload if (!fwrite($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) { $this->setError('couldn\'t write message data to socket'); @@ -2980,7 +2980,7 @@ private function sendRequest($data, $cookies = null) } $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload)); return true; - } elseif ('curl' == $this->io_method()) { + } elseif ('curl' === $this->io_method()) { // set payload // cURL does say this should only be the verb, and in fact it // turns out that the URI and HTTP version are appended to this, which @@ -2988,7 +2988,7 @@ private function sendRequest($data, $cookies = null) //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload); $curl_headers = []; foreach ($this->outgoing_headers as $k => $v) { - if ('Connection' == $k || 'Content-Length' == $k || 'Host' == $k || 'Authorization' == $k || 'Proxy-Authorization' == $k) { + if ('Connection' === $k || 'Content-Length' === $k || 'Host' === $k || 'Authorization' === $k || 'Proxy-Authorization' === $k) { $this->debug("Skip cURL header $k: $v"); } else { $curl_headers[] = "$k: $v"; @@ -2999,7 +2999,7 @@ private function sendRequest($data, $cookies = null) } $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers); $this->debug('set cURL HTTP headers'); - if ('POST' == $this->request_method) { + if ('POST' === $this->request_method) { $this->setCurlOption(CURLOPT_POST, 1); $this->setCurlOption(CURLOPT_POSTFIELDS, $data); $this->debug('set cURL POST data'); @@ -3025,7 +3025,7 @@ private function getResponse() { $this->incoming_payload = ''; - if ('socket' == $this->io_method()) { + if ('socket' === $this->io_method()) { // loop until headers have been retrieved $data = ''; while (!isset($lb)) { @@ -3080,7 +3080,7 @@ private function getResponse() if (count($arr) > 1) { $header_name = strtolower(trim($arr[0])); $this->incoming_headers[$header_name] = trim($arr[1]); - if ('set-cookie' == $header_name) { + if ('set-cookie' === $header_name) { // TODO: allow multiple cookies from parseCookie $cookie = $this->parseCookie(trim($arr[1])); if ($cookie) { @@ -3097,7 +3097,7 @@ private function getResponse() } // loop until msg has been received - if (isset($this->incoming_headers['transfer-encoding']) && 'chunked' == strtolower($this->incoming_headers['transfer-encoding'])) { + if (isset($this->incoming_headers['transfer-encoding']) && 'chunked' === strtolower($this->incoming_headers['transfer-encoding'])) { $content_length = 2147483647; // ignore any content-length header $chunked = true; $this->debug('want to read chunked content'); @@ -3164,7 +3164,7 @@ private function getResponse() // close filepointer if ( - (isset($this->incoming_headers['connection']) && 'close' == strtolower($this->incoming_headers['connection'])) || + (isset($this->incoming_headers['connection']) && 'close' === strtolower($this->incoming_headers['connection'])) || (!$this->persistentConnection) || feof($this->fp) ) { fclose($this->fp); @@ -3188,7 +3188,7 @@ private function getResponse() // set decoded payload // $this->incoming_payload = $header_data.$lb.$lb.$data; // } - } elseif ('curl' == $this->io_method()) { + } elseif ('curl' === $this->io_method()) { // send and receive $this->debug('send and receive with cURL'); $this->incoming_payload = curl_exec($this->ch); @@ -3258,7 +3258,7 @@ private function getResponse() if (count($arr) > 1) { $header_name = strtolower(trim($arr[0])); $this->incoming_headers[$header_name] = trim($arr[1]); - if ('set-cookie' == $header_name) { + if ('set-cookie' === $header_name) { // TODO: allow multiple cookies from parseCookie $cookie = $this->parseCookie(trim($arr[1])); if ($cookie) { @@ -3327,7 +3327,7 @@ private function getResponse() // decode content-encoding if (isset($this->incoming_headers['content-encoding']) && '' != $this->incoming_headers['content-encoding']) { - if ('deflate' == strtolower($this->incoming_headers['content-encoding']) || 'gzip' == strtolower($this->incoming_headers['content-encoding'])) { + if ('deflate' === strtolower($this->incoming_headers['content-encoding']) || 'gzip' === strtolower($this->incoming_headers['content-encoding'])) { // if decoding works, use it. else assume data wasn't gzencoded if (function_exists('gzinflate')) { //$timer->setMarker('starting decoding of gzip/deflated content'); @@ -3335,7 +3335,7 @@ private function getResponse() // this means there are no Zlib headers, although there should be $this->debug('The gzinflate function exists'); $datalen = strlen($data); - if ('deflate' == $this->incoming_headers['content-encoding']) { + if ('deflate' === $this->incoming_headers['content-encoding']) { if ($degzdata = @gzinflate($data)) { $data = $degzdata; $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes'); @@ -3351,7 +3351,7 @@ private function getResponse() $this->debug('Error using gzinflate to inflate the payload'); $this->setError('Error using gzinflate to inflate the payload'); } - } elseif ('gzip' == $this->incoming_headers['content-encoding']) { + } elseif ('gzip' === $this->incoming_headers['content-encoding']) { if ($degzdata = @gzinflate(substr($data, 10))) { // do our best $data = $degzdata; $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes'); @@ -4018,12 +4018,12 @@ private function parse_request($data = '') // uncompress if necessary if (isset($this->headers['content-encoding']) && '' != $this->headers['content-encoding']) { $this->debug('got content encoding: ' . $this->headers['content-encoding']); - if ('deflate' == $this->headers['content-encoding'] || 'gzip' == $this->headers['content-encoding']) { + if ('deflate' === $this->headers['content-encoding'] || 'gzip' === $this->headers['content-encoding']) { // if decoding works, use it. else assume data wasn't gzencoded if (function_exists('gzuncompress')) { - if ('deflate' == $this->headers['content-encoding'] && $degzdata = @gzuncompress($data)) { + if ('deflate' === $this->headers['content-encoding'] && $degzdata = @gzuncompress($data)) { $data = $degzdata; - } elseif ('gzip' == $this->headers['content-encoding'] && $degzdata = gzinflate(substr($data, 10))) { + } elseif ('gzip' === $this->headers['content-encoding'] && $degzdata = gzinflate(substr($data, 10))) { $data = $degzdata; } else { $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data'); @@ -4133,7 +4133,7 @@ private function invoke_method() return; } } else { - $method_to_compare = ('4.' == substr(phpversion(), 0, 2)) ? strtolower($method) : $method; + $method_to_compare = ('4.' === substr(phpversion(), 0, 2)) ? strtolower($method) : $method; if (!in_array($method_to_compare, get_class_methods($class))) { $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!"); $this->result = 'fault: method not found'; @@ -4162,7 +4162,7 @@ private function invoke_method() $this->debug('in invoke_method, calling function using eval()'); $funcCall = "\$this->methodreturn = $this->methodname("; } else { - if ('..' == $delim) { + if ('..' === $delim) { $this->debug('in invoke_method, calling class method using eval()'); $funcCall = '$this->methodreturn = ' . $class . '::' . $method . '('; } else { @@ -4190,7 +4190,7 @@ private function invoke_method() if ('' == $class) { $this->debug('in invoke_method, calling function using call_user_func_array()'); $call_arg = $this->methodname; // straight assignment changes $this->methodname to lower case after call_user_func_array() - } elseif ('..' == $delim) { + } elseif ('..' === $delim) { $this->debug('in invoke_method, calling class method using call_user_func_array()'); $call_arg = [$class, $method]; } else { @@ -4224,7 +4224,7 @@ private function serialize_return() { $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI); // if fault - if (isset($this->methodreturn) && is_object($this->methodreturn) && (('soap_fault' == get_class($this->methodreturn)) || ('nusoap_fault' == get_class($this->methodreturn)))) { + if (isset($this->methodreturn) && is_object($this->methodreturn) && (('soap_fault' === get_class($this->methodreturn)) || ('nusoap_fault' === get_class($this->methodreturn)))) { $this->debug('got a fault object from method'); $this->fault = $this->methodreturn; return; @@ -4269,9 +4269,9 @@ private function serialize_return() $this->debug('serializing response'); if ($this->wsdl) { $this->debug('have WSDL for serialization: style is ' . $this->opData['style']); - if ('rpc' == $this->opData['style']) { + if ('rpc' === $this->opData['style']) { $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']); - if ('literal' == $this->opData['output']['use']) { + if ('literal' === $this->opData['output']['use']) { // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace if ($this->methodURI) { $payload = 'methodname . 'Response xmlns:ns1="' . $this->methodURI . '">' . $return_val . 'methodname . 'Response>'; @@ -4917,7 +4917,7 @@ private function parseWSDL($wsdl = '') // parse $wsdl for url format $wsdl_props = parse_url($wsdl); - if (isset($wsdl_props['scheme']) && ('http' == $wsdl_props['scheme'] || 'https' == $wsdl_props['scheme'])) { + if (isset($wsdl_props['scheme']) && ('http' === $wsdl_props['scheme'] || 'https' === $wsdl_props['scheme'])) { $this->debug('getting WSDL http(s) URL ' . $wsdl); // get wsdl $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl); @@ -4946,7 +4946,7 @@ private function parseWSDL($wsdl = '') $this->debug('got WSDL URL'); } else { // $wsdl is not http(s), so treat it as a file URL or plain file path - if (isset($wsdl_props['scheme']) && ('file' == $wsdl_props['scheme']) && isset($wsdl_props['path'])) { + if (isset($wsdl_props['scheme']) && ('file' === $wsdl_props['scheme']) && isset($wsdl_props['path'])) { $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path']; } else { $path = $wsdl; @@ -5014,7 +5014,7 @@ private function parseWSDL($wsdl = '') */ private function start_element($parser, $name, $attrs) { - if ('schema' == $this->status) { + if ('schema' === $this->status) { $this->currentSchema->schemaStartElement($parser, $name, $attrs); $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); @@ -5043,7 +5043,7 @@ private function start_element($parser, $name, $attrs) } else { $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v; } - if ('http://www.w3.org/2001/XMLSchema' == $v || 'http://www.w3.org/1999/XMLSchema' == $v || 'http://www.w3.org/2000/10/XMLSchema' == $v) { + if ('http://www.w3.org/2001/XMLSchema' === $v || 'http://www.w3.org/1999/XMLSchema' === $v || 'http://www.w3.org/2000/10/XMLSchema' === $v) { $this->XMLSchemaVersion = $v; $this->namespaces['xsi'] = $v . '-instance'; } @@ -5052,7 +5052,7 @@ private function start_element($parser, $name, $attrs) // expand each attribute prefix to its namespace foreach ($attrs as $k => $v) { $k = strpos($k, ':') ? $this->expandQname($k) : $k; - if ('location' != $k && 'soapAction' != $k && 'namespace' != $k) { + if ('location' !== $k && 'soapAction' !== $k && 'namespace' !== $k) { $v = strpos($v, ':') ? $this->expandQname($v) : $v; } $eAttrs[$k] = $v; @@ -5078,7 +5078,7 @@ private function start_element($parser, $name, $attrs) // find status, register data switch ($this->status) { case 'message': - if ('part' == $name) { + if ('part' === $name) { if (isset($attrs['type'])) { $this->debug('msg ' . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs)); $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; @@ -5241,7 +5241,7 @@ private function end_element($parser, $name) $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema; $this->debug('Parsing WSDL schema done'); } - if ('schema' == $this->status) { + if ('schema' === $this->status) { $this->currentSchema->schemaEndElement($parser, $name); } else { // bring depth down a notch @@ -5310,9 +5310,9 @@ public function getBindingData($binding) public function getOperations($portName = '', $bindingType = 'soap') { $ops = []; - if ('soap' == $bindingType) { + if ('soap' === $bindingType) { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; - } elseif ('soap12' == $bindingType) { + } elseif ('soap12' === $bindingType) { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; } else { $this->debug("getOperations bindingType $bindingType may not be supported"); @@ -5350,9 +5350,9 @@ public function getOperations($portName = '', $bindingType = 'soap') */ public function getOperationData($operation, $bindingType = 'soap') { - if ('soap' == $bindingType) { + if ('soap' === $bindingType) { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; - } elseif ('soap12' == $bindingType) { + } elseif ('soap12' === $bindingType) { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; } // loop thru ports @@ -5382,9 +5382,9 @@ public function getOperationData($operation, $bindingType = 'soap') */ public function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') { - if ('soap' == $bindingType) { + if ('soap' === $bindingType) { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; - } elseif ('soap12' == $bindingType) { + } elseif ('soap12' === $bindingType) { $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; } // loop thru ports @@ -5581,10 +5581,10 @@ function popout(){ // Hides message $b .= "
'; @@ -3218,9 +3218,9 @@ private function getResponse() $savedata = $data; while ($this->isSkippableCurlHeader($data)) { $this->debug('Found HTTP header to skip'); - if ($pos = strpos($data, "\r\n\r\n")) { + if (false !== ($pos = strpos($data, "\r\n\r\n"))) { $data = ltrim(substr($data, $pos)); - } elseif ($pos = strpos($data, "\n\n")) { + } elseif (false !== ($pos = strpos($data, "\n\n"))) { $data = ltrim(substr($data, $pos)); } } @@ -3229,18 +3229,18 @@ private function getResponse() // have nothing left; just remove 100 header(s) $data = $savedata; while (preg_match('/^HTTP\/1.1 100/', $data)) { - if ($pos = strpos($data, "\r\n\r\n")) { + if (false !== ($pos = strpos($data, "\r\n\r\n"))) { $data = ltrim(substr($data, $pos)); - } elseif ($pos = strpos($data, "\n\n")) { + } elseif (false !== ($pos = strpos($data, "\n\n"))) { $data = ltrim(substr($data, $pos)); } } } // separate content from HTTP headers - if ($pos = strpos($data, "\r\n\r\n")) { + if (false !== ($pos = strpos($data, "\r\n\r\n"))) { $lb = "\r\n"; - } elseif ($pos = strpos($data, "\n\n")) { + } elseif (false !== ($pos = strpos($data, "\n\n"))) { $lb = "\n"; } else { $this->debug('no proper separation of headers and document'); @@ -3336,13 +3336,13 @@ private function getResponse() $this->debug('The gzinflate function exists'); $datalen = strlen($data); if ('deflate' === $this->incoming_headers['content-encoding']) { - if ($degzdata = @gzinflate($data)) { + if (false !== ($degzdata = @gzinflate($data))) { $data = $degzdata; $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes'); if (strlen($data) < $datalen) { // test for the case that the payload has been compressed twice $this->debug('The inflated payload is smaller than the gzipped one; try again'); - if ($degzdata = @gzinflate($data)) { + if (false !== ($degzdata = @gzinflate($data))) { $data = $degzdata; $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes'); } @@ -3352,13 +3352,13 @@ private function getResponse() $this->setError('Error using gzinflate to inflate the payload'); } } elseif ('gzip' === $this->incoming_headers['content-encoding']) { - if ($degzdata = @gzinflate(substr($data, 10))) { // do our best + if (false !== ($degzdata = @gzinflate(substr($data, 10)))) { // do our best $data = $degzdata; $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes'); if (strlen($data) < $datalen) { // test for the case that the payload has been compressed twice $this->debug('The un-gzipped payload is smaller than the gzipped one; try again'); - if ($degzdata = @gzinflate(substr($data, 10))) { + if (false !== ($degzdata = @gzinflate(substr($data, 10)))) { $data = $degzdata; $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes'); } @@ -3784,7 +3784,7 @@ public function __construct($wsdl = false) } $this->appendDebug($this->wsdl->getDebug()); $this->wsdl->clearDebug(); - if ($err = $this->wsdl->getError()) { + if (false !== ($err = $this->wsdl->getError())) { die('WSDL ERROR: ' . $err); } } @@ -4074,10 +4074,10 @@ private function invoke_method() // $orig_methodname = $this->methodname; if ($this->wsdl) { - if ($this->opData = $this->wsdl->getOperationData($this->methodname)) { + if (false !== ($this->opData = $this->wsdl->getOperationData($this->methodname))) { $this->debug('in invoke_method, found WSDL operation=' . $this->methodname); $this->appendDebug('opData=' . $this->varDump($this->opData)); - } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) { + } elseif (false !== ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction))) { // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']); $this->appendDebug('opData=' . $this->varDump($this->opData)); @@ -4249,7 +4249,7 @@ private function serialize_return() $return_val = $this->wsdl->serializeRPCParameters($this->methodname, 'output', $opParams); $this->appendDebug($this->wsdl->getDebug()); $this->wsdl->clearDebug(); - if ($errstr = $this->wsdl->getError()) { + if (false !== ($errstr = $this->wsdl->getError())) { $this->debug('got wsdl error: ' . $errstr); $this->fault('SOAP-ENV:Server', 'unable to serialize result'); return; @@ -4451,7 +4451,7 @@ private function parseRequest($headers, $data) // parser debug $this->debug("parser debug: \n" . $parser->getDebug()); // if fault occurred during message parsing - if ($err = $parser->getError()) { + if (false !== ($err = $parser->getError())) { $this->result = 'fault: error in msg parsing: ' . $err; $this->fault('SOAP-ENV:Client', "error in msg parsing:\n" . $err); // else successfully parsed request into soapval object @@ -4935,7 +4935,7 @@ private function parseWSDL($wsdl = '') //$this->debug("WSDL response\n" . $tr->incoming_payload); $this->appendDebug($tr->getDebug()); // catch errors - if ($err = $tr->getError()) { + if (false !== ($err = $tr->getError())) { $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: ' . $err; $this->debug($errstr); $this->setError($errstr); @@ -4952,9 +4952,9 @@ private function parseWSDL($wsdl = '') $path = $wsdl; } $this->debug('getting WSDL file ' . $path); - if ($fp = @fopen($path, 'r')) { + if (false !== ($fp = @fopen($path, 'r'))) { $wsdl_string = ''; - while ($data = fread($fp, 32768)) { + while (false !== ($data = fread($fp, 32768))) { $wsdl_string .= $data; } fclose($fp); @@ -5038,7 +5038,7 @@ private function start_element($parser, $name, $attrs) // register namespace declarations foreach ($attrs as $k => $v) { if (preg_match('/^xmlns/', $k)) { - if ($ns_prefix = substr(strrchr($k, ':'), 1)) { + if (false !== ($ns_prefix = substr(strrchr($k, ':'), 1))) { $this->namespaces[$ns_prefix] = $v; } else { $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v; @@ -6346,7 +6346,7 @@ private function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) if ($this->getNamespaceFromPrefix($nsx)) { $nsx = $this->getNamespaceFromPrefix($nsx); } - if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) { + if (false !== ($typeDefx = $this->getTypeDef($uqTypex, $nsx))) { $this->debug("serialize attributes for extension base $nsx:$uqTypex"); $xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex); } else { @@ -6410,7 +6410,7 @@ private function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $u if ($this->getNamespaceFromPrefix($nsx)) { $nsx = $this->getNamespaceFromPrefix($nsx); } - if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) { + if (false !== ($typeDefx = $this->getTypeDef($uqTypex, $nsx))) { $this->debug("serialize elements for extension base $nsx:$uqTypex"); $xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle); } else { @@ -7543,7 +7543,7 @@ public function call($operation, $params = [], $namespace = 'http://tempuri.org' } $this->appendDebug($this->wsdl->getDebug()); $this->wsdl->clearDebug(); - if ($errstr = $this->wsdl->getError()) { + if (false !== ($errstr = $this->wsdl->getError())) { $this->debug('got wsdl error: ' . $errstr); $this->setError('wsdl error: ' . $errstr); return false; @@ -7612,7 +7612,7 @@ public function call($operation, $params = [], $namespace = 'http://tempuri.org' $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000)); // send $return = $this->send($this->getHTTPBody($soapmsg), $soapAction, $this->timeout, $this->response_timeout); - if ($errstr = $this->getError()) { + if (false !== ($errstr = $this->getError())) { $this->debug('Error: ' . $errstr); return false; } else { @@ -7670,17 +7670,17 @@ private function checkWSDL() $this->wsdl->clearDebug(); $this->debug('checkWSDL'); // catch errors - if ($errstr = $this->wsdl->getError()) { + if (false !== ($errstr = $this->wsdl->getError())) { $this->appendDebug($this->wsdl->getDebug()); $this->wsdl->clearDebug(); $this->debug('got wsdl error: ' . $errstr); $this->setError('wsdl error: ' . $errstr); - } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap')) { + } elseif (false !== ($this->operations = $this->wsdl->getOperations($this->portName, 'soap'))) { $this->appendDebug($this->wsdl->getDebug()); $this->wsdl->clearDebug(); $this->bindingType = 'soap'; $this->debug('got ' . count($this->operations) . ' operations from wsdl ' . $this->wsdlFile . ' for binding type ' . $this->bindingType); - } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) { + } elseif (false !== ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12'))) { $this->appendDebug($this->wsdl->getDebug()); $this->wsdl->clearDebug(); $this->bindingType = 'soap12'; @@ -7798,7 +7798,7 @@ private function send($msg, $soapaction = '', $timeout = 0, $response_timeout = } } - if ($err = $http->getError()) { + if (false !== ($err = $http->getError())) { $this->setError('HTTP Error: ' . $err); return false; } elseif ($this->getError()) { @@ -7852,7 +7852,7 @@ private function parseResponse($headers, $data) // add parser debug data to our debug $this->appendDebug($parser->getDebug()); // if parse errors - if ($errstr = $parser->getError()) { + if (false !== ($errstr = $parser->getError())) { $this->setError($errstr); // destroy the parser object unset($parser); From 4b8bd2b52214c69aa461c9edbf4f555caa7b6ce2 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 11 Jun 2018 03:25:13 -0400 Subject: [PATCH 26/40] Countable --- src/nusoap.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index 1d7b020..eb02402 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -601,7 +601,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal $xml .= $this->serialize_val($v, 'item', false, false, false, false, $use); ++$i; } - if (count($array_types) > 1) { + if (is_array($array_types) && count($array_types) > 1) { $array_typename = 'xsd:anyType'; } elseif (isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) { if ('integer' === $tt) { @@ -1317,7 +1317,7 @@ public function schemaStartElement($parser, $name, $attrs) } // loop thru attributes, expanding, and registering namespace declarations - if (count($attrs) > 0) { + if (is_array($attrs) && count($attrs) > 0) { foreach ($attrs as $k => $v) { // if ns declarations, add to class level array of valid namespaces if (preg_match('/^xmlns/', $k)) { @@ -1677,7 +1677,7 @@ public function serializeSchema() $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); $xml = ''; // imports - if (count($this->imports) > 0) { + if (is_array($this->imports) && count($this->imports) > 0) { foreach ($this->imports as $ns => $list) { foreach ($list as $ii) { if ('' != $ii['location']) { @@ -1932,7 +1932,7 @@ public function serializeTypeDef($type) } } $str .= ' xmlns="' . $this->schema['targetNamespace'] . '"'; - if (count($typeDef['elements']) > 0) { + if (is_array($typeDef['elements']) && count($typeDef['elements']) > 0) { $str .= '>'; foreach ($typeDef['elements'] as $element => $eData) { $str .= $this->serializeTypeDef($element); @@ -3077,7 +3077,7 @@ private function getResponse() $this->incoming_cookies = []; foreach ($header_array as $header_line) { $arr = explode(':', $header_line, 2); - if (count($arr) > 1) { + if (is_array($arr) && count($arr) > 1) { $header_name = strtolower(trim($arr[0])); $this->incoming_headers[$header_name] = trim($arr[1]); if ('set-cookie' === $header_name) { @@ -3255,7 +3255,7 @@ private function getResponse() // clean headers foreach ($header_array as $header_line) { $arr = explode(':', $header_line, 2); - if (count($arr) > 1) { + if (is_array($arr) && count($arr) > 1) { $header_name = strtolower(trim($arr[0])); $this->incoming_headers[$header_name] = trim($arr[1]); if ('set-cookie' === $header_name) { @@ -4235,7 +4235,7 @@ private function serialize_return() $this->debug('got a(n) ' . gettype($this->methodreturn) . ' from method'); $this->debug('serializing return value'); if ($this->wsdl) { - if (count($this->opData['output']['parts']) > 1) { + if (is_array($this->opData['output']['parts']) && count($this->opData['output']['parts']) > 1) { $this->debug('more than one output part, so use the method return unchanged'); $opParams = $this->methodreturn; } elseif (1 == count($this->opData['output']['parts'])) { @@ -5034,7 +5034,7 @@ private function start_element($parser, $name, $attrs) $this->depth_array[$depth] = $pos; $this->message[$pos] = ['cdata' => '']; // process attributes - if (count($attrs) > 0) { + if (is_array($attrs) && count($attrs) > 0) { // register namespace declarations foreach ($attrs as $k => $v) { if (preg_match('/^xmlns/', $k)) { @@ -5631,7 +5631,7 @@ public function serialize($debug = 0) } $xml .= '>'; // imports - if (count($this->import) > 0) { + if (is_array($this->import) && count($this->import) > 0) { foreach ($this->import as $ns => $list) { foreach ($list as $ii) { if ('' != $ii['location']) { @@ -5643,7 +5643,7 @@ public function serialize($debug = 0) } } // types - if (count($this->schemas) >= 1) { + if (is_array($this->schemas) && count($this->schemas) >= 1) { $xml .= "\n\n"; foreach ($this->schemas as $ns => $list) { foreach ($list as $xs) { @@ -5653,7 +5653,7 @@ public function serialize($debug = 0) $xml .= ''; } // messages - if (count($this->messages) >= 1) { + if (is_array($this->messages) && count($this->messages) >= 1) { foreach ($this->messages as $msgName => $msgParts) { $xml .= "\n'; if (is_array($msgParts)) { @@ -5692,7 +5692,7 @@ public function serialize($debug = 0) } } // bindings & porttypes - if (count($this->bindings) >= 1) { + if (is_array($this->bindings) && count($this->bindings) >= 1) { $binding_xml = ''; $portType_xml = ''; foreach ($this->bindings as $bindingName => $attrs) { @@ -5734,7 +5734,7 @@ public function serialize($debug = 0) } // services $xml .= "\nserviceName . '">'; - if (count($this->ports) >= 1) { + if (is_array($this->ports) && count($this->ports) >= 1) { foreach ($this->ports as $pName => $attrs) { $xml .= "\n" . ' '; $xml .= "\n" . ' '; @@ -6428,7 +6428,7 @@ private function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $u $xvalue = []; } // toggle whether all elements are present - ideally should validate against schema - if (count($typeDef['elements']) != count($xvalue)) { + if (is_array($xvalue) && (count($typeDef['elements']) != count($xvalue))) { $optionals = true; } foreach ($typeDef['elements'] as $eName => $attrs) { @@ -6511,7 +6511,7 @@ private function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $u */ public function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = [], $attrs = [], $arrayType = '') { - if (count($elements) > 0) { + if (is_array($elements) && count($elements) > 0) { $eElements = []; foreach ($elements as $n => $e) { // expand each element @@ -6526,7 +6526,7 @@ public function addComplexType($name, $typeClass = 'complexType', $phpType = 'ar $elements = $eElements; } - if (count($attrs) > 0) { + if (is_array($attrs) && count($attrs) > 0) { foreach ($attrs as $n => $a) { // expand each attribute foreach ($a as $k => $v) { @@ -6791,7 +6791,7 @@ public function __construct($xml, $encoding = 'UTF-8', $method = '', $decode_utf $this->soapheader = $this->message[$this->root_header]['result']; } // resolve hrefs/ids - if (count($this->multirefs) > 0) { + if (is_array($this->multirefs) && count($this->multirefs) > 0) { foreach ($this->multirefs as $id => $hrefs) { $this->debug('resolving multirefs for id: ' . $id); $idVal = $this->buildVal($this->ids[$id]); @@ -7643,7 +7643,7 @@ public function call($operation, $params = [], $namespace = 'http://tempuri.org' if (is_array($return)) { // multiple 'out' parameters, which we return wrapped up // in the array - if (count($return) > 1) { + if (is_array($return) && count($return) > 1) { return $return; } // single 'out' parameter (normally the return value) @@ -8113,7 +8113,7 @@ private function _getProxyClassCode($r) foreach ($this->operations as $operation => $opData) { if ('' != $operation) { // create param string and param comment string - if (count($opData['input']['parts']) > 0) { + if (is_array($opData['input']['parts']) && count($opData['input']['parts']) > 0) { $paramStr = ''; $paramArrayStr = ''; $paramCommentStr = ''; @@ -8282,7 +8282,7 @@ private function UpdateCookies($cookies) { if (0 == count($this->cookies)) { // no existing cookies: take whatever is new - if (count($cookies) > 0) { + if (is_array($cookies) && count($cookies) > 0) { $this->debug('Setting new cookie(s)'); $this->cookies = $cookies; } From 6f5676d2ad633977faa205ccdd34fac8a96b6840 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 11 Jun 2018 03:26:26 -0400 Subject: [PATCH 27/40] Return value type is not compatible with declared --- src/nusoap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index eb02402..d7081c5 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -3426,7 +3426,7 @@ public function usePersistentConnection() * parse an incoming Cookie into it's parts * * @param string $cookie_str content of cookie - * @return array with data of that cookie + * @return bool|array with data of that cookie * @access private */ /* @@ -7712,7 +7712,7 @@ public function loadWSDL() * get available data pertaining to an operation * * @param string $operation operation name - * @return array array of data pertaining to the operation + * @return bool|array array of data pertaining to the operation * @access public */ public function getOperationData($operation) From cfc1972bf4de778cef1bf6186fed11095ffd6c8f Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 11 Jun 2018 03:42:49 -0400 Subject: [PATCH 28/40] PHPDoc --- src/nusoap.php | 99 ++++++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 44 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index d7081c5..5081bc2 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -385,7 +385,8 @@ public function getError() /** * sets error string * - * @return boolean $string error string + * @param string $str + * @return void $string error string * @access private */ protected function setError($str) @@ -415,14 +416,14 @@ protected function isArraySimpleOrStruct($val) * serializes PHP values in accordance w/ section 5. Type information is * not serialized if $use == 'literal'. * - * @param mixed $val The value to serialize - * @param string $name The name (local part) of the XML element - * @param string $type The XML schema type (local part) for the element - * @param string $name_ns The namespace for the name of the XML element - * @param string $type_ns The namespace for the type of the element - * @param array $attributes The attributes to serialize as name=>value pairs - * @param string $use The WSDL "use" (encoded|literal) - * @param boolean $soapval Whether this is called from soapval. + * @param mixed $val The value to serialize + * @param bool|string $name The name (local part) of the XML element + * @param bool|string $type The XML schema type (local part) for the element + * @param bool|string $name_ns The namespace for the name of the XML element + * @param bool|string $type_ns The namespace for the type of the element + * @param bool|string|array $attributes The attributes to serialize as name=>value pairs + * @param string $use The WSDL "use" (encoded|literal) + * @param boolean $soapval Whether this is called from soapval. * @return string The serialized element, possibly with child elements * @access public */ @@ -1161,9 +1162,9 @@ class nusoap_xmlschema extends nusoap_base /** * constructor * - * @param string $schema schema document URI - * @param string $xml xml document URI - * @param string $namespaces namespaces defined in enclosing XML + * @param string $schema schema document URI + * @param string $xml xml document URI + * @param array $namespaces namespaces defined in enclosing XML * @access public */ public function __construct($schema = '', $xml = '', $namespaces = []) @@ -2016,18 +2017,18 @@ public function typeToForm($name, $type) * ); * * @param string name - * @param typeClass (complexType|simpleType|attribute) - * @param phpType : currently supported are array and struct (php assoc array) - * @param compositor (all|sequence|choice) - * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) - * @param elements = array ( name = array(name=>'',type=>'') ) - * @param attrs = array( + * @param string typeClass (complexType|simpleType|attribute) + * @param string phpType : currently supported are array and struct (php assoc array) + * @param string $compositor (all|sequence|choice) + * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) + * @param array $elements = array ( name = array(name=>'',type=>'') ) + * @param array $attrs = array( * array( * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" * ) * ) - * @param arrayType : namespace:name (http://www.w3.org/2001/XMLSchema:string) + * @param string arrayType : namespace:name (http://www.w3.org/2001/XMLSchema:string) * @access public * @see getTypeDef */ @@ -2379,10 +2380,10 @@ private function io_method() /** * establish an HTTP connection * - * @param integer $timeout set connection timeout in seconds - * @param integer $response_timeout set response timeout in seconds - * @return boolean true if connected, false if not - * @access private + * @param int $connection_timeout set connection timeout in seconds + * @param int $response_timeout set response timeout in seconds + * @return bool true if connected, false if not + * @access private */ private function connect($connection_timeout = 0, $response_timeout = 30) { @@ -4768,10 +4769,10 @@ class wsdl extends nusoap_base * constructor * * @param string $wsdl WSDL document URL - * @param string $proxyhost - * @param string $proxyport - * @param string $proxyusername - * @param string $proxypassword + * @param bool|string $proxyhost + * @param bool|string $proxyport + * @param bool|string $proxyusername + * @param bool|string $proxypassword * @param integer $timeout set the connection timeout * @param integer $response_timeout set the response timeout * @param array $curl_options user-specified cURL options @@ -4799,6 +4800,7 @@ public function __construct($wsdl = '', $proxyhost = false, $proxyport = false, * fetches the WSDL document and parses it * * @access public + * @param $wsdl */ public function fetchWSDL($wsdl) { @@ -5292,6 +5294,10 @@ public function setCredentials($username, $password, $authtype = 'basic', $certR $this->certRequest = $certRequest; } + /** + * @param $binding + * @return mixed + */ public function getBindingData($binding) { if (is_array($this->bindings[$binding])) { @@ -6013,8 +6019,8 @@ public function serializeParameters($operation, $direction, $parameters) * @param string $type XML schema type of value (type or element) * @param mixed $value a native PHP value (parameter value) * @param string $use use for part (encoded|literal) - * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style) - * @param boolean $unqualified a kludge for what should be XML namespace form handling + * @param bool|string $encodingStyle SOAP encoding style for the value (if different than the enclosing style) + * @param bool $unqualified a kludge for what should be XML namespace form handling * @return string value serialized as an XML string * @access private */ @@ -6396,7 +6402,7 @@ private function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) * @param string $ns the namespace of the type * @param string $uqType the local part of the type * @param string $use use for part (encoded|literal) - * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style) + * @param bool|string $encodingStyle SOAP encoding style for the value (if different than the enclosing style) * @return string value serialized as an XML string * @access private */ @@ -6581,15 +6587,15 @@ public function addElement($attrs) /** * register an operation with the server * - * @param string $name operation (method) name - * @param array $in assoc array of input values: key = param name, value = param type - * @param array $out assoc array of output values: key = param name, value = param type - * @param string $namespace optional The namespace for the operation - * @param string $soapaction optional The soapaction for the operation - * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically - * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now) - * @param string $documentation optional The description to include in the WSDL - * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) + * @param string $name operation (method) name + * @param bool|array $in assoc array of input values: key = param name, value = param type + * @param bool|array $out assoc array of output values: key = param name, value = param type + * @param bool|string $namespace optional The namespace for the operation + * @param bool|string $soapaction optional The soapaction for the operation + * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically + * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now) + * @param string $documentation optional The description to include in the WSDL + * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) * @access public */ public function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = '') @@ -6720,7 +6726,7 @@ class nusoap_parser extends nusoap_base * @param string $xml SOAP message * @param string $encoding character encoding scheme of message * @param string $method method for which XML is parsed (unused?) - * @param string $decode_utf8 whether to decode UTF-8 to ISO-8859-1 + * @param bool|string $decode_utf8 whether to decode UTF-8 to ISO-8859-1 * @access public */ public function __construct($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = true) @@ -7407,10 +7413,10 @@ class nusoap_client extends nusoap_base * * @param mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object) * @param mixed $wsdl optional, set to 'wsdl' or true if using WSDL - * @param string $proxyhost optional - * @param string $proxyport optional - * @param string $proxyusername optional - * @param string $proxypassword optional + * @param bool|string $proxyhost optional + * @param bool|string $proxyport optional + * @param bool|string $proxyusername optional + * @param bool|string $proxypassword optional * @param integer $timeout set the connection timeout * @param integer $response_timeout set the response timeout * @param string $portName optional portName in WSDL document @@ -8090,6 +8096,7 @@ public function getProxy() /** * dynamically creates proxy class code * + * @param string $r * @return string PHP/NuSOAP code for the proxy class * @access private */ @@ -8204,6 +8211,10 @@ private function getHTTPContentTypeCharset() * @return always returns true * @access public */ + /** + * @param $bool + * @return bool + */ public function decodeUTF8($bool) { $this->decode_utf8 = $bool; From af769a0441cd890c9e8da9b8339f57a97723d145 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 11 Jun 2018 03:45:39 -0400 Subject: [PATCH 29/40] file_get_contents(...) --- src/nusoap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nusoap.php b/src/nusoap.php index 5081bc2..827a22d 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -1204,7 +1204,7 @@ public function parseFile($xml, $type) { // parse xml file if ('' != $xml) { - $xmlStr = @implode('', @file($xml)); + $xmlStr = @file_get_contents($xml); if ('' == $xmlStr) { $msg = 'Error reading XML from ' . $xml; $this->setError($msg); From dfb4d0c9d82e7ce42f4e1ddd0a84a4bdce25ae19 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 11 Jun 2018 03:47:01 -0400 Subject: [PATCH 30/40] strict comparison --- src/nusoap.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index 827a22d..0161d7b 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -3756,7 +3756,7 @@ public function __construct($wsdl = false) } elseif (isset($_SERVER['QUERY_STRING'])) { $qs = explode('&', $_SERVER['QUERY_STRING']); foreach ($qs as $v) { - if ('debug=' == substr($v, 0, 6)) { + if ('debug=' === substr($v, 0, 6)) { $this->debug('In nusoap_server, set debug_flag=' . substr($v, 6) . ' based on query string #1'); $this->debug_flag = substr($v, 6); } @@ -3764,7 +3764,7 @@ public function __construct($wsdl = false) } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']); foreach ($qs as $v) { - if ('debug=' == substr($v, 0, 6)) { + if ('debug=' === substr($v, 0, 6)) { $this->debug('In nusoap_server, set debug_flag=' . substr($v, 6) . ' based on query string #2'); $this->debug_flag = substr($v, 6); } @@ -3774,7 +3774,7 @@ public function __construct($wsdl = false) // wsdl if ($wsdl) { $this->debug('In nusoap_server, WSDL is specified'); - if (is_object($wsdl) && ('wsdl' == get_class($wsdl))) { + if (is_object($wsdl) && ('wsdl' === get_class($wsdl))) { $this->wsdl = $wsdl; $this->externalWSDLURL = $this->wsdl->wsdl; $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL); @@ -3818,7 +3818,7 @@ public function service($data) } $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data)); - if ('POST' == $rm) { + if ('POST' === $rm) { $this->debug('In service, invoke the request'); $this->parse_request($data); if (!$this->fault) { @@ -3916,18 +3916,18 @@ private function parse_http_headers() } elseif (isset($_SERVER) && is_array($_SERVER)) { $this->debug('In parse_http_headers, use _SERVER'); foreach ($_SERVER as $k => $v) { - if ('HTTP_' == substr($k, 0, 5)) { + if ('HTTP_' === substr($k, 0, 5)) { $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); } else { $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); } - if ('soapaction' == $k) { + if ('soapaction' === $k) { // get SOAPAction header $k = 'SOAPAction'; $v = str_replace('"', '', $v); $v = str_replace('\\', '', $v); $this->SOAPAction = $v; - } elseif ('content-type' == $k) { + } elseif ('content-type' === $k) { // get the character encoding of the incoming request if (strpos($v, '=')) { $enc = substr(strstr($v, '='), 1); @@ -3950,20 +3950,20 @@ private function parse_http_headers() } elseif (is_array($HTTP_SERVER_VARS)) { $this->debug('In parse_http_headers, use HTTP_SERVER_VARS'); foreach ($HTTP_SERVER_VARS as $k => $v) { - if ('HTTP_' == substr($k, 0, 5)) { + if ('HTTP_' === substr($k, 0, 5)) { $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); $k = strtolower(substr($k, 5)); } else { $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); $k = strtolower($k); } - if ('soapaction' == $k) { + if ('soapaction' === $k) { // get SOAPAction header $k = 'SOAPAction'; $v = str_replace('"', '', $v); $v = str_replace('\\', '', $v); $this->SOAPAction = $v; - } elseif ('content-type' == $k) { + } elseif ('content-type' === $k) { // get the character encoding of the incoming request if (strpos($v, '=')) { $enc = substr(strstr($v, '='), 1); @@ -4569,7 +4569,7 @@ public function register($name, $in = [], $out = [], $namespace = false, $soapac } else { $this->setError('Neither _SERVER nor HTTP_SERVER_VARS is available'); } - if ('1' == $HTTPS || 'on' == $HTTPS) { + if ('1' == $HTTPS || 'on' === $HTTPS) { $SCHEME = 'https'; } else { $SCHEME = 'http'; @@ -4582,7 +4582,7 @@ public function register($name, $in = [], $out = [], $namespace = false, $soapac if (false == $use) { $use = 'encoded'; } - if ('encoded' == $use && '' == $encodingStyle) { + if ('encoded' === $use && '' == $encodingStyle) { $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; } @@ -4662,7 +4662,7 @@ public function configureWSDL($serviceName, $namespace = false, $endpoint = fals } if (false == $endpoint) { - if ('1' == $HTTPS || 'on' == $HTTPS) { + if ('1' == $HTTPS || 'on' === $HTTPS) { $SCHEME = 'https'; } else { $SCHEME = 'http'; @@ -4684,7 +4684,7 @@ public function configureWSDL($serviceName, $namespace = false, $endpoint = fals $this->wsdl->namespaces['types'] = $schemaTargetNamespace; } $this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces); - if ('document' == $style) { + if ('document' === $style) { $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified'; } $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace; From 76651cc6b0c706f11412136f0fee1e5742ea8b24 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 11 Jun 2018 03:59:19 -0400 Subject: [PATCH 31/40] missing function, types --- src/nusoap.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index 0161d7b..ab34754 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -2811,7 +2811,7 @@ public function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypass } else { $this->debug('remove proxy'); $proxy = null; - unsetHeader('Proxy-Authorization'); + $this->unsetHeader('Proxy-Authorization'); } } @@ -7388,22 +7388,22 @@ class nusoap_client extends nusoap_base * fault related variables */ /** - * @var fault + * @var string $fault * @access public */ public $fault; /** - * @var faultcode + * @var string $faultcode * @access public */ public $faultcode; /** - * @var faultstring + * @var string $faultstring * @access public */ public $faultstring; /** - * @var faultdetail + * @var string $faultdetail * @access public */ public $faultdetail; From 1c51d8dda95e77851a6067ca250a1418e87fab12 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 11 Jun 2018 04:03:38 -0400 Subject: [PATCH 32/40] Missing @return tag --- src/nusoap.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index ab34754..0132939 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -355,6 +355,7 @@ public function &getDebugAsXMLComment() * * @param string $val The string in which to expand entities. * @access private + * @return mixed|string */ protected function expandEntities($val) { @@ -2815,7 +2816,6 @@ public function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypass } } - /** * Test if the given string starts with a header that is to be skipped. * Skippable headers result from chunked transfer and proxy requests. @@ -2823,6 +2823,7 @@ public function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypass * @param string $data The string to check. * @returns boolean Whether a skippable header was found. * @access private + * @return bool */ private function isSkippableCurlHeader(&$data) { @@ -2855,6 +2856,7 @@ private function isSkippableCurlHeader(&$data) * @returns string * @access public * @deprecated + * @return string */ public function decodeChunked($buffer, $lb) { @@ -4528,16 +4530,17 @@ public function add_to_map($methodname, $in, $out) /** * register a service function with the server * - * @param string $name the name of the PHP function, class.method or class..method - * @param array $in assoc array of input values: key = param name, value = param type - * @param array $out assoc array of output values: key = param name, value = param type - * @param mixed $namespace the element namespace for the method or false - * @param mixed $soapaction the soapaction for the method or false - * @param mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically - * @param mixed $use optional (encoded|literal) or false + * @param string $name the name of the PHP function, class.method or class..method + * @param array $in assoc array of input values: key = param name, value = param type + * @param array $out assoc array of output values: key = param name, value = param type + * @param mixed $namespace the element namespace for the method or false + * @param mixed $soapaction the soapaction for the method or false + * @param mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically + * @param mixed $use optional (encoded|literal) or false * @param string $documentation optional Description to include in WSDL * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) * @access public + * @return bool */ public function register($name, $in = [], $out = [], $namespace = false, $soapaction = false, $style = false, $use = false, $documentation = '', $encodingStyle = '') { @@ -4905,6 +4908,7 @@ public function fetchWSDL($wsdl) * * @param string $wsdl path or URL * @access private + * @return bool */ private function parseWSDL($wsdl = '') { @@ -6597,6 +6601,7 @@ public function addElement($attrs) * @param string $documentation optional The description to include in the WSDL * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) * @access public + * @return bool */ public function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = '') { From 59a55fdc11f99600d05b9902a68c0c2f57262192 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 11 Jun 2018 04:05:34 -0400 Subject: [PATCH 33/40] 'safe_mode' was removed in PHP 5.4.0. --- src/nusoap.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index 0132939..08ee9cc 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -2499,15 +2499,7 @@ private function connect($connection_timeout = 0, $response_timeout = 30) $hostURL .= $this->path; $this->setCurlOption(CURLOPT_URL, $hostURL); // follow location headers (re-directs) - if (ini_get('safe_mode') || ini_get('open_basedir')) { - $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION'); - $this->debug('safe_mode = '); - $this->appendDebug($this->varDump(ini_get('safe_mode'))); - $this->debug('open_basedir = '); - $this->appendDebug($this->varDump(ini_get('open_basedir'))); - } else { - $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1); - } + $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1); // ask for headers in the response output $this->setCurlOption(CURLOPT_HEADER, 1); // ask for the response output as the return value From 8049be862e1c0cb550a39ec9b185fba617bf55c5 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 11 Jun 2018 04:08:16 -0400 Subject: [PATCH 34/40] 'substr(...)' replaced with 'strpos(...)' --- src/nusoap.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index 08ee9cc..63fe441 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -3750,7 +3750,7 @@ public function __construct($wsdl = false) } elseif (isset($_SERVER['QUERY_STRING'])) { $qs = explode('&', $_SERVER['QUERY_STRING']); foreach ($qs as $v) { - if ('debug=' === substr($v, 0, 6)) { + if (0 === strpos($v, 'debug=')) { $this->debug('In nusoap_server, set debug_flag=' . substr($v, 6) . ' based on query string #1'); $this->debug_flag = substr($v, 6); } @@ -3758,7 +3758,7 @@ public function __construct($wsdl = false) } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']); foreach ($qs as $v) { - if ('debug=' === substr($v, 0, 6)) { + if (0 === strpos($v, 'debug=')) { $this->debug('In nusoap_server, set debug_flag=' . substr($v, 6) . ' based on query string #2'); $this->debug_flag = substr($v, 6); } @@ -3910,7 +3910,7 @@ private function parse_http_headers() } elseif (isset($_SERVER) && is_array($_SERVER)) { $this->debug('In parse_http_headers, use _SERVER'); foreach ($_SERVER as $k => $v) { - if ('HTTP_' === substr($k, 0, 5)) { + if (0 === strpos($k, 'HTTP_')) { $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); } else { $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); @@ -3944,7 +3944,7 @@ private function parse_http_headers() } elseif (is_array($HTTP_SERVER_VARS)) { $this->debug('In parse_http_headers, use HTTP_SERVER_VARS'); foreach ($HTTP_SERVER_VARS as $k => $v) { - if ('HTTP_' === substr($k, 0, 5)) { + if (0 === strpos($k, 'HTTP_')) { $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); $k = strtolower(substr($k, 5)); } else { @@ -4128,7 +4128,7 @@ private function invoke_method() return; } } else { - $method_to_compare = ('4.' === substr(phpversion(), 0, 2)) ? strtolower($method) : $method; + $method_to_compare = (0 === strpos(phpversion(), '4.')) ? strtolower($method) : $method; if (!in_array($method_to_compare, get_class_methods($class))) { $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!"); $this->result = 'fault: method not found'; From 263a85aadf7f819838ddd46a6afd3b36d2a3bc9b Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 11 Jun 2018 04:20:02 -0400 Subject: [PATCH 35/40] PHPDoc --- src/nusoap.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index 63fe441..47a874c 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -2781,11 +2781,11 @@ public function setEncoding($enc = 'gzip, deflate') /** * set proxy info here * - * @param string $proxyhost use an empty string to remove proxy - * @param string $proxyport - * @param string $proxyusername - * @param string $proxypassword - * @param string $proxyauthtype (basic|ntlm) + * @param bool|string $proxyhost use an empty string to remove proxy + * @param bool|string $proxyport + * @param bool|string $proxyusername + * @param bool|string $proxypassword + * @param bool|string $proxyauthtype (basic|ntlm) * @access public */ public function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') @@ -6722,7 +6722,7 @@ class nusoap_parser extends nusoap_base * * @param string $xml SOAP message * @param string $encoding character encoding scheme of message - * @param string $method method for which XML is parsed (unused?) + * @param string|array $method method for which XML is parsed (unused?) * @param bool|string $decode_utf8 whether to decode UTF-8 to ISO-8859-1 * @access public */ @@ -7385,7 +7385,7 @@ class nusoap_client extends nusoap_base * fault related variables */ /** - * @var string $fault + * @var string|bool $fault * @access public */ public $fault; From 538bacfd227d484034b86b3faf54213112f7b2cd Mon Sep 17 00:00:00 2001 From: mambax7 Date: Mon, 11 Jun 2018 22:15:20 -0400 Subject: [PATCH 36/40] cosmetics --- src/nusoap.php | 484 ++++++++++++++++++++++--------------------------- 1 file changed, 221 insertions(+), 263 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index 47a874c..72c6244 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -1,7 +1,6 @@ * @author Scott Nichol - * @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $ * @access public */ class nusoap_base @@ -476,7 +474,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal $this->debug('serialize_val: serialize null'); if ('literal' === $use) { // TODO: depends on minOccurs - $xml = "<$name$xmlns$atts/>"; + $xml = "<$name$xmlns$atts>"; $this->debug("serialize_val returning $xml"); return $xml; } else { @@ -485,7 +483,7 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } else { $type_str = ''; } - $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>"; + $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\">"; $this->debug("serialize_val returning $xml"); return $xml; } @@ -571,10 +569,9 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal $pXml = isset($pXml) ? $pXml . $this->serialize_val($v, $k, false, false, false, false, $use) : $this->serialize_val($v, $k, false, false, false, false, $use); } } + $type_str = ''; if (isset($type) && isset($type_prefix)) { $type_str = " xsi:type=\"$type_prefix:$type\""; - } else { - $type_str = ''; } if ('literal' === $use) { $xml .= "<$name$xmlns$atts>$pXml"; @@ -636,12 +633,11 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } // empty array } else { + $type_str = ' xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[0]"'; if ('literal' === $use) { $type_str = ''; } elseif (isset($type) && isset($type_prefix)) { $type_str = " xsi:type=\"$type_prefix:$type\""; - } else { - $type_str = ' xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[0]"'; } } // TODO: for array in literal, there is no wrapper here @@ -649,10 +645,9 @@ public function serialize_val($val, $name = false, $type = false, $name_ns = fal } else { // got a struct $this->debug('serialize_val: serialize struct'); + $type_str = ''; if (isset($type) && isset($type_prefix)) { $type_str = " xsi:type=\"$type_prefix:$type\""; - } else { - $type_str = ''; } if ('literal' === $use) { $xml .= "<$name$xmlns$atts>"; @@ -773,10 +768,11 @@ protected function contractQName($qname) if ($p) { return $p . ':' . $name; } - return $qname; - } else { + return $qname; } + + return $qname; } /** @@ -1029,37 +1025,31 @@ function usleepWindows($usec) * Contains information for a SOAP fault. * Mainly used for returning faults from deployed functions * in a server instance. - * * @author Dietrich Ayala - * @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $ * @access public */ class nusoap_fault extends nusoap_base { /** * The fault code (client|server) - * * @var string * @access private */ private $faultcode; /** * The fault actor - * * @var string * @access private */ private $faultactor; /** * The fault string, a description of the fault - * * @var string * @access private */ private $faultstring; /** * The fault detail, typically a string or array of string - * * @var mixed * @access private */ @@ -1125,7 +1115,6 @@ class soap_fault extends nusoap_fault * * @author Dietrich Ayala * @author Scott Nichol - * @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $ * @access public */ class nusoap_xmlschema extends nusoap_base @@ -1165,7 +1154,7 @@ class nusoap_xmlschema extends nusoap_base * * @param string $schema schema document URI * @param string $xml xml document URI - * @param array $namespaces namespaces defined in enclosing XML + * @param array|string $namespaces namespaces defined in enclosing XML * @access public */ public function __construct($schema = '', $xml = '', $namespaces = []) @@ -1211,13 +1200,14 @@ public function parseFile($xml, $type) $this->setError($msg); $this->debug($msg); return false; - } else { + } + $this->debug("parsing $xml"); $this->parseString($xmlStr, $type); $this->debug("done parsing $xml"); return true; } - } + return false; } @@ -1281,7 +1271,7 @@ private function parseString($xml, $type) private function CreateTypeName($ename) { $scope = ''; - for ($i = 0, $iMax = count($this->complexTypeStack); $i < $iMax; $i++) { + for ($i = 0, $iMax = count($this->complexTypeStack); $i < $iMax; ++$i) { $scope .= $this->complexTypeStack[$i] . '_'; } return $scope . $ename . '_ContainedType'; @@ -1384,10 +1374,9 @@ public function schemaStartElement($parser, $name, $attrs) $this->attributes[$attrs['name']] = $attrs; $aname = $attrs['name']; } elseif (isset($attrs['ref']) && 'http://schemas.xmlsoap.org/soap/encoding/:arrayType' === $attrs['ref']) { + $aname = ''; if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; - } else { - $aname = ''; } } elseif (isset($attrs['ref'])) { $aname = $attrs['ref']; @@ -1398,13 +1387,13 @@ public function schemaStartElement($parser, $name, $attrs) $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; } // arrayType attribute - if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || 'arrayType' === $this->getLocalPart($aname)) { + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) + || 'arrayType' === $this->getLocalPart($aname)) { $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; $prefix = $this->getPrefix($aname); + $v = ''; if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; - } else { - $v = ''; } if (strpos($v, '[,]')) { $this->complexTypes[$this->currentComplexType]['multidimensional'] = true; @@ -1433,7 +1422,7 @@ public function schemaStartElement($parser, $name, $attrs) // // // + // minOccurs="0" maxOccurs="unbounded" > // // if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) { @@ -1453,7 +1442,7 @@ public function schemaStartElement($parser, $name, $attrs) // // // + // minOccurs="0" maxOccurs="unbounded" > // // if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) { @@ -1487,7 +1476,7 @@ public function schemaStartElement($parser, $name, $attrs) // // // + // minOccurs="0" maxOccurs="unbounded" > // // if ($this->currentComplexType && 'array' === $this->complexTypes[$this->currentComplexType]['phpType']) { @@ -1682,10 +1671,10 @@ public function serializeSchema() if (is_array($this->imports) && count($this->imports) > 0) { foreach ($this->imports as $ns => $list) { foreach ($list as $ii) { - if ('' != $ii['location']) { - $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; + if ('' !== $ii['location']) { + $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" >\n"; } else { - $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; + $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" >\n"; } } } @@ -1697,7 +1686,7 @@ public function serializeSchema() if (isset($attrs['elements']) && (count($attrs['elements']) > 0)) { foreach ($attrs['elements'] as $element => $eParts) { if (isset($eParts['ref'])) { - $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; + $contentStr .= " <$schemaPrefix:element ref=\"$element\">\n"; } else { $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . '"'; foreach ($eParts as $aName => $aValue) { @@ -1706,11 +1695,11 @@ public function serializeSchema() $contentStr .= " $aName=\"$aValue\""; } } - $contentStr .= "/>\n"; + $contentStr .= ">\n"; } } // compositor wraps elements - if (isset($attrs['compositor']) && ('' != $attrs['compositor'])) { + if (isset($attrs['compositor']) && ('' !== $attrs['compositor'])) { $contentStr = " <$schemaPrefix:$attrs[compositor]>\n" . $contentStr . " \n"; } } @@ -1728,11 +1717,11 @@ public function serializeSchema() $contentStr .= " $a=\"$v\""; } } - $contentStr .= "/>\n"; + $contentStr .= ">\n"; } } // if restriction - if (isset($attrs['restrictionBase']) && '' != $attrs['restrictionBase']) { + if (isset($attrs['restrictionBase']) && '' !== $attrs['restrictionBase']) { $contentStr = " <$schemaPrefix:restriction base=\"" . $this->contractQName($attrs['restrictionBase']) . "\">\n" . $contentStr . " \n"; // complex or simple content if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)) { @@ -1740,10 +1729,10 @@ public function serializeSchema() } } // finalize complex type - if ('' != $contentStr) { + if ('' !== $contentStr) { $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n" . $contentStr . " \n"; } else { - $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; + $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n"; } $xml .= $contentStr; } @@ -1753,7 +1742,7 @@ public function serializeSchema() $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"" . $this->contractQName($eParts['type']) . "\">\n"; if (isset($eParts['enumeration'])) { foreach ($eParts['enumeration'] as $e) { - $xml .= " <$schemaPrefix:enumeration value=\"$e\"/>\n"; + $xml .= " <$schemaPrefix:enumeration value=\"$e\">\n"; } } $xml .= " \n "; @@ -1762,13 +1751,13 @@ public function serializeSchema() // elements if (isset($this->elements) && count($this->elements) > 0) { foreach ($this->elements as $element => $eParts) { - $xml .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"/>\n"; + $xml .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\">\n"; } } // attributes if (isset($this->attributes) && count($this->attributes) > 0) { foreach ($this->attributes as $attr => $aParts) { - $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"" . $this->contractQName($aParts['type']) . "\"\n/>"; + $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"" . $this->contractQName($aParts['type']) . "\"\n>"; } } // finish 'er up @@ -1814,7 +1803,9 @@ public function getPHPType($type, $ns) if (isset($this->typemap[$ns][$type])) { //print "found type '$type' and ns $ns in typemap
"; return $this->typemap[$ns][$type]; - } elseif (isset($this->complexTypes[$type])) { + } + + if (isset($this->complexTypes[$type])) { //print "getting type '$type' and ns $ns from complexTypes array
"; return $this->complexTypes[$type]['phpType']; } @@ -1856,7 +1847,9 @@ public function getTypeDef($type) if ((!$is_element) && isset($this->complexTypes[$type])) { $this->xdebug("in getTypeDef, found complexType $type"); return $this->complexTypes[$type]; - } elseif ((!$is_element) && isset($this->simpleTypes[$type])) { + } + + if ((!$is_element) && isset($this->simpleTypes[$type])) { $this->xdebug("in getTypeDef, found simpleType $type"); if (!isset($this->simpleTypes[$type]['phpType'])) { // get info for type to tack onto the simple type @@ -1943,7 +1936,7 @@ public function serializeTypeDef($type) } elseif ('element' === $typeDef['typeClass']) { $str .= ">"; } else { - $str .= '/>'; + $str .= '>'; } return $str; } @@ -1976,7 +1969,7 @@ public function typeToForm($name, $type) // if array } elseif ('array' === $typeDef['phpType']) { $buffer .= '
'; - for ($i = 0; $i < 3; $i++) { + for ($i = 0; $i < 3; ++$i) { $buffer .= " "; @@ -2130,14 +2123,14 @@ class soapval extends nusoap_base * @var mixed * @access private */ - private $type; + public $type; /** * The PHP value * * @var mixed * @access private */ - private $value; + public $value; /** * The XML element namespace (string or false) * @@ -2151,14 +2144,14 @@ class soapval extends nusoap_base * @var mixed * @access private */ - private $type_ns; + public $type_ns; /** * The XML element attributes (array or false) * * @var mixed * @access private */ - private $attributes; + public $attributes; /** * constructor @@ -2213,7 +2206,6 @@ public function decode() * * @author Dietrich Ayala * @author Scott Nichol - * @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $ * @access public */ class soap_transport_http extends nusoap_base @@ -2333,16 +2325,15 @@ private function setURL($url) } // add any GET params to path - if (isset($u['query']) && '' != $u['query']) { + if (isset($u['query']) && '' !== $u['query']) { $this->path .= '?' . $u['query']; } // set default port if (!isset($u['port'])) { + $this->port = 80; if ('https' === $u['scheme']) { $this->port = 443; - } else { - $this->port = 80; } } @@ -2356,7 +2347,7 @@ private function setURL($url) $this->setHeader('Host', $this->host . ':' . $this->port); } - if (isset($u['user']) && '' != $u['user']) { + if (isset($u['user']) && '' !== $u['user']) { $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : ''); } } @@ -2393,7 +2384,7 @@ private function connect($connection_timeout = 0, $response_timeout = 30) // TODO: disabled for now because OpenSSL must be *compiled* in (not just // loaded), and until PHP5 stream_get_wrappers is not available. // if ($this->scheme == 'https') { - // if (version_compare(phpversion(), '4.3.0') >= 0) { + // if (version_compare(PHP_VERSION, '4.3.0') >= 0) { // if (extension_loaded('openssl')) { // $this->scheme = 'ssl'; // $this->debug('Using SSL over OpenSSL'); @@ -2452,49 +2443,43 @@ private function connect($connection_timeout = 0, $response_timeout = 30) $this->debug('socket connected'); return true; - } elseif ('curl' === $this->io_method()) { + if ('curl' === $this->io_method()) { if (!extension_loaded('curl')) { // $this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS'); $this->setError('The PHP cURL Extension is required for HTTPS or NLTM. You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.'); return false; } // Avoid warnings when PHP does not have these options + $CURLOPT_CONNECTIONTIMEOUT = 78; if (defined('CURLOPT_CONNECTIONTIMEOUT')) { $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT; - } else { - $CURLOPT_CONNECTIONTIMEOUT = 78; } + $CURLOPT_HTTPAUTH = 107; if (defined('CURLOPT_HTTPAUTH')) { $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH; - } else { - $CURLOPT_HTTPAUTH = 107; } + $CURLOPT_PROXYAUTH = 111; if (defined('CURLOPT_PROXYAUTH')) { $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH; - } else { - $CURLOPT_PROXYAUTH = 111; } + $CURLAUTH_BASIC = 1; if (defined('CURLAUTH_BASIC')) { $CURLAUTH_BASIC = CURLAUTH_BASIC; - } else { - $CURLAUTH_BASIC = 1; } + $CURLAUTH_DIGEST = 2; if (defined('CURLAUTH_DIGEST')) { $CURLAUTH_DIGEST = CURLAUTH_DIGEST; - } else { - $CURLAUTH_DIGEST = 2; } + $CURLAUTH_NTLM = 8; if (defined('CURLAUTH_NTLM')) { $CURLAUTH_NTLM = CURLAUTH_NTLM; - } else { - $CURLAUTH_NTLM = 8; } $this->debug('connect using cURL'); // init CURL $this->ch = curl_init(); // set url - $hostURL = ('' != $this->port) ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host"; + $hostURL = ('' !== $this->port) ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host"; // add path $hostURL .= $this->path; $this->setCurlOption(CURLOPT_URL, $hostURL); @@ -2586,7 +2571,7 @@ private function connect($connection_timeout = 0, $response_timeout = 30) } if (is_array($this->proxy)) { $this->debug('set cURL proxy options'); - if ('' != $this->proxy['port']) { + if ('' !== $this->proxy['port']) { $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'] . ':' . $this->proxy['port']); } else { $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']); @@ -2615,8 +2600,8 @@ private function connect($connection_timeout = 0, $response_timeout = 30) * sends the SOAP request and gets the SOAP response via HTTP[S] * * @param string $data message data - * @param integer $timeout set connection timeout in seconds - * @param integer $response_timeout set response timeout in seconds + * @param int $timeout set connection timeout in seconds + * @param int $response_timeout set response timeout in seconds * @param array $cookies cookies to send * @return string data * @access public @@ -2629,7 +2614,7 @@ public function send($data, $timeout = 0, $response_timeout = 30, $cookies = nul $tries = 0; while ($this->tryagain) { $this->tryagain = false; - if ($tries++ < 2) { + if (++$tries < 2) { // make connnection if (!$this->connect($timeout, $response_timeout)) { return false; @@ -2655,8 +2640,8 @@ public function send($data, $timeout = 0, $response_timeout = 30, $cookies = nul * sends the SOAP request and gets the SOAP response via HTTPS using CURL * * @param string $data message data - * @param integer $timeout set connection timeout in seconds - * @param integer $response_timeout set response timeout in seconds + * @param int $timeout set connection timeout in seconds + * @param int $response_timeout set response timeout in seconds * @param array $cookies cookies to send * @return string data * @access public @@ -2718,7 +2703,7 @@ public function setCredentials($username, $password, $authtype = 'basic', $diges $unhashedDigest = ''; $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : ''; $cnonce = $nonce; - if ('' != $digestRequest['qop']) { + if ('' !== $digestRequest['qop']) { $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf('%08d', $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2; } else { $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2; @@ -2798,7 +2783,7 @@ public function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypass 'password' => $proxypassword, 'authtype' => $proxyauthtype ]; - if ('' != $proxyusername && '' != $proxypassword && $proxyauthtype = 'basic') { + if ('' !== $proxyusername && '' !== $proxypassword && $proxyauthtype = 'basic') { $this->setHeader('Proxy-Authorization', ' Basic ' . base64_encode($proxyusername . ':' . $proxypassword)); } } else { @@ -2859,7 +2844,7 @@ public function decodeChunked($buffer, $lb) // read chunk-size, chunk-extension (if any) and CRLF // get the position of the linebreak $chunkend = strpos($buffer, $lb); - if (false == $chunkend) { + if (false === $chunkend) { $this->debug('no linebreak found in decodeChunked'); return $new; } @@ -2872,7 +2857,7 @@ public function decodeChunked($buffer, $lb) $chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size); // Just in case we got a broken connection - if (false == $chunkend) { + if (false === $chunkend) { $chunk = substr($buffer, $chunkstart); // append chunk-data to entity-body $new .= $chunk; @@ -2890,7 +2875,7 @@ public function decodeChunked($buffer, $lb) $chunkstart = $chunkend + strlen($lb); $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb); - if (false == $chunkend) { + if (false === $chunkend) { break; //Just in case we got a broken connection } $temp = substr($buffer, $chunkstart, $chunkend - $chunkstart); @@ -2937,7 +2922,7 @@ private function buildPayload($data, $cookie_str = '') } // add any cookies - if ('' != $cookie_str) { + if ('' !== $cookie_str) { $hdr = 'Cookie: ' . $cookie_str; $this->debug("HTTP header: $hdr"); $this->outgoing_payload .= "$hdr\r\n"; @@ -2975,7 +2960,9 @@ private function sendRequest($data, $cookies = null) } $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload)); return true; - } elseif ('curl' === $this->io_method()) { + } + + if ('curl' === $this->io_method()) { // set payload // cURL does say this should only be the verb, and in fact it // turns out that the URI and HTTP version are appended to this, which @@ -2983,13 +2970,14 @@ private function sendRequest($data, $cookies = null) //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload); $curl_headers = []; foreach ($this->outgoing_headers as $k => $v) { - if ('Connection' === $k || 'Content-Length' === $k || 'Host' === $k || 'Authorization' === $k || 'Proxy-Authorization' === $k) { + if ('Connection' === $k || 'Content-Length' === $k || 'Host' === $k || 'Authorization' === $k + || 'Proxy-Authorization' === $k) { $this->debug("Skip cURL header $k: $v"); } else { $curl_headers[] = "$k: $v"; } } - if ('' != $cookie_str) { + if ('' !== $cookie_str) { $curl_headers[] = 'Cookie: ' . $cookie_str; } $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers); @@ -3158,17 +3146,15 @@ private function getResponse() $this->debug('received a total of ' . strlen($this->incoming_payload) . ' bytes of data from server'); // close filepointer - if ( - (isset($this->incoming_headers['connection']) && 'close' === strtolower($this->incoming_headers['connection'])) || - (!$this->persistentConnection) || feof($this->fp) - ) { + if ((isset($this->incoming_headers['connection']) && 'close' === strtolower($this->incoming_headers['connection'])) + || (!$this->persistentConnection) || feof($this->fp)) { fclose($this->fp); $this->fp = false; $this->debug('closed socket'); } // connection was closed unexpectedly - if ('' == $this->incoming_payload) { + if ('' === $this->incoming_payload) { $this->setError('no response from server'); return false; } @@ -3190,7 +3176,7 @@ private function getResponse() $data = $this->incoming_payload; $cErr = curl_error($this->ch); - if ('' != $cErr) { + if ('' !== $cErr) { $err = 'cURL ERROR: ' . curl_errno($this->ch) . ': ' . $cErr . '
'; // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE foreach (curl_getinfo($this->ch) as $k => $v) { @@ -3200,11 +3186,11 @@ private function getResponse() $this->setError($err); curl_close($this->ch); return false; - } else { + } + //echo '
';
                 //var_dump(curl_getinfo($this->ch));
                 //echo '
'; - } // close curl $this->debug('No cURL error, closing cURL'); curl_close($this->ch); @@ -3220,7 +3206,7 @@ private function getResponse() } } - if ('' == $data) { + if ('' === $data) { // have nothing left; just remove 100 header(s) $data = $savedata; while (preg_match('/^HTTP\/1.1 100/', $data)) { @@ -3321,7 +3307,7 @@ private function getResponse() } // decode content-encoding - if (isset($this->incoming_headers['content-encoding']) && '' != $this->incoming_headers['content-encoding']) { + if (isset($this->incoming_headers['content-encoding']) && '' !== $this->incoming_headers['content-encoding']) { if ('deflate' === strtolower($this->incoming_headers['content-encoding']) || 'gzip' === strtolower($this->incoming_headers['content-encoding'])) { // if decoding works, use it. else assume data wasn't gzencoded if (function_exists('gzinflate')) { @@ -3379,7 +3365,7 @@ private function getResponse() $this->debug('No Content-Encoding header'); } - if (0 == strlen($data)) { + if (0 === strlen($data)) { $this->debug('no data after headers!'); $this->setError('no data present after HTTP headers'); return false; @@ -3461,10 +3447,9 @@ private function parseCookie($cookie_str) } $cookie_param = ';secure;'; + $secure = false; if (false !== strpos($cookie_str, $cookie_param)) { $secure = true; - } else { - $secure = false; } $sep_pos = strpos($value_str, '='); @@ -3502,27 +3487,27 @@ private function getCookiesForRequest($cookies, $secure = false) continue; } $this->debug('check cookie for validity: ' . $cookie['name'] . '=' . $cookie['value']); - if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) { + if (isset($cookie['expires']) && !empty($cookie['expires'])) { if (strtotime($cookie['expires']) <= time()) { $this->debug('cookie has expired'); continue; } } - if ((isset($cookie['domain'])) && (!empty($cookie['domain']))) { + if (isset($cookie['domain']) && !empty($cookie['domain'])) { $domain = preg_quote($cookie['domain']); if (!preg_match("'.*$domain$'i", $this->host)) { $this->debug('cookie has different domain'); continue; } } - if ((isset($cookie['path'])) && (!empty($cookie['path']))) { + if (isset($cookie['path']) && !empty($cookie['path'])) { $path = preg_quote($cookie['path']); if (!preg_match("'^$path.*'i", $this->path)) { $this->debug('cookie is for a different path'); continue; } } - if ((!$secure) && (isset($cookie['secure'])) && ($cookie['secure'])) { + if ((!$secure) && isset($cookie['secure']) && $cookie['secure']) { $this->debug('cookie is secure, transport is not'); continue; } @@ -3542,7 +3527,6 @@ private function getCookiesForRequest($cookies, $secure = false) * * @author Dietrich Ayala * @author Scott Nichol - * @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $ * @access public */ class nusoap_server extends nusoap_base @@ -3898,10 +3882,9 @@ private function parse_http_headers() // get the character encoding of the incoming request if (isset($this->headers['content-type']) && strpos($this->headers['content-type'], '=')) { $enc = str_replace('"', '', substr(strstr($this->headers['content-type'], '='), 1)); + $this->xml_encoding = 'US-ASCII'; if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { $this->xml_encoding = strtoupper($enc); - } else { - $this->xml_encoding = 'US-ASCII'; } } else { // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 @@ -3927,10 +3910,9 @@ private function parse_http_headers() $enc = substr(strstr($v, '='), 1); $enc = str_replace('"', '', $enc); $enc = str_replace('\\', '', $enc); + $this->xml_encoding = 'US-ASCII'; if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { $this->xml_encoding = strtoupper($enc); - } else { - $this->xml_encoding = 'US-ASCII'; } } else { // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 @@ -3963,10 +3945,9 @@ private function parse_http_headers() $enc = substr(strstr($v, '='), 1); $enc = str_replace('"', '', $enc); $enc = str_replace('\\', '', $enc); + $this->xml_encoding = 'US-ASCII'; if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { $this->xml_encoding = strtoupper($enc); - } else { - $this->xml_encoding = 'US-ASCII'; } } else { // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 @@ -4011,7 +3992,7 @@ private function parse_request($data = '') $this->parse_http_headers(); $this->debug('got character encoding: ' . $this->xml_encoding); // uncompress if necessary - if (isset($this->headers['content-encoding']) && '' != $this->headers['content-encoding']) { + if (isset($this->headers['content-encoding']) && '' !== $this->headers['content-encoding']) { $this->debug('got content encoding: ' . $this->headers['content-encoding']); if ('deflate' === $this->headers['content-encoding'] || 'gzip' === $this->headers['content-encoding']) { // if decoding works, use it. else assume data wasn't gzencoded @@ -4089,12 +4070,11 @@ private function invoke_method() // if a . is present in $this->methodname, we see if there is a class in scope, // which could be referred to. We will also distinguish between two deliminators, // to allow methods to be called a the class or an instance + $delim = ''; if (strpos($this->methodname, '..') > 0) { $delim = '..'; } elseif (strpos($this->methodname, '.') > 0) { $delim = '.'; - } else { - $delim = ''; } $this->debug("in invoke_method, delim=$delim"); @@ -4120,7 +4100,7 @@ private function invoke_method() } // does method exist? - if ('' == $class) { + if ('' === $class) { if (!function_exists($this->methodname)) { $this->debug("in invoke_method, function '$this->methodname' not found!"); $this->result = 'fault: method not found'; @@ -4128,7 +4108,7 @@ private function invoke_method() return; } } else { - $method_to_compare = (0 === strpos(phpversion(), '4.')) ? strtolower($method) : $method; + $method_to_compare = (0 === strpos(PHP_VERSION, '4.')) ? strtolower($method) : $method; if (!in_array($method_to_compare, get_class_methods($class))) { $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!"); $this->result = 'fault: method not found'; @@ -4153,7 +4133,7 @@ private function invoke_method() $this->appendDebug($this->varDump($this->methodparams)); $this->debug("in invoke_method, calling '$this->methodname'"); if (!function_exists('call_user_func_array')) { - if ('' == $class) { + if ('' === $class) { $this->debug('in invoke_method, calling function using eval()'); $funcCall = "\$this->methodreturn = $this->methodname("; } else { @@ -4182,7 +4162,7 @@ private function invoke_method() $this->debug('in invoke_method, function call: ' . $funcCall); @eval($funcCall); } else { - if ('' == $class) { + if ('' === $class) { $this->debug('in invoke_method, calling function using call_user_func_array()'); $call_arg = $this->methodname; // straight assignment changes $this->methodname to lower case after call_user_func_array() } elseif ('..' === $delim) { @@ -4219,11 +4199,15 @@ private function serialize_return() { $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI); // if fault - if (isset($this->methodreturn) && is_object($this->methodreturn) && (('soap_fault' === get_class($this->methodreturn)) || ('nusoap_fault' === get_class($this->methodreturn)))) { + if (isset($this->methodreturn) && is_object($this->methodreturn) + && (($this->methodreturn instanceof \Soap_fault) + || ('nusoap_fault' === get_class($this->methodreturn)))) { $this->debug('got a fault object from method'); $this->fault = $this->methodreturn; return; - } elseif ($this->methodreturnisliteralxml) { + } + + if ($this->methodreturnisliteralxml) { $return_val = $this->methodreturn; // returned value(s) } else { @@ -4293,10 +4277,9 @@ private function serialize_return() //if($this->debug_flag){ $this->appendDebug($this->wsdl->getDebug()); // } + $encodingStyle = ''; if (isset($this->opData['output']['encodingStyle'])) { $encodingStyle = $this->opData['output']['encodingStyle']; - } else { - $encodingStyle = ''; } // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces. $this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders, $this->wsdl->usedNamespaces, $this->opData['style'], $this->opData['output']['use'], $encodingStyle); @@ -4431,10 +4414,9 @@ private function parseRequest($headers, $data) if (strpos($headers['content-type'], '=')) { $enc = str_replace('"', '', substr(strstr($headers['content-type'], '='), 1)); $this->debug('Got response encoding: ' . $enc); + $this->xml_encoding = 'US-ASCII'; if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { $this->xml_encoding = strtoupper($enc); - } else { - $this->xml_encoding = 'US-ASCII'; } } else { // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 @@ -4550,9 +4532,9 @@ public function register($name, $in = [], $out = [], $namespace = false, $soapac if (!is_array($out)) { die('You must provide an array for operation outputs'); } - if (false == $namespace) { + if (false === $namespace) { } - if (false == $soapaction) { + if (false === $soapaction) { if (isset($_SERVER)) { $SERVER_NAME = $_SERVER['SERVER_NAME']; $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; @@ -4564,20 +4546,19 @@ public function register($name, $in = [], $out = [], $namespace = false, $soapac } else { $this->setError('Neither _SERVER nor HTTP_SERVER_VARS is available'); } + $SCHEME = 'http'; if ('1' == $HTTPS || 'on' === $HTTPS) { $SCHEME = 'https'; - } else { - $SCHEME = 'http'; } $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name"; } - if (false == $style) { + if (false === $style) { $style = 'rpc'; } - if (false == $use) { + if (false === $use) { $use = 'encoded'; } - if ('encoded' === $use && '' == $encodingStyle) { + if ('encoded' === $use && '' === $encodingStyle) { $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; } @@ -4607,7 +4588,7 @@ public function register($name, $in = [], $out = [], $namespace = false, $soapac */ public function fault($faultcode, $faultstring, $faultactor = '', $faultdetail = '') { - if ('' == $faultdetail && $this->debug_flag) { + if ('' === $faultdetail && $this->debug_flag) { $faultdetail = $this->getDebug(); } $this->fault = new nusoap_fault($faultcode, $faultactor, $faultstring, $faultdetail); @@ -4652,20 +4633,19 @@ public function configureWSDL($serviceName, $namespace = false, $endpoint = fals } else { $SERVER_PORT = ':' . $SERVER_PORT; } - if (false == $namespace) { + if (false === $namespace) { $namespace = "http://$SERVER_NAME/soap/$serviceName"; } - if (false == $endpoint) { + if (false === $endpoint) { + $SCHEME = 'http'; if ('1' == $HTTPS || 'on' === $HTTPS) { $SCHEME = 'https'; - } else { - $SCHEME = 'http'; } $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME"; } - if (false == $schemaTargetNamespace) { + if (false === $schemaTargetNamespace) { $schemaTargetNamespace = $namespace; } @@ -4713,7 +4693,6 @@ class soap_server extends nusoap_server * * @author Dietrich Ayala * @author Scott Nichol - * @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $ * @access public */ class wsdl extends nusoap_base @@ -4768,8 +4747,8 @@ class wsdl extends nusoap_base * @param bool|string $proxyport * @param bool|string $proxyusername * @param bool|string $proxypassword - * @param integer $timeout set the connection timeout - * @param integer $response_timeout set the response timeout + * @param int $timeout set the connection timeout + * @param int $response_timeout set the response timeout * @param array $curl_options user-specified cURL options * @param boolean $use_curl try to use cURL * @access public @@ -4802,7 +4781,7 @@ public function fetchWSDL($wsdl) $this->debug("parse and process WSDL path=$wsdl"); $this->wsdl = $wsdl; // parse wsdl file - if ('' != $this->wsdl) { + if ('' !== $this->wsdl) { $this->parseWSDL($this->wsdl); } // imports @@ -4816,11 +4795,11 @@ public function fetchWSDL($wsdl) foreach ($list as $xs) { $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! foreach ($xs->imports as $ns2 => $list2) { - for ($ii = 0, $iiMax = count($list2); $ii < $iiMax; $ii++) { + for ($ii = 0, $iiMax = count($list2); $ii < $iiMax; ++$ii) { if (!$list2[$ii]['loaded']) { $this->schemas[$ns][$ns2]->imports[$ns2][$ii]['loaded'] = true; $url = $list2[$ii]['location']; - if ('' != $url) { + if ('' !== $url) { $urlparts = parse_url($url); if (!isset($urlparts['host'])) { $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . @@ -4828,7 +4807,7 @@ public function fetchWSDL($wsdl) } if (!in_array($url, $imported_urls)) { $this->parseWSDL($url); - $imported++; + ++$imported; $imported_urls[] = $url; } } else { @@ -4842,11 +4821,11 @@ public function fetchWSDL($wsdl) // WSDL imports $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! foreach ($this->import as $ns => $list) { - for ($ii = 0, $iiMax = count($list); $ii < $iiMax; $ii++) { + for ($ii = 0, $iiMax = count($list); $ii < $iiMax; ++$ii) { if (!$list[$ii]['loaded']) { $this->import[$ns][$ii]['loaded'] = true; $url = $list[$ii]['location']; - if ('' != $url) { + if ('' !== $url) { $urlparts = parse_url($url); if (!isset($urlparts['host'])) { $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . @@ -4854,7 +4833,7 @@ public function fetchWSDL($wsdl) } if (!in_array($url, $imported_urls)) { $this->parseWSDL($url); - $imported++; + ++$imported; $imported_urls[] = $url; } } else { @@ -4906,7 +4885,7 @@ private function parseWSDL($wsdl = '') { $this->debug("parse WSDL at path=$wsdl"); - if ('' == $wsdl) { + if ('' === $wsdl) { $this->debug('no wsdl passed to parseWSDL()!!'); $this->setError('no wsdl passed to parseWSDL()!!'); return false; @@ -4924,7 +4903,7 @@ private function parseWSDL($wsdl = '') if ($this->proxyhost && $this->proxyport) { $tr->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword); } - if ('' != $this->authtype) { + if ('' !== $this->authtype) { $tr->setCredentials($this->username, $this->password, $this->authtype, [], $this->certRequest); } $tr->setEncoding('gzip, deflate'); @@ -4944,10 +4923,9 @@ private function parseWSDL($wsdl = '') $this->debug('got WSDL URL'); } else { // $wsdl is not http(s), so treat it as a file URL or plain file path + $path = $wsdl; if (isset($wsdl_props['scheme']) && ('file' === $wsdl_props['scheme']) && isset($wsdl_props['path'])) { $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path']; - } else { - $path = $wsdl; } $this->debug('getting WSDL file ' . $path); if (false !== ($fp = @fopen($path, 'r'))) { @@ -5323,7 +5301,7 @@ public function getOperations($portName = '', $bindingType = 'soap') // loop thru ports foreach ($this->ports as $port => $portData) { $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']); - if ('' == $portName || $port == $portName) { + if ('' === $portName || $port == $portName) { // binding type of port matches parameter if ($portData['bindingType'] == $bindingType) { $this->debug("getOperations found port $port bindingType $bindingType"); @@ -5336,7 +5314,7 @@ public function getOperations($portName = '', $bindingType = 'soap') } } } - if (0 == count($ops)) { + if (0 === count($ops)) { $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType"); } return $ops; @@ -5439,8 +5417,8 @@ public function getTypeDef($type, $ns) } if (isset($this->schemas[$ns])) { $this->debug("in getTypeDef: have schema for namespace $ns"); - for ($i = 0, $iMax = count($this->schemas[$ns]); $i < $iMax; $i++) { - $xs = &$this->schemas[$ns][$i]; + for ($i = 0, $iMax = count($this->schemas[$ns]); $i < $iMax; ++$i) { + $xs = $this->schemas[$ns][$i]; $t = $xs->getTypeDef($type); $this->appendDebug($xs->getDebug()); $xs->clearDebug(); @@ -5497,8 +5475,8 @@ public function webDescription() $b = ' NuSOAP: ' . $this->serviceName . '
array item (type: $typeDef[arrayType]):