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:
751f9c9
)
Fix ArrayIterator interface implementation; remove usage of arraysize(), structsize...
author
gggeek
<giunta.gaetano@gmail.com>
Wed, 17 Jun 2015 22:18:50 +0000
(23:18 +0100)
committer
gggeek
<giunta.gaetano@gmail.com>
Wed, 17 Jun 2015 22:18:50 +0000
(23:18 +0100)
debugger/action.php
patch
|
blob
|
history
demo/client/agesort.php
patch
|
blob
|
history
demo/client/introspect.php
patch
|
blob
|
history
demo/server/proxy.php
patch
|
blob
|
history
demo/server/server.php
patch
|
blob
|
history
doc/api_changes_v4.md
patch
|
blob
|
history
src/Client.php
patch
|
blob
|
history
src/Encoder.php
patch
|
blob
|
history
src/Server.php
patch
|
blob
|
history
src/Value.php
patch
|
blob
|
history
diff --git
a/debugger/action.php
b/debugger/action.php
index
44d8a00
..
5427f67
100644
(file)
--- a/
debugger/action.php
+++ b/
debugger/action.php
@@
-284,7
+284,7
@@
if ($action) {
$v = $response->value();
if ($v->kindOf() == "array") {
$v = $response->value();
if ($v->kindOf() == "array") {
- $max = $v->
arraysize
();
+ $max = $v->
count
();
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
echo "<thead>\n<tr><th>Method ($max)</th><th>Description</th></tr>\n</thead>\n<tbody>\n";
for ($i = 0; $i < $max; $i++) {
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
echo "<thead>\n<tr><th>Method ($max)</th><th>Description</th></tr>\n</thead>\n<tbody>\n";
for ($i = 0; $i < $max; $i++) {
@@
-367,7
+367,7
@@
if ($action) {
if ($x->kindOf() == "array") {
$ret = $x->arraymem(0);
echo "<code>OUT: " . htmlspecialchars($ret->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "<br />IN: (";
if ($x->kindOf() == "array") {
$ret = $x->arraymem(0);
echo "<code>OUT: " . htmlspecialchars($ret->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding) . "<br />IN: (";
- if ($x->
arraysize
() > 1) {
+ if ($x->
count
() > 1) {
for ($k = 1; $k < $x->arraysize(); $k++) {
$y = $x->arraymem($k);
echo htmlspecialchars($y->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding);
for ($k = 1; $k < $x->arraysize(); $k++) {
$y = $x->arraymem($k);
echo htmlspecialchars($y->scalarval(), ENT_COMPAT, \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding);
@@
-389,7
+389,7
@@
if ($action) {
$payload .= "</value></param>\n";
}
$alt_payload .= $y->scalarval();
$payload .= "</value></param>\n";
}
$alt_payload .= $y->scalarval();
- if ($k < $x->
arraysize
() - 1) {
+ if ($k < $x->
count
() - 1) {
$alt_payload .= ';';
echo ", ";
}
$alt_payload .= ';';
echo ", ";
}
@@
-470,7
+470,7
@@
if ($action) {
case 'wrap':
$r1 = $resp[0]->value();
$r2 = $resp[1]->value();
case 'wrap':
$r1 = $resp[0]->value();
$r2 = $resp[1]->value();
- if ($r2->kindOf() != "array" || $r2->
arraysize
() <= $methodsig) {
+ if ($r2->kindOf() != "array" || $r2->
count
() <= $methodsig) {
echo "Error: signature unknown\n";
} else {
$mdesc = $r1->scalarval();
echo "Error: signature unknown\n";
} else {
$mdesc = $r1->scalarval();
diff --git
a/demo/client/agesort.php
b/demo/client/agesort.php
index
7f870c6
..
b21bf89
100644
(file)
--- a/
demo/client/agesort.php
+++ b/
demo/client/agesort.php
@@
-49,9
+49,7
@@
$resp = $client->send($req);
if (!$resp->faultCode()) {
print "The server gave me these results:<pre>";
$value = $resp->value();
if (!$resp->faultCode()) {
print "The server gave me these results:<pre>";
$value = $resp->value();
- $max = $value->arraysize();
- for ($i = 0; $i < $max; $i++) {
- $struct = $value->arraymem($i);
+ foreach ($value as $struct) {
$name = $struct->structmem("name");
$age = $struct->structmem("age");
print htmlspecialchars($name->scalarval()) . ", " . htmlspecialchars($age->scalarval()) . "\n";
$name = $struct->structmem("name");
$age = $struct->structmem("age");
print htmlspecialchars($name->scalarval()) . ", " . htmlspecialchars($age->scalarval()) . "\n";
diff --git
a/demo/client/introspect.php
b/demo/client/introspect.php
index
e11ac0e
..
f25540e
100644
(file)
--- a/
demo/client/introspect.php
+++ b/
demo/client/introspect.php
@@
-29,8
+29,7
@@
if ($resp->faultCode()) {
$v = $resp->value();
// Then, retrieve the signature and help text of each available method
$v = $resp->value();
// Then, retrieve the signature and help text of each available method
- for ($i = 0; $i < $v->arraysize(); $i++) {
- $methodName = $v->arraymem($i);
+ foreach ($v as $methodName) {
print "<h4>" . $methodName->scalarval() . "</h4>\n";
// build messages first, add params later
$m1 = new PhpXmlRpc\Request('system.methodHelp');
print "<h4>" . $methodName->scalarval() . "</h4>\n";
// build messages first, add params later
$m1 = new PhpXmlRpc\Request('system.methodHelp');
@@
-60,16
+59,15
@@
if ($resp->faultCode()) {
// note: using PhpXmlRpc\Encoder::decode() here would lead to cleaner code
$val = $rs[1]->value();
if ($val->kindOf() == "array") {
// note: using PhpXmlRpc\Encoder::decode() here would lead to cleaner code
$val = $rs[1]->value();
if ($val->kindOf() == "array") {
- for ($j = 0; $j < $val->arraysize(); $j++) {
- $x = $val->arraymem($j);
+ foreach ($val as $x) {
$ret = $x->arraymem(0);
print "<code>" . $ret->scalarval() . " "
. $methodName->scalarval() . "(";
$ret = $x->arraymem(0);
print "<code>" . $ret->scalarval() . " "
. $methodName->scalarval() . "(";
- if ($x->
arraysize
() > 1) {
- for ($k = 1; $k < $x->
arraysize
(); $k++) {
+ if ($x->
count
() > 1) {
+ for ($k = 1; $k < $x->
count
(); $k++) {
$y = $x->arraymem($k);
print $y->scalarval();
$y = $x->arraymem($k);
print $y->scalarval();
- if ($k < $x->
arraysize
() - 1) {
+ if ($k < $x->
count
() - 1) {
print ", ";
}
}
print ", ";
}
}
diff --git
a/demo/server/proxy.php
b/demo/server/proxy.php
index
fa74d3a
..
6e791f4
100644
(file)
--- a/
demo/server/proxy.php
+++ b/
demo/server/proxy.php
@@
-63,8
+63,8
@@
function forward_request($req)
$reqMethod = $encoder->decode($req->getParam(1));
$pars = $req->getParam(2);
$req = new PhpXmlRpc\Request($reqMethod);
$reqMethod = $encoder->decode($req->getParam(1));
$pars = $req->getParam(2);
$req = new PhpXmlRpc\Request($reqMethod);
- for
($i = 0; $i < $pars->arraySize(); $i++
) {
- $req->addParam($par
s->arraymem($i)
);
+ for
each ($pars as $par
) {
+ $req->addParam($par);
}
// add debug info into response we give back to caller
}
// add debug info into response we give back to caller
diff --git
a/demo/server/server.php
b/demo/server/server.php
index
4b8b8e4
..
546d265
100644
(file)
--- a/
demo/server/server.php
+++ b/
demo/server/server.php
@@
-269,11
+269,9
@@
$bitflipper_doc = 'Accepts an array of booleans, and returns them inverted';
function bitFlipper($req)
{
$v = $req->getParam(0);
function bitFlipper($req)
{
$v = $req->getParam(0);
- $sz = $v->arraysize();
$rv = new Value(array(), Value::$xmlrpcArray);
$rv = new Value(array(), Value::$xmlrpcArray);
- for ($j = 0; $j < $sz; $j++) {
- $b = $v->arraymem($j);
+ foreach ($v as $b) {
if ($b->scalarval()) {
$rv->addScalar(false, "boolean");
} else {
if ($b->scalarval()) {
$rv->addScalar(false, "boolean");
} else {
@@
-333,10
+331,9
@@
function ageSorter($req)
$v = new Value();
$agar = array();
$v = new Value();
$agar = array();
- $max = $sno->
arraysize
();
+ $max = $sno->
count
();
PhpXmlRpc\Server::xmlrpc_debugmsg("Found $max array elements");
PhpXmlRpc\Server::xmlrpc_debugmsg("Found $max array elements");
- for ($i = 0; $i < $max; $i++) {
- $rec = $sno->arraymem($i);
+ foreach ($sno as $rec) {
if ($rec->kindOf() != "struct") {
$err = "Found non-struct in array at element $i";
break;
if ($rec->kindOf() != "struct") {
$err = "Found non-struct in array at element $i";
break;
@@
-465,7
+462,7
@@
function setCookies($req)
{
$encoder = new PhpXmlRpc\Encoder();
$cookies = $req->getParam(0);
{
$encoder = new PhpXmlRpc\Encoder();
$cookies = $req->getParam(0);
-
while (list($name, $value) = $cookies->structeach()
) {
+
foreach ($cookies as $name => $value
) {
$cookieDesc = $encoder->decode($value);
setcookie($name, @$cookieDesc['value'], @$cookieDesc['expires'], @$cookieDesc['path'], @$cookieDesc['domain'], @$cookieDesc['secure']);
}
$cookieDesc = $encoder->decode($value);
setcookie($name, @$cookieDesc['value'], @$cookieDesc['expires'], @$cookieDesc['path'], @$cookieDesc['domain'], @$cookieDesc['secure']);
}
@@
-487,10
+484,8
@@
function v1_arrayOfStructs($req)
{
$sno = $req->getParam(0);
$numCurly = 0;
{
$sno = $req->getParam(0);
$numCurly = 0;
- for ($i = 0; $i < $sno->arraysize(); $i++) {
- $str = $sno->arraymem($i);
- $str->structreset();
- while (list($key, $val) = $str->structeach()) {
+ foreach ($sno as $str) {
+ foreach ($str as $key => $val) {
if ($key == "curly") {
$numCurly += $val->scalarval();
}
if ($key == "curly") {
$numCurly += $val->scalarval();
}
@@
-546,7
+541,7
@@
$v1_moderateSizeArrayCheck_doc = 'This handler takes a single parameter, which i
function v1_moderateSizeArrayCheck($req)
{
$ar = $req->getParam(0);
function v1_moderateSizeArrayCheck($req)
{
$ar = $req->getParam(0);
- $sz = $ar->
arraysize
();
+ $sz = $ar->
count
();
$first = $ar->arraymem(0);
$last = $ar->arraymem($sz - 1);
$first = $ar->arraymem(0);
$last = $ar->arraymem($sz - 1);
diff --git
a/doc/api_changes_v4.md
b/doc/api_changes_v4.md
index
2403020
..
ea9d4e1
100644
(file)
--- a/
doc/api_changes_v4.md
+++ b/
doc/api_changes_v4.md
@@
-52,10
+52,10
@@
In case you had extended the classes of the library and added methods to the sub
implementation clashes with the new one if you implemented:
implementation clashes with the new one if you implemented:
-| Class | Method | Notes |
-| --------- | ----------- | -------------------------------------- |
-| xmlrpcval | count | implements interface Countable |
-| xmlrpcval | getIterator | implements interface IteratorAggregate |
+| Class | Method | Notes
|
+| --------- | ----------- | --------------------------------------
-
|
+| xmlrpcval | count | implements interface
:
Countable |
+| xmlrpcval | getIterator | implements interface
:
IteratorAggregate |
Global variables cleanup
Global variables cleanup
diff --git
a/src/Client.php
b/src/Client.php
index
c0d86c3
..
3ff4b7c
100644
(file)
--- a/
src/Client.php
+++ b/
src/Client.php
@@
-1037,7
+1037,7
@@
class Client
if ($rets->kindOf() != 'array') {
return false; // bad return type from system.multicall
}
if ($rets->kindOf() != 'array') {
return false; // bad return type from system.multicall
}
- $numRets = $rets->
arraysize
();
+ $numRets = $rets->
count
();
if ($numRets != count($reqs)) {
return false; // wrong number of return values.
}
if ($numRets != count($reqs)) {
return false; // wrong number of return values.
}
@@
-1047,7
+1047,7
@@
class Client
$val = $rets->arraymem($i);
switch ($val->kindOf()) {
case 'array':
$val = $rets->arraymem($i);
switch ($val->kindOf()) {
case 'array':
- if ($val->
arraysize
() != 1) {
+ if ($val->
count
() != 1) {
return false; // Bad value
}
// Normal return value
return false; // Bad value
}
// Normal return value
diff --git
a/src/Encoder.php
b/src/Encoder.php
index
f97096e
..
86e518e
100644
(file)
--- a/
src/Encoder.php
+++ b/
src/Encoder.php
@@
-71,7
+71,7
@@
class Encoder
return $xmlrpcVal->scalarval();
case 'array':
return $xmlrpcVal->scalarval();
case 'array':
- $size = $xmlrpcVal->
arraysize
();
+ $size = $xmlrpcVal->
count
();
$arr = array();
for ($i = 0; $i < $size; $i++) {
$arr[] = $this->decode($xmlrpcVal->arraymem($i), $options);
$arr = array();
for ($i = 0; $i < $size; $i++) {
$arr[] = $this->decode($xmlrpcVal->arraymem($i), $options);
@@
-79,7
+79,6
@@
class Encoder
return $arr;
case 'struct':
return $arr;
case 'struct':
- $xmlrpcVal->structreset();
// If user said so, try to rebuild php objects for specific struct vals.
/// @todo should we raise a warning for class not found?
// shall we check for proper subclass of xmlrpc value instead of
// If user said so, try to rebuild php objects for specific struct vals.
/// @todo should we raise a warning for class not found?
// shall we check for proper subclass of xmlrpc value instead of
@@
-88,14
+87,14
@@
class Encoder
&& class_exists($xmlrpcVal->_php_class)
) {
$obj = @new $xmlrpcVal->_php_class();
&& class_exists($xmlrpcVal->_php_class)
) {
$obj = @new $xmlrpcVal->_php_class();
-
while (list($key, $value) = $xmlrpcVal->structeach()
) {
+
foreach ($xmlrpcVal as $key => $value
) {
$obj->$key = $this->decode($value, $options);
}
return $obj;
} else {
$arr = array();
$obj->$key = $this->decode($value, $options);
}
return $obj;
} else {
$arr = array();
-
while (list($key, $value) = $xmlrpcVal->structeach()
) {
+
foreach ($xmlrpcVal as $key => $value
) {
$arr[$key] = $this->decode($value, $options);
}
$arr[$key] = $this->decode($value, $options);
}
diff --git
a/src/Server.php
b/src/Server.php
index
70b45de
..
8540553
100644
(file)
--- a/
src/Server.php
+++ b/
src/Server.php
@@
-932,7
+932,7
@@
class Server
if ($params->kindOf() != 'array') {
return static::_xmlrpcs_multicall_error('notarray');
}
if ($params->kindOf() != 'array') {
return static::_xmlrpcs_multicall_error('notarray');
}
- $numParams = $params->
arraysize
();
+ $numParams = $params->
count
();
$req = new Request($methName->scalarval());
for ($i = 0; $i < $numParams; $i++) {
$req = new Request($methName->scalarval());
for ($i = 0; $i < $numParams; $i++) {
@@
-999,7
+999,7
@@
class Server
// let accept a plain list of php parameters, beside a single xmlrpc msg object
if (is_object($req)) {
$calls = $req->getParam(0);
// let accept a plain list of php parameters, beside a single xmlrpc msg object
if (is_object($req)) {
$calls = $req->getParam(0);
- $numCalls = $calls->
arraysize
();
+ $numCalls = $calls->
count
();
for ($i = 0; $i < $numCalls; $i++) {
$call = $calls->arraymem($i);
$result[$i] = static::_xmlrpcs_multicall_do_call($server, $call);
for ($i = 0; $i < $numCalls; $i++) {
$call = $calls->arraymem($i);
$result[$i] = static::_xmlrpcs_multicall_do_call($server, $call);
diff --git
a/src/Value.php
b/src/Value.php
index
6e8d7ef
..
84f04d1
100644
(file)
--- a/
src/Value.php
+++ b/
src/Value.php
@@
-344,6
+344,7
@@
class Value implements \Countable, \IteratorAggregate
/**
* Reset internal pointer for xmlrpc values of type struct.
/**
* Reset internal pointer for xmlrpc values of type struct.
+ * @deprecated iterate directly over the object using foreach instead
*/
public function structreset()
{
*/
public function structreset()
{
@@
-354,6
+355,8
@@
class Value implements \Countable, \IteratorAggregate
* Return next member element for xmlrpc values of type struct.
*
* @return Value
* Return next member element for xmlrpc values of type struct.
*
* @return Value
+ *
+ * @deprecated iterate directly over the object using foreach instead
*/
public function structeach()
{
*/
public function structeach()
{
@@
-419,7
+422,7
@@
class Value implements \Countable, \IteratorAggregate
*
* @return integer
*
*
* @return integer
*
- * @deprecateduse count() instead
+ * @deprecated
use count() instead
*/
public function structsize()
{
*/
public function structsize()
{
@@
-454,6
+457,16
@@
class Value implements \Countable, \IteratorAggregate
* @return ArrayIterator
*/
public function getIterator() {
* @return ArrayIterator
*/
public function getIterator() {
- return new \ArrayIterator($this->me);
+ switch ($this->mytype) {
+ case 3:
+ return new \ArrayIterator($this->me['struct']);
+ case 2:
+ return new \ArrayIterator($this->me['array']);
+ case 1:
+ return new \ArrayIterator($this->me);
+ default:
+ return new \ArrayIterator();
+ }
+ return new \ArrayIterator();
}
}
\ No newline at end of file
}
}
\ No newline at end of file