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 (from parent 1:
509dee3
)
Remove usages of 'each', as it is deprecated in php 7.2
author
gggeek
<giunta.gaetano@gmail.com>
Sun, 3 Sep 2017 19:11:32 +0000
(20:11 +0100)
committer
gggeek
<giunta.gaetano@gmail.com>
Sun, 3 Sep 2017 19:11:32 +0000
(20:11 +0100)
demo/server/server.php
patch
|
blob
|
history
lib/xmlrpc.inc
patch
|
blob
|
history
src/Encoder.php
patch
|
blob
|
history
src/Helper/Http.php
patch
|
blob
|
history
src/Value.php
patch
|
blob
|
history
tests/3LocalhostTest.php
patch
|
blob
|
history
diff --git
a/demo/server/server.php
b/demo/server/server.php
index
b18cf46
..
1af2554
100644
(file)
--- a/
demo/server/server.php
+++ b/
demo/server/server.php
@@
-351,7
+351,7
@@
function ageSorter($req)
// hack, must make global as uksort() won't
// allow us to pass any other auxiliary information
uksort($agesorter_arr, 'agesorter_compare');
// hack, must make global as uksort() won't
// allow us to pass any other auxiliary information
uksort($agesorter_arr, 'agesorter_compare');
-
while (list($key, $val) = each($agesorter_arr)
) {
+
foreach($agesorter_arr as $key => $val
) {
// recreate each struct element
$v[] = new Value(
array(
// recreate each struct element
$v[] = new Value(
array(
diff --git
a/lib/xmlrpc.inc
b/lib/xmlrpc.inc
index
28b47d3
..
74ff080
100644
(file)
--- a/
lib/xmlrpc.inc
+++ b/
lib/xmlrpc.inc
@@
-92,8
+92,8
@@
class xmlrpcval extends PhpXmlRpc\Value
//if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))
//{
$ar = $o->me;
//if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))
//{
$ar = $o->me;
- reset($ar);
-
list($typ, $val) = each
($ar);
+
$val =
reset($ar);
+
$typ = key
($ar);
return '<value>' . $this->serializedata($typ, $val) . "</value>\n";
//}
return '<value>' . $this->serializedata($typ, $val) . "</value>\n";
//}
@@
-106,16
+106,15
@@
class xmlrpcval extends PhpXmlRpc\Value
public function getval()
{
// UNSTABLE
public function getval()
{
// UNSTABLE
- reset($this->me);
-
list($a, $b) = each
($this->me);
+
$b =
reset($this->me);
+
$a = key
($this->me);
// contributed by I Sofer, 2001-03-24
// add support for nested arrays to scalarval
// i've created a new method here, so as to
// preserve back compatibility
if (is_array($b)) {
// contributed by I Sofer, 2001-03-24
// add support for nested arrays to scalarval
// i've created a new method here, so as to
// preserve back compatibility
if (is_array($b)) {
- @reset($b);
- while (list($id, $cont) = @each($b)) {
+ foreach($b as $id => $cont) {
$b[$id] = $cont->scalarval();
}
}
$b[$id] = $cont->scalarval();
}
}
@@
-123,12
+122,10
@@
class xmlrpcval extends PhpXmlRpc\Value
// add support for structures directly encoding php objects
if (is_object($b)) {
$t = get_object_vars($b);
// add support for structures directly encoding php objects
if (is_object($b)) {
$t = get_object_vars($b);
- @reset($t);
- while (list($id, $cont) = @each($t)) {
+ foreach($t as $id => $cont) { {
$t[$id] = $cont->scalarval();
}
$t[$id] = $cont->scalarval();
}
- @reset($t);
- while (list($id, $cont) = @each($t)) {
+ foreach($t as $id => $cont) {
@$b->$id = $cont;
}
}
@$b->$id = $cont;
}
}
diff --git
a/src/Encoder.php
b/src/Encoder.php
index
dfec15d
..
735c3ed
100644
(file)
--- a/
src/Encoder.php
+++ b/
src/Encoder.php
@@
-36,8
+36,8
@@
class Encoder
switch ($xmlrpcVal->kindOf()) {
case 'scalar':
if (in_array('extension_api', $options)) {
switch ($xmlrpcVal->kindOf()) {
case 'scalar':
if (in_array('extension_api', $options)) {
- reset($xmlrpcVal->me);
-
list($typ, $val) = each
($xmlrpcVal->me);
+
$val =
reset($xmlrpcVal->me);
+
$typ = key
($xmlrpcVal->me);
switch ($typ) {
case 'dateTime.iso8601':
$xmlrpcVal->scalar = $val;
switch ($typ) {
case 'dateTime.iso8601':
$xmlrpcVal->scalar = $val;
@@
-183,8
+183,7
@@
class Encoder
$xmlrpcVal = new Value($phpVal->format('Ymd\TH:i:s'), Value::$xmlrpcStruct);
} else {
$arr = array();
$xmlrpcVal = new Value($phpVal->format('Ymd\TH:i:s'), Value::$xmlrpcStruct);
} else {
$arr = array();
- reset($phpVal);
- while (list($k, $v) = each($phpVal)) {
+ foreach($phpVal as $k => $v) {
$arr[$k] = $this->encode($v, $options);
}
$xmlrpcVal = new Value($arr, Value::$xmlrpcStruct);
$arr[$k] = $this->encode($v, $options);
}
$xmlrpcVal = new Value($arr, Value::$xmlrpcStruct);
diff --git
a/src/Helper/Http.php
b/src/Helper/Http.php
index
2faf583
..
03a1ab6
100644
(file)
--- a/
src/Helper/Http.php
+++ b/
src/Helper/Http.php
@@
-133,7
+133,7
@@
class Http
}
// be tolerant to line endings, and extra empty lines
$ar = preg_split("/\r?\n/", trim(substr($data, 0, $pos)));
}
// be tolerant to line endings, and extra empty lines
$ar = preg_split("/\r?\n/", trim(substr($data, 0, $pos)));
-
while (list(, $line) = @each($ar)
) {
+
foreach($ar as $line
) {
// take care of multi-line headers and cookies
$arr = explode(':', $line, 2);
if (count($arr) > 1) {
// take care of multi-line headers and cookies
$arr = explode(':', $line, 2);
if (count($arr) > 1) {
diff --git
a/src/Value.php
b/src/Value.php
index
97852b0
..
8747e69
100644
(file)
--- a/
src/Value.php
+++ b/
src/Value.php
@@
-329,8
+329,8
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
*/
public function serialize($charsetEncoding = '')
{
*/
public function serialize($charsetEncoding = '')
{
- reset($this->me);
-
list($typ, $val) = each
($this->me);
+
$val =
reset($this->me);
+
$typ = key
($this->me);
return '<value>' . $this->serializedata($typ, $val, $charsetEncoding) . "</value>\n";
}
return '<value>' . $this->serializedata($typ, $val, $charsetEncoding) . "</value>\n";
}
@@
-394,8
+394,7
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
*/
public function scalarval()
{
*/
public function scalarval()
{
- reset($this->me);
- list(, $b) = each($this->me);
+ $b = reset($this->me);
return $b;
}
return $b;
}
@@
-410,7
+409,7
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
public function scalartyp()
{
reset($this->me);
public function scalartyp()
{
reset($this->me);
-
list($a,) = each
($this->me);
+
$a = key
($this->me);
if ($a == static::$xmlrpcI4) {
$a = static::$xmlrpcInt;
}
if ($a == static::$xmlrpcI4) {
$a = static::$xmlrpcInt;
}
@@
-525,7
+524,7
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
case 1:
// todo: handle i4 vs int
reset($this->me);
case 1:
// todo: handle i4 vs int
reset($this->me);
-
list($type,) = each
($this->me);
+
$type = key
($this->me);
if ($type != $offset) {
throw new \Exception('');
}
if ($type != $offset) {
throw new \Exception('');
}
@@
-575,8
+574,8
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
return isset($this->me['array'][$offset]) ? $this->me['array'][$offset] : null;
case 1:
// on bad type: null or exception?
return isset($this->me['array'][$offset]) ? $this->me['array'][$offset] : null;
case 1:
// on bad type: null or exception?
- reset($this->me);
-
list($type, $value) = each
($this->me);
+
$value =
reset($this->me);
+
$type = key
($this->me);
return $type == $offset ? $value : null;
default:
// return null or exception?
return $type == $offset ? $value : null;
default:
// return null or exception?
diff --git
a/tests/3LocalhostTest.php
b/tests/3LocalhostTest.php
index
0290dbf
..
118f10b
100644
(file)
--- a/
tests/3LocalhostTest.php
+++ b/
tests/3LocalhostTest.php
@@
-411,7
+411,7
@@
And turned it into nylon';
$got = '';
$expected = '37210';
$expect_array = array('ctLeftAngleBrackets', 'ctRightAngleBrackets', 'ctAmpersands', 'ctApostrophes', 'ctQuotes');
$got = '';
$expected = '37210';
$expect_array = array('ctLeftAngleBrackets', 'ctRightAngleBrackets', 'ctAmpersands', 'ctApostrophes', 'ctQuotes');
-
while (list(, $val) = each($expect_array)
) {
+
foreach($expect_array as $val
) {
$b = $v->structmem($val);
$got .= $b->me['int'];
}
$b = $v->structmem($val);
$got .= $b->me['int'];
}