git://git.onelab.eu
/
plcapi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove usages of 'each', as it is deprecated in php 7.2
[plcapi.git]
/
src
/
Value.php
diff --git
a/src/Value.php
b/src/Value.php
index
d48f0b8
..
8747e69
100644
(file)
--- a/
src/Value.php
+++ b/
src/Value.php
@@
-113,7
+113,7
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
}
// coerce booleans into correct values
}
// coerce booleans into correct values
- // NB: we should either do it for datetimes, integers and doubles, too,
+ // NB: we should either do it for datetimes, integers
, i8
and doubles, too,
// or just plain remove this check, implemented on booleans only...
if ($type == static::$xmlrpcBoolean) {
if (strcasecmp($val, 'true') == 0 || $val == 1 || ($val == true && strcasecmp($val, 'false'))) {
// or just plain remove this check, implemented on booleans only...
if ($type == static::$xmlrpcBoolean) {
if (strcasecmp($val, 'true') == 0 || $val == 1 || ($val == true && strcasecmp($val, 'false'))) {
@@
-329,14
+329,10
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
*/
public function serialize($charsetEncoding = '')
{
*/
public function serialize($charsetEncoding = '')
{
- // add check? slower, but helps to avoid recursion in serializing broken xmlrpc values...
- //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))
- //{
- 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";
- //}
}
/**
}
/**
@@
-398,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;
}
@@
-407,15
+402,15
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
/**
* Returns the type of the xmlrpc value.
*
/**
* Returns the type of the xmlrpc value.
*
- * For integers, 'int' is always returned in place of 'i4'
or 'i8'.
+ * For integers, 'int' is always returned in place of 'i4'
. 'i8' is considered a separate type and returned as such
*
* @return string
*/
public function scalartyp()
{
reset($this->me);
*
* @return string
*/
public function scalartyp()
{
reset($this->me);
-
list($a,) = each
($this->me);
- if ($a == static::$xmlrpcI4
|| $a == static::$xmlrpcI8
) {
+
$a = key
($this->me);
+ if ($a == static::$xmlrpcI4) {
$a = static::$xmlrpcInt;
}
$a = static::$xmlrpcInt;
}
@@
-501,7
+496,6
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
return new \ArrayIterator();
}
return new \ArrayIterator();
}
-
public function offsetSet($offset, $value) {
switch ($this->mytype) {
public function offsetSet($offset, $value) {
switch ($this->mytype) {
@@
-528,9
+522,9
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
}
return;
case 1:
}
return;
case 1:
-// todo: handle i4
/i8
vs int
+// todo: handle i4 vs int
reset($this->me);
reset($this->me);
-
list($type,) = each
($this->me);
+
$type = key
($this->me);
if ($type != $offset) {
throw new \Exception('');
}
if ($type != $offset) {
throw new \Exception('');
}
@@
-549,7
+543,7
@@
class Value implements \Countable, \IteratorAggregate, \ArrayAccess
case 2:
return isset($this->me['array'][$offset]);
case 1:
case 2:
return isset($this->me['array'][$offset]);
case 1:
-// todo: handle i4
/i8
vs int
+// todo: handle i4 vs int
return $offset == $this->scalartyp();
default:
return false;
return $offset == $this->scalartyp();
default:
return false;
@@
-580,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?