Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 401 and 403]

(no description)

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

Defines 1 class

Value:: (26 methods):
  __construct()
  addScalar()
  addArray()
  addStruct()
  kindOf()
  scalarVal()
  scalarTyp()
  serialize()
  serializeData()
  count()
  getIterator()
  offsetSet()
  offsetExists()
  offsetUnset()
  offsetGet()
  structMemExists()
  structMem()
  structReset()
  structEach()
  arrayMem()
  arraySize()
  structSize()
  __get()
  __set()
  __isset()
  __unset()


Class: Value  - X-Ref

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

__construct($val = -1, $type = '')   X-Ref
Build an xml-rpc 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 xml-rpc type name (lowercase): i4, int, boolean, string, double, dateTime.iso8601,

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

If the xml-rpc value is an array, the php value is added as its last element.
If the xml-rpc value is empty (uninitialized), this method makes it a scalar value, and sets that value.
Fails if the xml-rpc value is not an array (i.e. a struct or a scalar) 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 xml-rpc value objects to an xml-rpc value.

If the xml-rpc value is an array, the elements are appended to the existing ones.
If the xml-rpc 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 xml-rpc value objects into an xml-rpc value.

If the xml-rpc value is a struct, the elements are merged with the existing ones (overwriting existing ones).
If the xml-rpc 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 describing the base type of the value.

return: string either "struct", "array", "scalar" or "undef"

scalarVal()   X-Ref
Returns the value of a scalar xml-rpc value (base 64 decoding is automatically handled here)

return: mixed

scalarTyp()   X-Ref
Returns the type of the xml-rpc value.

return: string For integers, 'int' is always returned in place of 'i4'. 'i8' is considered a separate type and

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

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

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

count()   X-Ref
Returns the number of members in an xml-rpc 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
return: void

offsetExists($offset)   X-Ref

param: mixed $offset
return: bool

offsetUnset($offset)   X-Ref

param: mixed $offset
return: void

offsetGet($offset)   X-Ref

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

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

Works only on xml-rpc 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 xml-rpc 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 xml-rpc values of type struct.

return: void

structEach()   X-Ref
Return next member element for xml-rpc values of type struct.

return: array having the same format as PHP's `each` method

arrayMem($key)   X-Ref
Returns the n-th member of an xml-rpc 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 xml-rpc value of array type.

return: integer

structSize()   X-Ref
Returns the number of members in an xml-rpc value of struct type.

return: integer

__get($name)   X-Ref
No description

__set($name, $value)   X-Ref
No description

__isset($name)   X-Ref
No description

__unset($name)   X-Ref
No description