当前位置: 首页>>代码示例>>PHP>>正文


PHP Type::getType方法代码示例

本文整理汇总了PHP中Type::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP Type::getType方法的具体用法?PHP Type::getType怎么用?PHP Type::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Type的用法示例。


在下文中一共展示了Type::getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: WriteTypedXmlValue

 /**
  * Writes all data of the defined Value to the XmlWriter.
  *
  * You can write it in 3 different ways:
  *
  * - <$name type="..." value="..." />
  *   Is created if $short is boolean TRUE.
  *
  * If $short is FALSE you can write in the following 2 ways:
  *
  * - <$name type="...">$value</$name>
  *   Is created if $separateElements is boolean FALSE.
  * - <$name><Type>...</Type><Value>$value</Value></$name>
  *   Is created if $separateElements is boolean TRUE.
  *
  * @param \XMLWriter $w                The XmlWriter to use.
  * @param mixed      $value            The value to write.
  * @param string     $name             The name of the element to write
  * @param boolean    $short            Use the short notation? (type and value as attributes)
  * @param boolean    $separateElements Write type and value in separate elements, if $short is FALSE
  */
 public static function WriteTypedXmlValue(\XMLWriter $w, $value, string $name, bool $short = true, bool $separateElements = false)
 {
     if (!$value instanceof Type) {
         $value = new Type($value);
     }
     $v = null;
     $t = null;
     switch ($value->getType()) {
         case Type::PHP_ARRAY:
             $v = \serialize($value->getValue());
             $t = Type::PHP_ARRAY;
             break;
         case Type::PHP_BOOLEAN:
             $v = $value->getValue() ? 'true' : 'false';
             $t = Type::PHP_BOOLEAN;
             break;
         case Type::PHP_DOUBLE:
         case Type::PHP_FLOAT:
         case Type::PHP_INTEGER:
             $v = $value->getValue();
             $t = $value->getType();
             break;
         case Type::PHP_NULL:
             $v = '';
             $t = Type::PHP_NULL;
             break;
         case Type::PHP_RESOURCE:
             # Ignore some resources
             break;
         case Type::PHP_STRING:
             $v = $value->getValue();
             $t = Type::PHP_STRING;
             break;
         case Type::PHP_UNKNOWN:
             $v = $value->getStringValue();
             $t = Type::PHP_STRING;
             break;
         default:
             $v = \serialize($value->getValue());
             $t = $value->getType();
             break;
     }
     if (!\is_null($t) && !\is_null($v)) {
         $w->startElement($name);
         if ($short) {
             $w->writeAttribute('type', $t);
             $w->writeAttribute('value', $v);
         } else {
             if ($separateElements) {
                 $w->writeElement('type', $t);
                 $w->writeElement('value', $v);
             } else {
                 $w->writeAttribute('type', $t);
                 $w->text($v);
             }
         }
         $w->endElement();
     }
 }
开发者ID:sagittariusx,项目名称:beluga.core,代码行数:80,代码来源:TypeTool.php

示例2: getColumnDeclarationSql

 /**
  * Obtain DBMS specific SQL code portion needed to declare a generic type
  * field to be used in statements like CREATE TABLE.
  *
  * @param string $name   name the field to be declared.
  * @param array  $field  associative array with the name of the properties
  *      of the field being declared as array indexes. Currently, the types
  *      of supported field properties are as follows:
  *
  *      length
  *          Integer value that determines the maximum length of the text
  *          field. If this argument is missing the field should be
  *          declared to have the longest length allowed by the DBMS.
  *
  *      default
  *          Text value to be used as default for this field.
  *
  *      notnull
  *          Boolean flag that indicates whether this field is constrained
  *          to not be set to null.
  *      charset
  *          Text value with the default CHARACTER SET for this field.
  *      collation
  *          Text value with the default COLLATION for this field.
  *      unique
  *          unique constraint
  *      check
  *          column check constraint
  *
  * @return string  DBMS specific SQL code portion that should be used to declare the column.
  */
 public function getColumnDeclarationSql($name, array $field)
 {
     $default = $this->getDefaultValueDeclarationSql($field);
     $charset = isset($field['charset']) && $field['charset'] ? ' ' . $this->getColumnCharsetDeclarationSql($field['charset']) : '';
     $collation = isset($field['collation']) && $field['collation'] ? ' ' . $this->getColumnCollationDeclarationSql($field['collation']) : '';
     $notnull = isset($field['notnull']) && $field['notnull'] ? ' NOT NULL' : '';
     $unique = isset($field['unique']) && $field['unique'] ? ' ' . $this->getUniqueFieldDeclarationSql() : '';
     $check = isset($field['check']) && $field['check'] ? ' ' . $field['check'] : '';
     $typeDecl = Type::getType($field['type'])->getSqlDeclaration($field, $this);
     return '`' . $name . '` ' . $typeDecl . $charset . $default . $notnull . $unique . $check . $collation;
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:42,代码来源:MySqlPlatform.php

示例3: testGetType

 /**
  * @covers Geissler\Converter\Model\Type::getType
  * 
  */
 public function testGetType()
 {
     $this->assertInstanceOf($this->class, $this->object->setArticle());
     $this->assertEquals('article', $this->object->getType());
 }
开发者ID:avvertix,项目名称:converter,代码行数:9,代码来源:TypeTest.php


注:本文中的Type::getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。