本文整理汇总了PHP中QType::Cast方法的典型用法代码示例。如果您正苦于以下问题:PHP QType::Cast方法的具体用法?PHP QType::Cast怎么用?PHP QType::Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QType
的用法示例。
在下文中一共展示了QType::Cast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __set
public function __set($strName, $mixValue)
{
//$this->blnModified = true;
switch ($strName) {
case "ReadyFunction":
// The name of a javascript function to call after the CKEditor instance is ready, so that you can do further initialization
// This function will receive the formId and controlId as parameters, and "this" will be the ckeditor instance.
try {
$this->strJsReadyFunc = \QType::Cast($mixValue, \QType::String);
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
break;
case "Configuration":
// The configuration string. Could be a name of an object, or a javascript object (sourrounded by braces {})
try {
$this->strConfiguration = \QType::Cast($mixValue, \QType::String);
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
break;
default:
try {
parent::__set($strName, $mixValue);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
break;
}
}
示例2: __set
public function __set($strName, $mixValue)
{
switch ($strName) {
case "Lat":
try {
return $this->fltLat = QType::Cast($mixValue, QType::Float);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case "Long":
try {
return $this->fltLong = QType::Cast($mixValue, QType::Float);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
default:
try {
return parent::__set($strName, $mixValue);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
示例3: __set
public function __set($strName, $mixValue)
{
switch ($strName) {
case '_ResizeData':
// Internal only. Do not use. Called by qcubed.resizable to keep track of changes.
try {
$data = QType::Cast($mixValue, QType::ArrayType);
$this->aryOriginalSize = $data['originalSize'];
$this->aryNewSize = $data['size'];
// update dimensions
$this->Width = $this->aryNewSize['width'];
$this->Height = $this->aryNewSize['height'];
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
default:
try {
parent::__set($strName, $mixValue);
break;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
示例4: __set
public function __set($strName, $mixValue)
{
$this->blnModified = true;
switch ($strName) {
// APPEARANCE
case "Text":
try {
$this->strText = QType::Cast($mixValue, QType::String);
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case "HtmlEntities":
try {
$this->blnHtmlEntities = QType::Cast($mixValue, QType::Boolean);
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
default:
try {
parent::__set($strName, $mixValue);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
break;
}
}
示例5: testCasting
public function testCasting()
{
define('_FAIL_', 'fail');
$cases = array(array("25.0", "25.0", (double) 25.0, QType::Float), array("25.1", "25.1", (double) 25.1, QType::Float), array(25.0, "25.0", (double) 25.0, QType::Float), array(25.1, "25.1", (double) 25.1, QType::Float), array(true, "true", _FAIL_, QType::Float), array("true", "true", _FAIL_, QType::Float), array(false, "false", _FAIL_, QType::Float), array("false", "false", _FAIL_, QType::Float), array(1, "1", (double) 1, QType::Float), array(0, "0", (double) 0, QType::Float), array("1", "1", (double) 1, QType::Float), array("0", "0", (double) 0, QType::Float), array("25", "25", (double) 25, QType::Float), array(25, "25", (double) 25, QType::Float), array(34.51666666667, "34.51666666667", (double) 34.51666666667, QType::Float), array(2147483648, "2147483648", (double) 2147483648, QType::Float), array(-2147483648, "-2147483648", (double) -2147483648, QType::Float), array(-2147483649, "-2147483649", (double) -2147483649, QType::Float), array("34.51666666667", "34.51666666667", (double) 34.51666666667, QType::Float), array("2147483648", "2147483648", (double) 2147483648.0, QType::Float), array("-2147483648", "-2147483648", (double) -2147483648.0, QType::Float), array("-2147483649", "-2147483649", (double) -2147483649.0, QType::Float), array("25.0", "25.0", _FAIL_, QType::Integer), array("25.1", "25.1", _FAIL_, QType::Integer), array(25.0, "25.0", (int) 25, QType::Integer), array(25.1, "25.1", _FAIL_, QType::Integer), array(true, "true", _FAIL_, QType::Integer), array("true", "true", _FAIL_, QType::Integer), array(false, "false", _FAIL_, QType::Integer), array("false", "false", _FAIL_, QType::Integer), array(1, "1", 1, QType::Integer), array(0, "0", 0, QType::Integer), array("1", "1", 1, QType::Integer), array("0", "0", 0, QType::Integer), array("25", "25", 25, QType::Integer), array(25, "25", 25, QType::Integer), array(34.51666666667, "34.51666666667", _FAIL_, QType::Integer), array(2147483648, "2147483648", 2147483648, QType::Integer), array(-2147483648, "-2147483648", (int) -2147483648, QType::Integer), array(-2147483649, "-2147483649", -2147483649, QType::Integer), array("34.51666666667", "34.51666666667", _FAIL_, QType::Integer), array("2147483648", "2147483648", 2147483648, QType::Integer), array("-2147483648", "-2147483648", (int) -2147483648, QType::Integer), array("-2147483649", "-2147483649", -2147483649, QType::Integer), array(1.8446744073709552E+21, "1844674407370955161616", (double) 1.8446744073709552E+21, QType::Float), array(1.8446744073709552E+21, "1844674407370955161616", "fail", QType::Integer), array("1844674407370955161616", "1844674407370955161616", "1844674407370955161616", QType::Float), array("1844674407370955161616", "1844674407370955161616", "1844674407370955161616", QType::Integer), array(6, '6', '6', QType::String), array(6.94, '6.94', '6.94', QType::String), array(0.694 * 10, '6.94', '6.94', QType::String));
foreach ($cases as $case) {
$value = (string) $case[1] . '(' . gettype($case[0]) . ')';
if ($case[2] === _FAIL_) {
try {
QType::Cast($case[0], $case[3]);
$this->fail("Excepted exception was not thrown casting " . $value . " to " . $case[3]);
} catch (QInvalidCastException $e) {
$this->pass("Casting " . $value . " to " . $case[3] . " caused a QInvalidCastException");
unset($e);
}
} else {
try {
$castValue = QType::Cast($case[0], $case[3]);
$newValue = $castValue . '(' . gettype($castValue) . ')';
$this->assertIdentical($castValue, $case[2], "{$value} cast as a " . $case[3] . " is {$newValue}");
} catch (Exception $e) {
$this->fail("Exception caused when casting {$value} to " . $case[3] . ": {$e->getMessage()}");
}
}
}
}
示例6: __set
public function __set($strName, $mixValue)
{
$this->blnModified = true;
switch ($strName) {
case "Query":
try {
$this->strQuery = QType::Cast($mixValue, QType::String);
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case "TotalQuery":
try {
$this->strTotalQuery = QType::Cast($mixValue, QType::String);
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
default:
try {
parent::__set($strName, $mixValue);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
break;
}
}
示例7: __set
public function __set($strName, $mixValue)
{
switch ($strName) {
case "Once":
try {
return $this->blnOnce = QType::Cast($mixValue, QType::Boolean);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case "Rendered":
try {
return $this->blnRendered = QType::Cast($mixValue, QType::Boolean);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case "KeyCode":
try {
return $this->strKeyCode = $mixValue;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
default:
try {
return parent::__set($strName, $mixValue);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
示例8: CastObjectTo
private static function CastObjectTo($objItem, $strType)
{
try {
$objReflection = new ReflectionClass($objItem);
if ($objReflection->getName() == 'SimpleXMLElement') {
switch ($strType) {
case QType::String:
return (string) $objItem;
case QType::Integer:
try {
return QType::Cast((string) $objItem, QType::Integer);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case QType::Boolean:
$strItem = strtolower(trim((string) $objItem));
if ($strItem == 'false' || !$strItem) {
return false;
} else {
return true;
}
}
}
if ($objItem instanceof $strType) {
return $objItem;
}
} catch (Exception $objExc) {
}
throw new QInvalidCastException(sprintf('Unable to cast %s object to %s', $objReflection->getName(), $strType));
}
示例9: __set
public function __set($strName, $mixValue)
{
switch ($strName) {
case '_SelectedIndex':
// Internal Only. Used by JS above. Do Not Call.
try {
$this->mixActive = QType::Cast($mixValue, QType::Integer);
// will cause ->Active getter to always return index of content item that is currently active
} catch (QInvalidCastException $objExc) {
try {
$this->mixActive = QType::Cast($mixValue, QType::Boolean);
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
break;
default:
try {
parent::__set($strName, $mixValue);
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
break;
}
}
示例10: __set
public function __set($strName, $mixValue)
{
switch ($strName) {
case "Value":
try {
return $this->strValue = QType::Cast($mixValue, QType::String);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case "Text":
try {
return $this->strText = QType::Cast($mixValue, QType::String);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
case "Selected":
try {
return $this->blnSelected = QType::Cast($mixValue, QType::Boolean);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
default:
try {
return parent::__set($strName, $mixValue);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
示例11: __set
public function __set($strName, $mixValue)
{
switch ($strName) {
case '_ResizeData':
// Internal only. Do not use. Called by JS above to keep track of user selection.
try {
$data = QType::Cast($mixValue, QType::String);
$a = explode(",", $data);
$this->aryOriginalSize['width'] = $a[0];
$this->aryOriginalSize['height'] = $a[1];
$this->aryNewSize['width'] = $a[2];
$this->aryNewSize['height'] = $a[3];
// update dimensions
$this->strWidth = $this->aryNewSize['width'];
$this->strHeight = $this->aryNewSize['height'];
break;
} catch (QInvalidCastException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
default:
try {
parent::__set($strName, $mixValue);
break;
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
}
}
示例12: ConfigureBaseProperties
/**
* Sets up the base-level configuration properties for this database,
* namely DB Profiling and Database Index
*
* @param integer $intDatabaseIndex
* @return void
*/
protected function ConfigureBaseProperties($intDatabaseIndex)
{
// Setup DatabaseIndex
$this->intDatabaseIndex = $intDatabaseIndex;
// Setup Profiling Array (if applicable)
$this->blnEnableProfiling = QType::Cast(QApplication::$ConnectionStringArray[$intDatabaseIndex]['profiling'], QType::Boolean);
if ($this->blnEnableProfiling) {
$this->strProfileArray = array();
}
}
示例13: __construct
public function __construct($strKey = null, $blnBase64 = null, $strCipher = null, $strMode = null)
{
// Get the Key
if (is_null($strKey)) {
$strKey = self::$Key;
}
// Get the Base64 Flag
try {
if (is_null($blnBase64)) {
$this->blnBase64 = QType::Cast(self::$Base64, QType::Boolean);
} else {
$this->blnBase64 = QType::Cast($blnBase64, QType::Boolean);
}
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
throw $objExc;
}
// Get the Cipher
if (is_null($strCipher)) {
$strCipher = self::$Cipher;
}
// Get the Mode
if (is_null($strMode)) {
$strMode = self::$Mode;
}
$this->objMcryptModule = mcrypt_module_open($strCipher, null, $strMode, null);
if (!$this->objMcryptModule) {
throw new QCryptographyException('Unable to open LibMcrypt Module');
}
// Determine IV Size
$intIvSize = mcrypt_enc_get_iv_size($this->objMcryptModule);
// Create the IV
if (self::$RandomSource != MCRYPT_RAND) {
// Ignore All Warnings
set_error_handler('QcodoHandleError', 0);
$intCurrentLevel = error_reporting();
error_reporting(0);
$strIv = mcrypt_create_iv($intIvSize, self::$RandomSource);
error_reporting($intCurrentLevel);
restore_error_handler();
// If the RandomNumGenerator didn't work, we revert back to using MCRYPT_RAND
if (strlen($strIv) != $intIvSize) {
srand();
$strIv = mcrypt_create_iv($intIvSize, MCRYPT_RAND);
}
} else {
srand();
$strIv = mcrypt_create_iv($intIvSize, MCRYPT_RAND);
}
$this->strIv = $strIv;
// Determine KeySize length
$intKeySize = mcrypt_enc_get_key_size($this->objMcryptModule);
// Create the Key Based on Key Passed In
$this->strKey = substr(md5($strKey), 0, $intKeySize);
}
示例14: ParsePostData
public function ParsePostData()
{
// Check to see if this Control's Value was passed in via the POST data
if (array_key_exists($this->strControlId, $_FILES) && $_FILES[$this->strControlId]['tmp_name']) {
// It was -- update this Control's value with the new value passed in via the POST arguments
$this->strFileName = $_FILES[$this->strControlId]['name'];
$this->strType = $_FILES[$this->strControlId]['type'];
$this->intSize = QType::Cast($_FILES[$this->strControlId]['size'], QType::Integer);
$this->strFile = $_FILES[$this->strControlId]['tmp_name'];
}
}
示例15: Initialize
private static function Initialize()
{
self::$intDbIndex = QType::Cast(self::$intDbIndex, QType::Integer);
self::$strTableName = QType::Cast(self::$strTableName, QType::String);
// If the database index exists
if (!array_key_exists(self::$intDbIndex, QApplication::$Database)) {
throw new QCallerException('No database defined at DB_CONNECTION index ' . self::$intDbIndex . '. Correct your settings in configuration.inc.php.');
}
$objDatabase = QApplication::$Database[self::$intDbIndex];
// see if the database contains a table with desired name
if (!in_array(self::$strTableName, $objDatabase->GetTables())) {
throw new QCallerException('Table ' . self::$strTableName . ' not found in database at DB_CONNECTION index ' . self::$intDbIndex . '. Correct your settings in configuration.inc.php.');
}
}