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


PHP Type::isEnum方法代码示例

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


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

示例1: getFullQualifiedTypeName

 public static function getFullQualifiedTypeName(FieldDescriptorProto $field, DescriptorProto $descriptor, FileDescriptorProto $file)
 {
     if (FieldDescriptorProto\Type::isMessage($field) || FieldDescriptorProto\Type::isEnum($field)) {
         $name = $field->getTypeName();
         if (strlen($name) < 1) {
             return null;
         }
         if ($name[0] == ".") {
             $name = Helper::getPackageName($file) . $name;
         } else {
             $name = $descriptor->package_name . $name;
         }
     } else {
         $name = $field->getTypeName();
     }
     return $name;
 }
开发者ID:melanc,项目名称:devel,代码行数:17,代码来源:Helper.php

示例2: printProperties

 public function printProperties(Printer $printer)
 {
     if ($this->descriptor->getOptions()->getExtension("php_option")->getUseSingleProperty()) {
         $printer->put("/** @var array \$`var` */\n", "var", $this->descriptor->getOptions()->getExtension("php_option")->getSinglePropertyName());
         $printer->put("protected \$`var` = array();\n", "var", $this->descriptor->getOptions()->getExtension("php_option")->getSinglePropertyName());
     } else {
         foreach ($this->descriptor->getField() as $field) {
             /* @var $field \google\protobuf\FieldDescriptorProto */
             $printer->put("/**\n");
             if ($dict = SourceInfoDictionary::get($this->descriptor->file()->getName(), $this->descriptor->getName(), $field->getName())) {
                 /* @var $dict \google\protobuf\SourceCodeInfo\Location */
                 if ($dict->getLeadingComments()) {
                     $lines = preg_split("/\r?\n/", trim($dict->getLeadingComments()));
                     foreach ($lines as $line) {
                         $line = Helper::cleanupComment($line);
                         $printer->put(" * `comment`\n", "comment", $line);
                     }
                     $printer->put(" *\n");
                 }
             }
             $printer->put(" * @var `type` \$`var`\n", "type", $this->getTypeName($field), "var", $field->getName());
             $printer->put(" * @tag `tag`\n", "tag", $field->getNumber());
             $printer->put(" * @label `required`\n", "required", FieldDescriptorProto\Label::isRequired($field) ? "required" : "optional");
             $printer->put(" * @type `type`\n", "type", Helper::getFieldTypeName($field));
             if (FieldDescriptorProto\Label::isRepeated($field) && FieldDescriptorProto\Type::isMessage($field) || FieldDescriptorProto\Type::isEnum($field)) {
                 $printer->put(" * @see `see`\n", "see", Helper::getClassName($field, true));
             }
             if ($dict = SourceInfoDictionary::get($this->descriptor->file()->getName(), $this->descriptor->getName(), $field->getName())) {
                 /* @var $dict \google\protobuf\SourceCodeInfo\Location */
                 if ($dict->getTrailingComments()) {
                     $printer->put(" *\n");
                     $lines = preg_split("/\r?\n/", trim($dict->getTrailingComments()));
                     foreach ($lines as $line) {
                         $printer->put(" * `comment`\n", "comment", Helper::cleanupComment($line));
                     }
                     $printer->put(" *\n");
                 }
             }
             $printer->put(" **/\n");
             $printer->put("protected \$`name`;\n", "name", $field->getName());
             $printer->put("\n");
         }
     }
     $printer->put("\n");
     $printer->put("// @@protoc_insertion_point(properties_scope:`name`)\n\n", "name", $this->descriptor->full_name);
 }
开发者ID:asamaru7,项目名称:protoc-gen-php,代码行数:46,代码来源:MessageGenerator.php


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