Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
PhpXmlRpc\Value Class Reference
Inheritance diagram for PhpXmlRpc\Value:

Public Member Functions

 __construct ($val=-1, $type='')
 Build an xml-rpc value.
 
__get ($name)
 
 __isset ($name)
 
 __set ($name, $value)
 
 __unset ($name)
 
 addArray ($values)
 Add an array of xml-rpc value objects to an xml-rpc value.
 
 addScalar ($val, $type='string')
 Add a single php value to an xml-rpc value.
 
 addStruct ($values)
 Merges an array of named xml-rpc value objects into an xml-rpc value.
 
 arrayMem ($key)
 Returns the n-th member of an xml-rpc value of array type.
 
 arraySize ()
 Returns the number of members in an xml-rpc value of array type.
 
 count ()
 Returns the number of members in an xml-rpc value:
 
 getIterator ()
 Implements the IteratorAggregate interface.
 
 kindOf ()
 Returns a string describing the base type of the value.
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 scalarTyp ()
 Returns the type of the xml-rpc value.
 
 scalarVal ()
 Returns the value of a scalar xml-rpc value (base 64 decoding is automatically handled here)
 
 serialize ($charsetEncoding='')
 Returns the xml representation of the value.
 
 structEach ()
 Return next member element for xml-rpc values of type struct.
 
 structMem ($key)
 Returns the value of a given struct member (an xml-rpc value object in itself).
 
 structMemExists ($key)
 Checks whether a struct member with a given name is present.
 
 structReset ()
 Reset internal pointer for xml-rpc values of type struct.
 
 structSize ()
 Returns the number of members in an xml-rpc value of struct type.
 

Static Public Attributes

static $xmlrpcArray = "array"
 
static $xmlrpcBase64 = "base64"
 
static $xmlrpcBoolean = "boolean"
 
static $xmlrpcDateTime = "dateTime.iso8601"
 
static $xmlrpcDouble = "double"
 
static $xmlrpcI4 = "i4"
 
static $xmlrpcI8 = "i8"
 
static $xmlrpcInt = "int"
 
static $xmlrpcNull = "null"
 
static $xmlrpcString = "string"
 
static $xmlrpcStruct = "struct"
 
static $xmlrpcTypes
 
static $xmlrpcValue = "undefined"
 

Protected Member Functions

 serializeData ($typ, $val, $charsetEncoding='')
 

Protected Attributes

string null $_php_class = null
 
Value[] mixed $me = array()
 
int $mytype = 0
 0 for undef, 1 for scalar, 2 for array, 3 for struct
 

Constructor & Destructor Documentation

◆ __construct()

PhpXmlRpc\Value::__construct ( $val = -1,
$type = '' )

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.

Parameters
Value[] | mixed$valif passing in an array, all array elements should be PhpXmlRpc\Value themselves
string$typeany valid xml-rpc type name (lowercase): i4, int, boolean, string, double, dateTime.iso8601, base64, array, struct, null. If null, 'string' is assumed. You should refer to http://xmlrpc.com/spec.md for more information on what each of these mean.

Member Function Documentation

◆ addArray()

PhpXmlRpc\Value::addArray ( $values)

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.

Parameters
Value[]$values
Return values
int1 or 0 on failure
Todo

add some checking for $values to be an array of xml-rpc values?

rename to addToArray?

◆ addScalar()

PhpXmlRpc\Value::addScalar ( $val,
$type = 'string' )

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.

Parameters
mixed$val
string$typeallowed values: i4, i8, int, boolean, string, double, dateTime.iso8601, base64, null.
Return values
int1 or 0 on failure
Todo

arguably, as we have addArray to add elements to an Array value, and addStruct to add elements to a Struct value, we should not allow this method to add values to an Array. The 'scalar' in the method name refers to the expected state of the target object, not to the type of $val. Also, this works differently from addScalar/addStruct in that, when adding an element to an array, it wraps it into a new Value

rename?

◆ addStruct()

PhpXmlRpc\Value::addStruct ( $values)

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.

Parameters
Value[]$values
Return values
int1 or 0 on failure
Todo

add some checking for $values to be an array of xml-rpc values?

rename to addToStruct?

◆ arrayMem()

PhpXmlRpc\Value::arrayMem ( $key)

Returns the n-th member of an xml-rpc value of array type.

Parameters
integer$keythe index of the value to be retrieved (zero based)
Return values
Value
Deprecated
use array access, e.g. $val[$key]

◆ arraySize()

PhpXmlRpc\Value::arraySize ( )

Returns the number of members in an xml-rpc value of array type.

Return values
integer
Deprecated
use count() instead

◆ count()

PhpXmlRpc\Value::count ( )

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 values
integer

◆ kindOf()

PhpXmlRpc\Value::kindOf ( )

Returns a string describing the base type of the value.

Return values
stringeither "struct", "array", "scalar" or "undef"

◆ scalarTyp()

PhpXmlRpc\Value::scalarTyp ( )

Returns the type of the xml-rpc value.

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

◆ scalarVal()

PhpXmlRpc\Value::scalarVal ( )

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

Return values
mixed

◆ serialize()

PhpXmlRpc\Value::serialize ( $charsetEncoding = '')

Returns the xml representation of the value.

XML prologue not included.

Parameters
string$charsetEncodingthe charset to be used for serialization. If null, US-ASCII is assumed
Return values
string

◆ serializeData()

PhpXmlRpc\Value::serializeData ( $typ,
$val,
$charsetEncoding = '' )
protected
Parameters
string$typ
Value[] | mixed$val
string$charsetEncoding
Return values
string
Deprecated
this should be folded back into serialize()

◆ structEach()

PhpXmlRpc\Value::structEach ( )

Return next member element for xml-rpc values of type struct.

Return values
arrayhaving the same format as PHP's each method
Deprecated
iterate directly over the object using foreach instead

◆ structMem()

PhpXmlRpc\Value::structMem ( $key)

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.

Parameters
string$keythe name of the struct member to be looked up
Return values
Value
Deprecated
use array access, e.g. $val[$key]

◆ structMemExists()

PhpXmlRpc\Value::structMemExists ( $key)

Checks whether a struct member with a given name is present.

Works only on xml-rpc values of type struct.

Parameters
string$keythe name of the struct member to be looked up
Return values
boolean
Deprecated
use array access, e.g. isset($val[$key])

◆ structReset()

PhpXmlRpc\Value::structReset ( )

Reset internal pointer for xml-rpc values of type struct.

Return values
void
Deprecated
iterate directly over the object using foreach instead

◆ structSize()

PhpXmlRpc\Value::structSize ( )

Returns the number of members in an xml-rpc value of struct type.

Return values
integer
Deprecated
use count() instead

Member Data Documentation

◆ $xmlrpcTypes

PhpXmlRpc\Value::$xmlrpcTypes
static
Initial value:
= array(
"i4" => 1,
"i8" => 1,
"int" => 1,
"boolean" => 1,
"double" => 1,
"string" => 1,
"dateTime.iso8601" => 1,
"base64" => 1,
"array" => 2,
"struct" => 3,
"null" => 1,
)

The documentation for this class was generated from the following file: