From: gggeek Date: Sat, 20 Jan 2018 14:06:06 +0000 (+0000) Subject: Remove usage of 'each' call from tests to make them work w. php 7.2; fix an error... X-Git-Tag: 4.3.1~6 X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=1dc0e62829d3238e1181e58774a27cc44e596ef1 Remove usage of 'each' call from tests to make them work w. php 7.2; fix an error when using ssl and non-curl; fix inspections from phpstorm --- diff --git a/src/Client.php b/src/Client.php index 4279ebc..101068b 100644 --- a/src/Client.php +++ b/src/Client.php @@ -537,7 +537,6 @@ class Client $this->proxy_pass, $this->proxy_authtype, $method, - $this->keepalive, $this->key, $this->keypass, $this->sslversion @@ -569,7 +568,7 @@ class Client $method='http') { return $this->sendPayloadSocket($req, $server, $port, $timeout, $username, $password, $authType, null, null, - null, null, $proxyHost, $proxyPort, $proxyUsername, $proxyPassword, $proxyAuthType); + null, null, $proxyHost, $proxyPort, $proxyUsername, $proxyPassword, $proxyAuthType, $method); } /** @@ -645,6 +644,7 @@ class Client $payload = $req->payload; // Deflate request body and set appropriate request headers + $encodingHdr = ''; if (function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) { if ($this->request_compression == 'gzip') { $a = @gzencode($payload); @@ -659,8 +659,6 @@ class Client $encodingHdr = "Content-Encoding: deflate\r\n"; } } - } else { - $encodingHdr = ''; } // thanks to Grant Rauscher for this @@ -1260,10 +1258,12 @@ class Client break; case 'struct': $code = $val['faultCode']; + /** @var Value $code */ if ($code->kindOf() != 'scalar' || $code->scalartyp() != 'int') { return false; } $str = $val['faultString']; + /** @var Value $str */ if ($str->kindOf() != 'scalar' || $str->scalartyp() != 'string') { return false; } diff --git a/src/Encoder.php b/src/Encoder.php index 495584d..b015115 100644 --- a/src/Encoder.php +++ b/src/Encoder.php @@ -6,6 +6,7 @@ use PhpXmlRpc\Helper\XMLParser; /** * A helper class to easily convert between Value objects and php native values + * @todo implement an interface */ class Encoder { @@ -292,7 +293,9 @@ class Encoder case 'methodresponse': $v = &$xmlRpcParser->_xh['value']; if ($xmlRpcParser->_xh['isf'] == 1) { + /** @var Value $vc */ $vc = $v['faultCode']; + /** @var Value $vs */ $vs = $v['faultString']; $r = new Response(0, $vc->scalarval(), $vs->scalarval()); } else { diff --git a/src/Server.php b/src/Server.php index ab17168..49a5483 100644 --- a/src/Server.php +++ b/src/Server.php @@ -825,12 +825,22 @@ class Server return $outAr; } + /** + * @param Server $server + * @param Request $req + * @return Response + */ public static function _xmlrpcs_getCapabilities($server, $req = null) { $encoder = new Encoder(); return new Response($encoder->encode($server->getCapabilities())); } + /** + * @param Server $server + * @param Request $req + * @return Response + */ public static function _xmlrpcs_listMethods($server, $req = null) // if called in plain php values mode, second param is missing { $outAr = array(); @@ -846,6 +856,11 @@ class Server return new Response(new Value($outAr, 'array')); } + /** + * @param Server $server + * @param Request $req + * @return Response + */ public static function _xmlrpcs_methodSignature($server, $req) { // let accept as parameter both an xmlrpc value or string @@ -883,6 +898,11 @@ class Server return $r; } + /** + * @param Server $server + * @param Request $req + * @return Response + */ public static function _xmlrpcs_methodHelp($server, $req) { // let accept as parameter both an xmlrpc value or string @@ -926,6 +946,11 @@ class Server return new Value($struct, 'struct'); } + /** + * @param Server $server + * @param Value $call + * @return Value + */ public static function _xmlrpcs_multicall_do_call($server, $call) { if ($call->kindOf() != 'struct') { @@ -969,6 +994,11 @@ class Server return new Value(array($result->value()), 'array'); } + /** + * @param Server $server + * @param Value $call + * @return Value + */ public static function _xmlrpcs_multicall_do_call_phpvals($server, $call) { if (!is_array($call)) { @@ -1008,6 +1038,11 @@ class Server return new Value(array($result->value()), 'array'); } + /** + * @param Server $server + * @param Request $req + * @return Response + */ public static function _xmlrpcs_multicall($server, $req) { $result = array(); diff --git a/src/Value.php b/src/Value.php index 8747e69..ae73aaa 100644 --- a/src/Value.php +++ b/src/Value.php @@ -296,6 +296,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess $rs .= "\n"; } $charsetEncoder = Charset::instance(); + /** @var Value $val2 */ foreach ($val as $key2 => $val2) { $rs .= '' . $charsetEncoder->encodeEntities($key2, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "\n"; //$rs.=$this->serializeval($val2); @@ -307,6 +308,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess case 2: // array $rs .= "\n\n"; + /** @var Value $element */ foreach ($val as $element) { //$rs.=$this->serializeval($val[$i]); $rs .= $element->serialize($charsetEncoding); @@ -480,7 +482,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess /** * Implements the IteratorAggregate interface * - * @return ArrayIterator + * @return \ArrayIterator */ public function getIterator() { switch ($this->mytype) { @@ -493,7 +495,6 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess default: return new \ArrayIterator(); } - return new \ArrayIterator(); } public function offsetSet($offset, $value) { diff --git a/src/Wrapper.php b/src/Wrapper.php index a45100b..bcdd5ef 100644 --- a/src/Wrapper.php +++ b/src/Wrapper.php @@ -110,7 +110,7 @@ class Wrapper * Since php is a typeless language, to infer types of input and output parameters, * it relies on parsing the javadoc-style comment block associated with the given * function. Usage of xmlrpc native types (such as datetime.dateTime.iso8601 and base64) - * in the @param tag is also allowed, if you need the php function to receive/send + * in the '@param' tag is also allowed, if you need the php function to receive/send * data in that particular format (note that base64 encoding/decoding is transparently * carried out by the lib, while datetime vals are passed around as strings) * @@ -396,11 +396,15 @@ class Wrapper * @param $callable * @param array $extraOptions * @param string $plainFuncName - * @param string $funcDesc + * @param array $funcDesc * @return \Closure */ protected function buildWrapFunctionClosure($callable, $extraOptions, $plainFuncName, $funcDesc) { + /** + * @param Request $req + * @return mixed + */ $function = function($req) use($callable, $extraOptions, $funcDesc) { $nameSpace = '\\PhpXmlRpc\\'; @@ -785,7 +789,7 @@ class Wrapper * @param Client $client * @param string $methodName * @param array $extraOptions - * @param string $mSig + * @param array $mSig * @return \Closure * * @todo should we allow usage of parameter simple_client_copy to mean 'do not clone' in this case? diff --git a/tests/1ParsingBugsTest.php b/tests/1ParsingBugsTest.php index ce463f7..e85586d 100644 --- a/tests/1ParsingBugsTest.php +++ b/tests/1ParsingBugsTest.php @@ -629,11 +629,13 @@ and there they were.postid7414222assertequals(2, count($v2)); $out = array(0 => 'object', 1 => 'object'); + $i = 0; foreach($v2 as $key => $val) { - $expected = each($out); + $expected = $out[$i]; $this->assertequals($expected['key'], $key); $this->assertequals($expected['value'], gettype($val)); + $i++; } } }