TPropertyValue is a utility class that provides static methods
to convert component property values to specific types.
TPropertyValue is commonly used in component setter methods to ensure
the new property value is of specific type.
For example, a boolean-typed property setter method would be as follows,
function setPropertyName($value) {
$value=TPropertyValue::ensureBoolean($value);
$value is now of boolean type
}
Properties can be of the following types with specific type conversion rules:
- string: a boolean value will be converted to 'true' or 'false'.
- boolean: string 'true' (case-insensitive) will be converted to true,
string 'false' (case-insensitive) will be converted to false.
- integer
- float
- array: string starting with '(' and ending with ')' will be considered as
as an array expression and will be evaluated. Otherwise, an array
with the value to be ensured is returned.
- object
- enum: enumerable type, represented by an array of strings.