Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

(no description)

File Size: 672 lines (23 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Value:: (26 methods):
  getLogger()
  setLogger()
  getCharsetEncoder()
  setCharsetEncoder()
  __construct()
  addScalar()
  addArray()
  addStruct()
  kindOf()
  serializedata()
  serialize()
  structmemexists()
  structmem()
  structreset()
  structeach()
  scalarval()
  scalartyp()
  arraymem()
  arraysize()
  structsize()
  count()
  getIterator()
  offsetSet()
  offsetExists()
  offsetUnset()
  offsetGet()


Class: Value  - X-Ref

This class enables the creation of values for XML-RPC, by encapsulating plain php values.

getLogger()   X-Ref


setLogger($logger)   X-Ref
No description

getCharsetEncoder()   X-Ref
No description

setCharsetEncoder($charsetEncoder)   X-Ref
No description

__construct($val = -1, $type = '')   X-Ref
Build an xmlrpc value.

When no value or type is passed in, the value is left uninitialized, and the value can be added later.

param: Value[]|mixed $val if passing in an array, all array elements should be PhpXmlRpc\Value themselves
param: string $type any valid xmlrpc type name (lowercase): i4, int, boolean, string, double, dateTime.iso8601,

addScalar($val, $type = 'string')   X-Ref
Add a single php value to an xmlrpc value.

If the xmlrpc value is an array, the php value is added as its last element.
If the xmlrpc value is empty (uninitialized), this method makes it a scalar value, and sets that value.
Fails if the xmlrpc value is not an array and already initialized.

param: mixed $val
param: string $type allowed values: i4, i8, int, boolean, string, double, dateTime.iso8601, base64, null.
return: int 1 or 0 on failure

addArray($values)   X-Ref
Add an array of xmlrpc value objects to an xmlrpc value.

If the xmlrpc value is an array, the elements are appended to the existing ones.
If the xmlrpc value is empty (uninitialized), this method makes it an array value, and sets that value.
Fails otherwise.

param: Value[] $values
return: int 1 or 0 on failure

addStruct($values)   X-Ref
Merges an array of named xmlrpc value objects into an xmlrpc value.

If the xmlrpc value is a struct, the elements are merged with the existing ones (overwriting existing ones).
If the xmlrpc value is empty (uninitialized), this method makes it a struct value, and sets that value.
Fails otherwise.

param: Value[] $values
return: int 1 or 0 on failure

kindOf()   X-Ref
Returns a string containing either "struct", "array", "scalar" or "undef", describing the base type of the value.

return: string

serializedata($typ, $val, $charsetEncoding = '')   X-Ref

param: string $typ
param: Value[]|mixed $val
param: string $charsetEncoding
return: string

serialize($charsetEncoding = '')   X-Ref
Returns the xml representation of the value. XML prologue not included.

param: string $charsetEncoding the charset to be used for serialization. if null, US-ASCII is assumed
return: string

structmemexists($key)   X-Ref
Checks whether a struct member with a given name is present.

Works only on xmlrpc values of type struct.

param: string $key the name of the struct member to be looked up
return: boolean

structmem($key)   X-Ref
Returns the value of a given struct member (an xmlrpc value object in itself).
Will raise a php warning if struct member of given name does not exist.

param: string $key the name of the struct member to be looked up
return: Value

structreset()   X-Ref
Reset internal pointer for xmlrpc values of type struct.


structeach()   X-Ref
Return next member element for xmlrpc values of type struct.

return: Value

scalarval()   X-Ref
Returns the value of a scalar xmlrpc value (base 64 decoding is automatically handled here)

return: mixed

scalartyp()   X-Ref
Returns the type of the xmlrpc value.

For integers, 'int' is always returned in place of 'i4'. 'i8' is considered a separate type and returned as such

return: string

arraymem($key)   X-Ref
Returns the m-th member of an xmlrpc value of array type.

param: integer $key the index of the value to be retrieved (zero based)
return: Value

arraysize()   X-Ref
Returns the number of members in an xmlrpc value of array type.

return: integer

structsize()   X-Ref
Returns the number of members in an xmlrpc value of struct type.

return: integer

count()   X-Ref
Returns the number of members in an xmlrpc value:
- 0 for uninitialized values
- 1 for scalar values
- the number of elements for struct and array values

return: integer

getIterator()   X-Ref
Implements the IteratorAggregate interface

return: \ArrayIterator

offsetSet($offset, $value)   X-Ref

param: mixed $offset
param: mixed $value

offsetExists($offset)   X-Ref

param: mixed $offset
return: bool

offsetUnset($offset)   X-Ref

param: mixed $offset

offsetGet($offset)   X-Ref

param: mixed $offset
return: mixed|Value|null