git://git.onelab.eu
/
plcapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7df27d0
)
Remove usage of 'each' call from tests to make them work w. php 7.2; fix an error...
author
gggeek
<giunta.gaetano@gmail.com>
Sat, 20 Jan 2018 14:06:06 +0000
(14:06 +0000)
committer
gggeek
<giunta.gaetano@gmail.com>
Sat, 20 Jan 2018 14:06:06 +0000
(14:06 +0000)
src/Client.php
patch
|
blob
|
history
src/Encoder.php
patch
|
blob
|
history
src/Server.php
patch
|
blob
|
history
src/Value.php
patch
|
blob
|
history
src/Wrapper.php
patch
|
blob
|
history
tests/1ParsingBugsTest.php
patch
|
blob
|
history
diff --git
a/src/Client.php
b/src/Client.php
index
4279ebc
..
101068b
100644
(file)
--- a/
src/Client.php
+++ b/
src/Client.php
@@
-537,7
+537,6
@@
class Client
$this->proxy_pass,
$this->proxy_authtype,
$method,
$this->proxy_pass,
$this->proxy_authtype,
$method,
- $this->keepalive,
$this->key,
$this->keypass,
$this->sslversion
$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,
$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
$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);
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";
}
}
$encodingHdr = "Content-Encoding: deflate\r\n";
}
}
- } else {
- $encodingHdr = '';
}
// thanks to Grant Rauscher <grant7@firstworld.net> for this
}
// thanks to Grant Rauscher <grant7@firstworld.net> for this
@@
-1260,10
+1258,12
@@
class Client
break;
case 'struct':
$code = $val['faultCode'];
break;
case 'struct':
$code = $val['faultCode'];
+ /** @var Value $code */
if ($code->kindOf() != 'scalar' || $code->scalartyp() != 'int') {
return false;
}
$str = $val['faultString'];
if ($code->kindOf() != 'scalar' || $code->scalartyp() != 'int') {
return false;
}
$str = $val['faultString'];
+ /** @var Value $str */
if ($str->kindOf() != 'scalar' || $str->scalartyp() != 'string') {
return false;
}
if ($str->kindOf() != 'scalar' || $str->scalartyp() != 'string') {
return false;
}
diff --git
a/src/Encoder.php
b/src/Encoder.php
index
495584d
..
b015115
100644
(file)
--- 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
/**
* A helper class to easily convert between Value objects and php native values
+ * @todo implement an interface
*/
class Encoder
{
*/
class Encoder
{
@@
-292,7
+293,9
@@
class Encoder
case 'methodresponse':
$v = &$xmlRpcParser->_xh['value'];
if ($xmlRpcParser->_xh['isf'] == 1) {
case 'methodresponse':
$v = &$xmlRpcParser->_xh['value'];
if ($xmlRpcParser->_xh['isf'] == 1) {
+ /** @var Value $vc */
$vc = $v['faultCode'];
$vc = $v['faultCode'];
+ /** @var Value $vs */
$vs = $v['faultString'];
$r = new Response(0, $vc->scalarval(), $vs->scalarval());
} else {
$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
(file)
--- a/
src/Server.php
+++ b/
src/Server.php
@@
-825,12
+825,22
@@
class Server
return $outAr;
}
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()));
}
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();
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'));
}
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
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;
}
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
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');
}
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') {
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');
}
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)) {
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');
}
return new Value(array($result->value()), 'array');
}
+ /**
+ * @param Server $server
+ * @param Request $req
+ * @return Response
+ */
public static function _xmlrpcs_multicall($server, $req)
{
$result = array();
public static function _xmlrpcs_multicall($server, $req)
{
$result = array();
diff --git
a/src/Value.php
b/src/Value.php
index
8747e69
..
ae73aaa
100644
(file)
--- a/
src/Value.php
+++ b/
src/Value.php
@@
-296,6
+296,7
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
$rs .= "<struct>\n";
}
$charsetEncoder = Charset::instance();
$rs .= "<struct>\n";
}
$charsetEncoder = Charset::instance();
+ /** @var Value $val2 */
foreach ($val as $key2 => $val2) {
$rs .= '<member><name>' . $charsetEncoder->encodeEntities($key2, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</name>\n";
//$rs.=$this->serializeval($val2);
foreach ($val as $key2 => $val2) {
$rs .= '<member><name>' . $charsetEncoder->encodeEntities($key2, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</name>\n";
//$rs.=$this->serializeval($val2);
@@
-307,6
+308,7
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
case 2:
// array
$rs .= "<array>\n<data>\n";
case 2:
// array
$rs .= "<array>\n<data>\n";
+ /** @var Value $element */
foreach ($val as $element) {
//$rs.=$this->serializeval($val[$i]);
$rs .= $element->serialize($charsetEncoding);
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
*
/**
* Implements the IteratorAggregate interface
*
- * @return ArrayIterator
+ * @return
\
ArrayIterator
*/
public function getIterator() {
switch ($this->mytype) {
*/
public function getIterator() {
switch ($this->mytype) {
@@
-493,7
+495,6
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
default:
return new \ArrayIterator();
}
default:
return new \ArrayIterator();
}
- return new \ArrayIterator();
}
public function offsetSet($offset, $value) {
}
public function offsetSet($offset, $value) {
diff --git
a/src/Wrapper.php
b/src/Wrapper.php
index
a45100b
..
bcdd5ef
100644
(file)
--- 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)
* 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)
*
* 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 $callable
* @param array $extraOptions
* @param string $plainFuncName
- * @param
string
$funcDesc
+ * @param
array
$funcDesc
* @return \Closure
*/
protected function buildWrapFunctionClosure($callable, $extraOptions, $plainFuncName, $funcDesc)
{
* @return \Closure
*/
protected function buildWrapFunctionClosure($callable, $extraOptions, $plainFuncName, $funcDesc)
{
+ /**
+ * @param Request $req
+ * @return mixed
+ */
$function = function($req) use($callable, $extraOptions, $funcDesc)
{
$nameSpace = '\\PhpXmlRpc\\';
$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 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?
* @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
(file)
--- a/
tests/1ParsingBugsTest.php
+++ b/
tests/1ParsingBugsTest.php
@@
-629,11
+629,13
@@
and there they were.</value></member><member><name>postid</name><value>7414222</
$v2 = new \PhpXmlRpc\Value(array(new \PhpXmlRpc\Value('one'), new \PhpXmlRpc\Value('two')), 'array');
$this->assertequals(2, count($v2));
$out = array(0 => 'object', 1 => 'object');
$v2 = new \PhpXmlRpc\Value(array(new \PhpXmlRpc\Value('one'), new \PhpXmlRpc\Value('two')), 'array');
$this->assertequals(2, count($v2));
$out = array(0 => 'object', 1 => 'object');
+ $i = 0;
foreach($v2 as $key => $val)
{
foreach($v2 as $key => $val)
{
- $expected =
each($out)
;
+ $expected =
$out[$i]
;
$this->assertequals($expected['key'], $key);
$this->assertequals($expected['value'], gettype($val));
$this->assertequals($expected['key'], $key);
$this->assertequals($expected['value'], gettype($val));
+ $i++;
}
}
}
}
}
}