
Public Member Functions | |
| __construct () | |
| Constructor. | |
| getName () | |
| Gets the name of this type. | |
| getDocumentation () | |
| Gets the documentation for this type. | |
| getOptions () | |
| Gets the type options for this type. | |
| check ($value, spunQ_Map $options=NULL, $throwException=true) | |
| Checks if a value is of the type described by this object. | |
| __call ($functionName, $arguments) | |
| Overloaded to provide automatic getters and setters. | |
| __sleep () | |
| Replaces $_type with the type's name. | |
| _verifyMembers ($omittedMembers=array(), $throwException=true) | |
| Verifies that all members are valid. | |
| _getMember ($name) | |
| Gets the value of a member of this object. | |
| _setMember ($name, $value) | |
| Sets the value of a member of this object. | |
| _getType ($throwException=true) | |
| Gets the type of this object. | |
Static Public Member Functions | |
| static | stringDescribesType ($string) |
| Checks whether a string is a valid type descriptor. | |
| static | getByName ($string) |
| Will return a Type object with given description. | |
| static | getDescription ($value) |
| Returns the most appropriate textual representation of a value. | |
| static | getCommonDescription (array $values) |
| Finds the most suiting string description for multiple values. | |
| static | valueByProperty ($value, $path) |
| Transforms a value using a property path. | |
| static | propertyOfValue ($value, $property) |
| Gets a single property of a value. | |
Protected Member Functions | |
| handleGetUntranslated ($memberName, $arguments, $functionName) | |
| Needed by __call(). | |
| handleGet ($memberName, $arguments, $functionName) | |
| Needed by __call(). | |
| initLocalizedMember ($memberName) | |
| Makes sure a localized member contains a spunQ_Map. | |
| handleGetFromArray ($memberName, $arguments, $functionName) | |
| Needed by __call(). | |
| handleSet ($memberName, $arguments, $functionName) | |
| Needed by __call(). | |
| handleAdd ($memberName, $arguments, $functionName) | |
| Needed by __call(). | |
| handleRemove ($memberName, $arguments, $functionName) | |
| Needed by __call(). | |
Protected Attributes | |
| $name | |
| The name of this type. | |
| $documentation | |
| Documentation of this type as extracted from its doc comments. | |
| $options | |
| Additional options for this member. | |
| $_type | |
| The actual type of this object. | |
Static Protected Attributes | |
| static | $typeInstance = NULL |
| The one instance of this class that will describe all other instances. | |
Static Private Attributes | |
| static | $nameToTypeCache = array() |
| Cache for getByName(). | |
Types are needed in the spunQ framework for various reasons:
forum.rights.User, the class must be named User. There is an exception to this rule to prevent name collisions with other classes. The class name may be prefixed with any level of module names of the type, delimited by underscores. The same forum.rights.User type may be defined with the class forum_User or forum_rights_User.spunQ.modules. This means that the following setup would lead to the folder /tmp/forum becoming the root of the forum module: spunQ.modules.folder = /tmp/forum.type.php. The complete path for the above example would be /tmp/forum/rights/User.type.php.integer: min: The minimum value of the member.max: The maximum value of the member.real: min: The minimum value of the member.max: The maximum value of the member.string: length.min: Minimum length of the string.length.max: Minimum length of the string.array: See the options of maps. Arrays are handled identically to maps indexed with integers in this context. array<string> = map<integer,string>set: Almost the same as array. Sets don't claim to be ordered.map: This type itself does not have options of its own, but it prvides access to options of its keys/values with the prefix key and value accordingly. The type map<integer,string> could have the option @key.min or @key.max to limit the allowed range of values for the key.# Example class (doc comment malformatted for technical reasons) class User extends spunQ_DataObject { / ** * The usernames this user can use to log in. * A user can have a maximum of 10 user names, the first one being his * preferred name. * @type array<string> * @key.min 1 * @key.max 10 * @value.length.min 3 * @value.length.max 100 * / protected $usernames; / ** * Caches various things. * @local * / private $cache; }
Definition at line 283 of file Type.type.php.
| spunQ_DataObject::__call | ( | $ | functionName, | |
| $ | arguments | |||
| ) | [inherited] |
Overloaded to provide automatic getters and setters.
| $functionName | The function that was called. | |
| $arguments | Array containing the arguments that were passed to the function. |
| spunQ_BadArgumentCountError |
Definition at line 148 of file DataObject.type.php.
| spunQ_DataObject::__sleep | ( | ) | [inherited] |
Replaces $_type with the type's name.
Reimplemented in spunQ_ArrayType, spunQ_MapType, and spunQ_SetType.
Definition at line 178 of file DataObject.type.php.
| spunQ_DataObject::_getMember | ( | $ | name | ) | [inherited] |
Gets the value of a member of this object.
Will check if the object has a getter for the member and will use that method for getting the value. Otherwise, the value of the object member is returned.
| $name | The name of the member. |
Definition at line 478 of file DataObject.type.php.
| spunQ_DataObject::_getType | ( | $ | throwException = true |
) | [inherited] |
Gets the type of this object.
Definition at line 507 of file DataObject.type.php.
| spunQ_DataObject::_setMember | ( | $ | name, | |
| $ | value | |||
| ) | [inherited] |
Sets the value of a member of this object.
Will check if the object has a setter for the member and will use that method for setting the value. Otherwise, the object member is set directly.
| $name | The name of the member. | |
| $value | The value to set it to. |
Definition at line 495 of file DataObject.type.php.
| spunQ_DataObject::_verifyMembers | ( | $ | omittedMembers = array(), |
|
| $ | throwException = true | |||
| ) | [inherited] |
Verifies that all members are valid.
This function is called from various modules prior to critical actions requiring a complete object - like inserting into a database.
| $omittedMembers | Do not perform checks on these member names. | |
| $throwException | Whether an exception should be thrown if a member does not have a valid value. |
| spunQ_IllegalValueException |
Definition at line 458 of file DataObject.type.php.
| spunQ_Type::check | ( | $ | value, | |
| spunQ_Map $ | options = NULL, |
|||
| $ | throwException = true | |||
| ) |
Checks if a value is of the type described by this object.
| $value | The value to check | |
| $options | The type options to consider. | |
| $throwException | Whether an exception should be thrown if the type of the value differs. |
| spunQ_IllegalValueException |
Reimplemented in spunQ_AnyType, spunQ_ArrayType, spunQ_BooleanType, spunQ_DateTimeType, spunQ_DateType, spunQ_MapType, spunQ_NumericType, spunQ_SetType, spunQ_StringType, spunQ_TimeType, and spunQ_UserType.
Definition at line 479 of file Type.type.php.
| static spunQ_Type::getByName | ( | $ | string | ) | [static] |
Will return a Type object with given description.
| $string | The string description fo the type. |
Reimplemented in spunQ_ArrayType, spunQ_MapType, spunQ_SetType, and spunQ_BuiltinType.
Definition at line 313 of file Type.type.php.
| static spunQ_Type::getCommonDescription | ( | array $ | values | ) | [static] |
Finds the most suiting string description for multiple values.
| $values | The values to find string description for. |
Definition at line 373 of file Type.type.php.
| static spunQ_Type::getDescription | ( | $ | value | ) | [static] |
Returns the most appropriate textual representation of a value.
Can be used to provide useful information about a value when debugging:
'any' for undefined types (map<string,any>).| $value | The value to describe as a string. |
Definition at line 343 of file Type.type.php.
| spunQ_Type::getDocumentation | ( | ) |
| spunQ_Type::getName | ( | ) |
Gets the name of this type.
Reimplemented in spunQ_ArrayType, spunQ_MapType, and spunQ_SetType.
Definition at line 450 of file Type.type.php.
| spunQ_Type::getOptions | ( | ) |
Gets the type options for this type.
Definition at line 466 of file Type.type.php.
| spunQ_DataObject::handleAdd | ( | $ | memberName, | |
| $ | arguments, | |||
| $ | functionName | |||
| ) | [protected, inherited] |
Needed by __call().
Will take care of function calls starting with 'add'.
| $memberName | The name of the member that is possibly being appended to. Merely the name of the function without the leading 'add', with a lower-case first letter. | |
| $arguments | Array containing the arguments that were passed to the function. | |
| $functionName | The function that was called. |
Reimplemented in spunQ_StorableObject.
Definition at line 327 of file DataObject.type.php.
| spunQ_DataObject::handleGet | ( | $ | memberName, | |
| $ | arguments, | |||
| $ | functionName | |||
| ) | [protected, inherited] |
Needed by __call().
Will take care of function calls starting with 'get'.
| $memberName | The name of the member that was possibly requested. Merely the name of the function without the leading 'get', with a lower-case first letter. | |
| $arguments | Array containing the arguments that were passed to the function. | |
| $functionName | The name of the function that was called. |
Reimplemented in spunQ_StorableObject.
Definition at line 217 of file DataObject.type.php.
| spunQ_DataObject::handleGetFromArray | ( | $ | memberName, | |
| $ | arguments, | |||
| $ | functionName | |||
| ) | [protected, inherited] |
Needed by __call().
Will take care of getter functions, where the member has an array type.
| $memberName | The name of the member that was possibly requested. Merely the name of the function without the leading 'set', with a lower-case first letter. | |
| $arguments | Array containing the arguments that were passed to the function. | |
| $functionName | The function that was called. |
Reimplemented in spunQ_StorableObject.
Definition at line 264 of file DataObject.type.php.
| spunQ_DataObject::handleGetUntranslated | ( | $ | memberName, | |
| $ | arguments, | |||
| $ | functionName | |||
| ) | [protected, inherited] |
Needed by __call().
Will take care of functions requesting all translations available for a member.
| $memberName | The name of the member that was possibly requested. | |
| $arguments | Array containing the arguments that were passed to the function. | |
| $functionName | The name of the function that was called. |
Reimplemented in spunQ_StorableObject.
Definition at line 198 of file DataObject.type.php.
| spunQ_DataObject::handleRemove | ( | $ | memberName, | |
| $ | arguments, | |||
| $ | functionName | |||
| ) | [protected, inherited] |
Needed by __call().
Will take care of function calls starting with 'remove'.
| $memberName | The name of the member that is possibly being removed from. Merely the name of the function without the leading 'remove', with a lower-case first letter. | |
| $arguments | Array containing the arguments that were passed to the function. | |
| $functionName | The function that was called. |
Reimplemented in spunQ_StorableObject.
Definition at line 399 of file DataObject.type.php.
| spunQ_DataObject::handleSet | ( | $ | memberName, | |
| $ | arguments, | |||
| $ | functionName | |||
| ) | [protected, inherited] |
Needed by __call().
Will take care of function calls starting with 'set'.
| $memberName | The name of the member that is possibly being set. Merely the name of the function without the leading 'set', with a lower-case first letter. | |
| $arguments | Array containing the arguments that were passed to the function. | |
| $functionName | The function that was called. |
Reimplemented in spunQ_StorableObject.
Definition at line 292 of file DataObject.type.php.
| spunQ_DataObject::initLocalizedMember | ( | $ | memberName | ) | [protected, inherited] |
Makes sure a localized member contains a spunQ_Map.
| $memberName | The name of the member. This member must have the option 'localized'. |
Definition at line 245 of file DataObject.type.php.
| static spunQ_DataObject::propertyOfValue | ( | $ | value, | |
| $ | property | |||
| ) | [static, inherited] |
Gets a single property of a value.
| $value | The value to fetch property for. | |
| $property | The property to fetch. |
Definition at line 74 of file DataObject.type.php.
| static spunQ_Type::stringDescribesType | ( | $ | string | ) | [static] |
Checks whether a string is a valid type descriptor.
| $string | The string to check |
Definition at line 298 of file Type.type.php.
| static spunQ_DataObject::valueByProperty | ( | $ | value, | |
| $ | path | |||
| ) | [static, inherited] |
Transforms a value using a property path.
Some types are considered to have properties within spunQ. These properties can be referred to using property path definitions. The most simple case for properties is the user type, for which every member is considered a property. Concatenations of these paths with dots as separators are called property path. The list of all users in the primary group of a given user can be described using this method in a string: 'primaryGroup.users'.
Different types have different properties:
_keys: An array of the keys of the map._values: An array of the values of the map. Note that _keys and _values are guaranteed to return arrays where the index of a key matches the index of its value in the according result._key: The first entry of the _keys property. This is handy for referencing the key of single key/value pairs._value: The first entry of the _values property._count: The amount of items in the map._keys: The array of keys of the array. Note that the difference between arrays and maps in spunQ is that arrays are always numerically indexed! So this will always return an array containing a range of integers._values: Array of values in this array. This essentially returns the array as-is and is a NOOP._key: The first entry of the _keys property._value: The first entry of the _values property._count: The amount of items in the array._length: The length of the string.| $value | The value to transform | |
| $path | The property path to use for the transformation. This can either be a string as described, or an array, each entry holding a property name. |
Definition at line 54 of file DataObject.type.php.
spunQ_DataObject::$_type [protected, inherited] |
spunQ_Type::$documentation [protected] |
Documentation of this type as extracted from its doc comments.
Definition at line 434 of file Type.type.php.
spunQ_Type::$name [protected] |
spunQ_Type::$nameToTypeCache = array() [static, private] |
spunQ_Type::$options [protected] |
Additional options for this member.
This map is extracted from the tags in the doc comment. The value is intentionally typed as array, since some options can have multiple values. A doc comment containing two author tags would result in a single entry with two values.
Definition at line 444 of file Type.type.php.
spunQ_Type::$typeInstance = NULL [static, protected] |
The one instance of this class that will describe all other instances.
Any type describing a type has itself a type (which is spunQ.Type). That instance describing types is stored in this static variable.
Definition at line 291 of file Type.type.php.
1.5.9