QCubed - A PHP5 rapid development MVC framework.
Home  |  Updates

classQType

QType Class Reference

List of all members.

Public Member Functions

Static Public Member Functions

Public Attributes

Static Private Member Functions


Detailed Description

Type Library to add some support for strongly named types.

PHP does not support strongly named types. The QCubed type library and QCubed typing in general attempts to bring some structure to types when passing in values, properties, parameters to/from QCubed framework objects and methods.

The Type library attempts to allow as much flexibility as possible to set and cast variables to other types, similar to how PHP does it natively, but simply adds a big more structure to it.

For example, regardless if a variable is an integer, boolean, or string, QType::Cast will allow the flexibility of those values to interchange with each other with little to no issue.

In addition to value objects (ints, bools, floats, strings), the Type library also supports object casting. While technically casting one object to another is not a true cast, QType::Cast does at least ensure that the tap being "casted" to is a legitamate subclass of the object being "cast". So if you have ParentClass, and you have a ChildClass that extends ParentClass, $objChildClass = new ChildClass(); $objParentClass = new ParentClass(); Type::Cast($objChildClass, 'ParentClass'); // is a legal cast Type::Cast($objParentClass, 'ChildClass'); // will throw an InvalidCastException

For values, specifically int to string conversion, one different between QType::Cast and PHP (in order to add structure) is that if an integer contains alpha characters, PHP would normally allow that through w/o complaint, simply ignoring any numeric characters past the first alpha character. QType::Cast would instead throw an InvalidCastException to let the developer immedaitely know that something doesn't look right.

In theory, the type library should maintain the same level of flexibility PHP developers are accostomed to, while providing a mechanism to limit careless coding errors and tough to figure out mistakes due to PHP's sometimes overly laxed type conversions.


Constructor & Destructor Documentation

QType::__construct (  )  [final]

This faux constructor method throws a caller exception. The Type object should never be instantiated, and this constructor override simply guarantees it.

Returns:
void


Member Function Documentation

static QType::Cast ( mixItem,
strType 
) [static, final]

Used to cast a variable to another type. Allows for moderate support of strongly-named types.

Will throw an exception if the cast fails, causes unexpected side effects, if attempting to cast an object to a value (or vice versa), or if an object is being cast to a class that isn't a subclass (e.g. parent). The exception thrown will be an InvalidCastException, which extends CallerException.

Parameters:
mixed $mixItem the value, array or object that you want to cast
string $strType the type to cast to. Can be a QType::XXX constant (e.g. QType::Integer), or the name of a Class
Returns:
mixed the passed in value/array/object that has been cast to strType

References ArrayType, Boolean, CastArrayTo(), CastObjectTo(), CastValueTo(), Float, QCallerException::IncrementOffset(), Integer, Object, Resource, and String.

Referenced by QEvent::__construct(), QToggleEnableAction::__construct(), QToggleDisplayAction::__construct(), QUpdateUtility::__construct(), QQLimitInfo::__construct(), QQConditionNotBetween::__construct(), QQConditionBetween::__construct(), QQConditionNotLike::__construct(), QQConditionLike::__construct(), QQConditionNotIn::__construct(), QQConditionIn::__construct(), QQConditionLogical::__construct(), QDatabaseBase::__construct(), QCryptography::__construct(), QSqlServerDatabaseField::__construct(), QMySqlDatabaseField::__construct(), QSampleControl::__set(), QPaginator::__set(), QWriteBox::__set(), QWaitIcon::__set(), QTreeNavItem::__set(), QTreeNav::__set(), QTextBoxBase::__set(), QRadioButtonList::__set(), QRadioButton::__set(), QPaginatorBase::__set(), QPaginatedControl::__set(), QListItemStyle::__set(), QListItem::__set(), QListControl::__set(), QListBoxBase::__set(), QLinkButton::__set(), QIntegerTextBox::__set(), QImageRollover::__set(), QImageLabelBase::__set(), QImageControlBase::__set(), QImageButton::__set(), QImageBase::__set(), QFormBase::__set(), QFloatTextBox::__set(), QFileAssetBase::__set(), QDialogBox::__set(), QDateTimeTextBox::__set(), QDateTimePicker::__set(), QDataRepeater::__set(), QDataGridRowStyle::__set(), QDataGridColumn::__set(), QDataGridBase::__set(), QControlLabel::__set(), QControlBase::__set(), QCheckBoxList::__set(), QCheckBox::__set(), QCalendarPopup::__set(), QCalendar::__set(), QButtonBase::__set(), QBlockControl::__set(), QAction::__set(), QSoapMethod::__set(), QSoapParameter::__set(), QRssItem::__set(), QRssFeed::__set(), QEmailMessage::__set(), QDateTimeSpan::__set(), QDateTime::__set(), QTypeTable::__set(), QTable::__set(), QReverseReference::__set(), QReference::__set(), QManyToManyReference::__set(), QIndex::__set(), QColumn::__set(), QCodeGenBase::__set(), QDataGridBase::AddColumnAt(), QListControl::AddItem(), QListControl::AddItemAt(), CastObjectTo(), QCodeGenBase::GenerateFile(), QSqlServerDatabaseRow::GetColumn(), QPostgreSqlDatabaseRow::GetColumn(), QMySqliDatabaseRow::GetColumn(), QListControl::GetItem(), QImageLabelBase::GetStyleAttributes(), QControlBase::GetStyleAttributes(), QCodeGenBase::LookupSetting(), QDataGridBase::OverrideRowStyle(), QPaginatorBase::Page_Click(), QFileControl::ParsePostData(), QSqlServerDatabase::Query(), QDataGridBase::RemoveColumn(), QListControl::RemoveItem(), QControlBase::RenderOutput(), QDateTime::setDate(), QDateTime::setTime(), QDataGridBase::Sort_Click(), QFormBase::Unserialize(), QIntegerTextBox::Validate(), and QFloatTextBox::Validate().

static QType::CastArrayTo ( arrItem,
strType 
) [static, private]

References ArrayType.

Referenced by Cast().

static QType::CastObjectTo ( objItem,
strType 
) [static, private]

static QType::CastValueTo ( mixItem,
strType 
) [static, private]

References Boolean, Float, Integer, String, and TypeFromDoc().

Referenced by Cast().

static QType::Constant ( strType  )  [static, final]

Used by the Qcodo Code Generator to allow for the code generation of the actual "Type::Xxx" constant, instead of the text of the constant, in generated code.

It is rare for Constant to be used manually outside of Code Generation.

Parameters:
string $strType the type to convert to 'constant' form
Returns:
string the text of the Text:Xxx Constant

References ArrayType, Boolean, DateTime, Float, Integer, Object, Resource, and String.

Referenced by QDatabaseCodeGen::AnalyzeTableColumn().

static QType::SoapType ( strType  )  [static, final]

Used by the Qcodo Code Generator and QSoapService class to allow for the xml generation of the actual "s:type" Soap Variable types.

Parameters:
string $strType the type to convert to 'constant' form
Returns:
string the text of the SOAP standard s:type variable type

References ArrayType, Boolean, DateTime, Float, Integer, Object, Resource, and String.

Referenced by QSoapParameter::GetWsdlMessagePart().

static QType::TypeFromDoc ( strType  )  [static, final]


Member Data Documentation

const QType::Resource = 'resource'

Referenced by Cast(), Constant(), and SoapType().

const QType::String = 'string'

Referenced by QEvent::__construct(), QQConditionNotBetween::__construct(), QQConditionBetween::__construct(), QQConditionNotLike::__construct(), QQConditionLike::__construct(), QSampleControl::__set(), QPaginator::__set(), QWriteBox::__set(), QWaitIcon::__set(), QTreeNavItem::__set(), QTreeNav::__set(), QTextBoxBase::__set(), QRadioButtonList::__set(), QRadioButton::__set(), QPaginatedControl::__set(), QListItemStyle::__set(), QListItem::__set(), QListBoxBase::__set(), QLinkButton::__set(), QIntegerTextBox::__set(), QImageRollover::__set(), QImageLabelBase::__set(), QImageControlBase::__set(), QImageButton::__set(), QImageBase::__set(), QFormBase::__set(), QFloatTextBox::__set(), QFileAssetBase::__set(), QDialogBox::__set(), QDateTimeTextBox::__set(), QDateTimePicker::__set(), QDataRepeater::__set(), QDataGridRowStyle::__set(), QDataGridColumn::__set(), QDataGridBase::__set(), QControlLabel::__set(), QControlBase::__set(), QCheckBoxList::__set(), QCheckBox::__set(), QCalendarPopup::__set(), QButtonBase::__set(), QBlockControl::__set(), QSoapMethod::__set(), QSoapParameter::__set(), QRssItem::__set(), QRssFeed::__set(), QEmailMessage::__set(), QTypeTable::__set(), QTable::__set(), QReverseReference::__set(), QReference::__set(), QManyToManyReference::__set(), QIndex::__set(), QColumn::__set(), QCodeGenBase::__set(), Cast(), CastObjectTo(), CastValueTo(), Constant(), QCodeGenBase::FormControlTypeForColumn(), QCodeGenBase::GenerateFile(), QSqlServerDatabaseRow::GetColumn(), QPostgreSqlDatabaseRow::GetColumn(), QMySqliDatabaseRow::GetColumn(), QSoapParameter::IsObject(), QCodeGenBase::LookupSetting(), QConvertNotationBase::PrefixFromType(), QControlBase::RenderHelper(), SoapType(), TypeFromDoc(), and QCodeGenBase::VariableTypeFromDbType().


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