• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP typeof函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中typeof函数的典型用法代码示例。如果您正苦于以下问题:PHP typeof函数的具体用法?PHP typeof怎么用?PHP typeof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: usage

 function usage()
 {
     $f = FsObject::get(base::appPath());
     $usage = $f->getDiskUsage(true);
     $this->assertNotNull($usage);
     $this->assertEquals(typeof($usage), 'array');
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:7,代码来源:filesystem.php


示例2: display

 /**
  * Display information
  *
  * @param  io.StringWriter $out
  * @return void
  */
 public function display($out)
 {
     $out->write(self::declarationOf($this->mirror));
     $parent = $this->mirror->parent();
     if ('lang.Enum' !== $parent->name()) {
         $this->displayExtensions([$parent], $out, 'extends');
     }
     $this->displayExtensions($this->mirror->interfaces()->declared(), $out, 'implements');
     $separator = false;
     $out->writeLine(' {');
     $this->displayMembers($this->mirror->constants(), $out, $separator);
     foreach (Enum::valuesOf($this->mirror->type()) as $member) {
         $out->write('  ', $member->name(), '(', $member->ordinal(), ')');
         $mirror = new TypeMirror(typeof($member));
         if ($mirror->isSubtypeOf($this->mirror)) {
             $out->writeLine(' {');
             foreach ($mirror->methods()->declared() as $method) {
                 $out->writeLine('    ', (string) $method);
             }
             $separator = true;
             $out->writeLine('  }');
         } else {
             $out->writeLine();
             $separator = true;
         }
     }
     $constructor = $this->mirror->constructor();
     if ($constructor->present()) {
         $this->displayMembers([$constructor], $out, $separator);
     }
     $this->displayMembers($this->mirror->methods()->all(Methods::ofClass()), $out, $separator);
     $this->displayMembers($this->mirror->methods()->all(Methods::ofInstance()), $out, $separator);
     $out->writeLine('}');
 }
开发者ID:xp-forge,项目名称:mirrors,代码行数:40,代码来源:EnumInformation.class.php


示例3: __construct

 /**
  * Creates a new injector optionally given initial bindings
  *
  * @param  inject.Bindings... $initial
  */
 public function __construct(...$initial)
 {
     $this->bind(typeof($this), $this);
     foreach ($initial as $bindings) {
         $this->add($bindings);
     }
 }
开发者ID:xp-forge,项目名称:inject,代码行数:12,代码来源:Injector.class.php


示例4: creating_instances_invokes_constructor

 public function creating_instances_invokes_constructor()
 {
     $fixture = newinstance(Object::class, [], '{
   public $passed= null;
   public function __construct(... $args) { $this->passed= $args; }
 }');
     $this->assertEquals([1, 2, 3], (new Constructor(new TypeMirror(typeof($fixture))))->newInstance(1, 2, 3)->passed);
 }
开发者ID:xp-forge,项目名称:mirrors,代码行数:8,代码来源:ConstructorTest.class.php


示例5: __construct

 /**
  * Creates a new instance mirror
  *
  * @param  var $value
  */
 public function __construct($value)
 {
     if (is_object($value)) {
         // Parent constructor inlined
         $this->reflect = Sources::$REFLECTION->reflect(new \ReflectionObject($value));
     } else {
         throw new IllegalArgumentException('Given value is not an object, ' . typeof($value) . ' given');
     }
 }
开发者ID:xp-forge,项目名称:mirrors,代码行数:14,代码来源:InstanceMirror.class.php


示例6: __construct

 public function __construct($streamuri, $mode = 'r', $context = null)
 {
     $this->uri = $streamuri;
     if (typeof($context) == 'StreamContext') {
         $ctx = $context->getContext();
     } else {
         $ctx = $context;
     }
     if ($ctx) {
         $this->fh = fopen($streamuri, $mode, null, $ctx);
     } else {
         $this->fh = fopen($streamuri, $mode);
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:14,代码来源:streams.php


示例7: __construct

 /**
  * Constructor
  *
  * @param   string $arg Either a name or the file descriptor
  */
 public function __construct($arg)
 {
     if ('stdin' === $arg || 'input' === $arg) {
         if (!($this->fd = fopen('php://' . $arg, 'rb'))) {
             throw new IOException('Could not open ' . $arg . ' channel for reading');
         }
     } else {
         if (is_resource($arg)) {
             $this->fd = $arg;
             $this->name = '#' . (int) $arg;
         } else {
             throw new IOException('Expecting either stdin, input or a file descriptor ' . typeof($arg) . ' given');
         }
     }
 }
开发者ID:johannes85,项目名称:core,代码行数:20,代码来源:ChannelInputStream.class.php


示例8: toString

 public static function toString($var)
 {
     $type = typeof($var);
     switch ($type) {
         case 'boolean':
             if ($var == true) {
                 return "true";
             } else {
                 return "false";
             }
             break;
         default:
             return strval($var);
             break;
     }
 }
开发者ID:odin3,项目名称:MoyService,代码行数:16,代码来源:convert.php


示例9: __toString

 /**
  * @brief Return the CSS code for the rule
  *
  * @return String The CSS code for the rule
  */
 function __toString()
 {
     $rules = array();
     foreach ($this->attributes as $key => $rule) {
         if (typeof($rule) == 'array') {
             foreach ($rule as $rulesub) {
                 $rules[] = $key . ':' . $rulesub . ';';
             }
         } else {
             $rules[] = $key . ':' . $rule . ';';
         }
     }
     $rulestr = '{' . join(' ', $rules) . '}';
     $ret = $this->selector . $rulestr;
     return $ret;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:21,代码来源:css.php


示例10: string

function string($n)
{
    if (js()) {
        if (typeof($n) === "number") {
            return Number($n) . toString();
        } else {
            if (typeof($n) === "undefined") {
                return "";
            } else {
                return $n . toString();
            }
        }
    } else {
        return "" . $n;
    }
}
开发者ID:tantek,项目名称:cassis,代码行数:16,代码来源:cassis.php


示例11: pointer

 /**
  * Helper method to retrieve a pointer inside a given data structure
  * using a given segment. Returns null if there is no such segment.
  *
  * @param  var $ptr
  * @param  string $segment
  * @return var
  */
 protected function pointer($ptr, $segment)
 {
     if ($ptr instanceof \ArrayAccess) {
         return $ptr->offsetExists($segment) ? $ptr->offsetGet($segment) : null;
     } else {
         if (is_object($ptr)) {
             $class = typeof($ptr);
             // 1. Try public field named <segment>
             if ($class->hasField($segment)) {
                 $field = $class->getField($segment);
                 if ($field->getModifiers() & MODIFIER_PUBLIC) {
                     return $field->get($ptr);
                 }
             }
             // 2. Try public method named <segment>
             if ($class->hasMethod($segment)) {
                 $method = $class->getMethod($segment);
                 if ($method->getModifiers() & MODIFIER_PUBLIC) {
                     return $method->invoke($ptr);
                 }
             }
             // 3. Try accessor named get<segment>()
             if ($class->hasMethod($getter = 'get' . $segment)) {
                 $method = $class->getMethod($getter);
                 if ($method->getModifiers() & MODIFIER_PUBLIC) {
                     return $method->invoke($ptr);
                 }
             }
             // Non applicable - give up
             return null;
         } else {
             if (isset($ptr[$segment])) {
                 return $ptr[$segment];
             } else {
                 if ('length' === $segment) {
                     return sizeof($ptr);
                 } else {
                     return null;
                 }
             }
         }
     }
 }
开发者ID:xp-forge,项目名称:mustache,代码行数:51,代码来源:DataContext.class.php


示例12: helper

 /**
  * Returns helper
  *
  * @param  var $ptr
  * @param  string $segment
  * @return var
  */
 protected function helper($ptr, $segment)
 {
     if ($ptr instanceof \Closure) {
         return $ptr;
     } else {
         if (is_object($ptr)) {
             $class = typeof($ptr);
             if ($class->hasMethod($segment)) {
                 $method = $class->getMethod($segment);
                 return function ($in, $ctx, $options) use($ptr, $method) {
                     return $method->invoke($ptr, [$in, $ctx, $options]);
                 };
             }
             return null;
         } else {
             return isset($ptr[$segment]) ? $ptr[$segment] : null;
         }
     }
 }
开发者ID:xp-forge,项目名称:mustache,代码行数:26,代码来源:Context.class.php


示例13: serve

 /**
  * Serve requests
  *
  * @param  string $source
  * @param  string $profile
  * @param  io.Path $webroot
  * @param  io.Path $docroot
  * @param  string[] $config
  */
 public function serve($source, $profile, $webroot, $docroot, $config)
 {
     $runtime = Runtime::getInstance();
     $startup = $runtime->startupOptions();
     $backing = typeof($startup)->getField('backing')->setAccessible(true)->get($startup);
     // PHP doesn't start with a nonexistant document root
     if (!$docroot->exists()) {
         $docroot = getcwd();
     }
     // Start `php -S`, the development webserver
     $arguments = ['-S', $this->host . ':' . $this->port, '-t', $docroot];
     $options = newinstance(RuntimeOptions::class, [$backing], ['asArguments' => function () use($arguments) {
         return array_merge($arguments, parent::asArguments());
     }]);
     $options->withSetting('user_dir', $source . PATH_SEPARATOR . implode(PATH_SEPARATOR, $config));
     // Pass classpath (TODO: This is fixed in XP 7.6.0, remove once
     // this becomes minimum dependency)
     $cp = [];
     foreach (ClassLoader::getLoaders() as $delegate) {
         if ($delegate instanceof FileSystemClassLoader || $delegate instanceof ArchiveClassLoader) {
             $cp[] = $delegate->path;
         }
     }
     set_include_path('');
     $options->withClassPath($cp);
     // Export environment
     putenv('DOCUMENT_ROOT=' . $docroot);
     putenv('WEB_ROOT=' . $webroot);
     putenv('SERVER_PROFILE=' . $profile);
     Console::writeLine("[33m@", $this, "[0m");
     Console::writeLine("[1mServing ", (new Source($source, new Config($config)))->layout());
     Console::writeLine("[36m", str_repeat('═', 72), "[0m");
     Console::writeLine();
     with($runtime->newInstance($options, 'web', '', []), function ($proc) {
         $proc->in->close();
         Console::writeLine("[33;1m>[0m Server started: [35;4m", $this->url, "[0m (", date('r'), ')');
         Console::writeLine('  PID ', $proc->getProcessId(), '; press Ctrl+C to exit');
         Console::writeLine();
         while (is_string($line = $proc->err->readLine())) {
             Console::writeLine("  [36m", $line, "[0m");
         }
     });
 }
开发者ID:xp-framework,项目名称:scriptlet,代码行数:52,代码来源:Develop.class.php


示例14: printValue

 protected function printValue($key, $val, $inst = 0)
 {
     $defs = $this->conf->getDefs($key);
     if (arr::hasKey($defs, 'vartype')) {
         $typeset = $defs['vartype'];
     } else {
         $typeset = typeof($val);
     }
     if ($inst == 0) {
         printf(__astr("'\\b{%s}' = \\g{%s(}"), $key, $typeset);
     }
     if (typeof($val) == 'array') {
         foreach ($val as $k => $v) {
             $this->printValue($k, $v, $inst + 1);
         }
     } else {
         switch ($typeset) {
             case 'boolean':
                 if ($val) {
                     printf(__astr("\\c{ltcyan true}"));
                 } else {
                     printf(__astr("(\\c{cyan false})"));
                 }
                 break;
             case 'NULL':
                 printf(__astr("\\c{red NULL}"));
                 break;
             case 'integer':
                 printf(__astr("\\c{cyan %d}"), $val);
                 break;
             case 'float':
                 printf(__astr("\\c{cyan %.2f}"), $val);
                 break;
             default:
                 printf(__astr("\\c{yellow '%s'}"), $val);
         }
         if ($inst == 0) {
             printf(__astr("\\g{)} "));
         }
         printf(__astr("  \\c{ltgreen //} \\c{green %s}"), $defs['description']);
         printf("\n");
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:43,代码来源:clihelper.php


示例15: comment

 function comment($comment, $entities = [], $args = array())
 {
     $_comment = '';
     if (is_array($comment)) {
         $entities = [];
         foreach ($comment as $element) {
             if (typeof($element) == 'string') {
                 $_comment .= $element;
             } else {
                 $entity = new \stdClass();
                 $entity->id = $element->id;
                 $entity->range = [strlen($_comment), strlen($_comment) + strlen($element->name)];
                 $entity->type = 'mention';
                 $entity->title = $element->name;
                 $_comment .= $element->name + ' ';
                 $entities[] = $entity;
             }
         }
     } else {
         $_comment = $comment;
     }
     $args['post_id'] = $this->id;
     $args['comment'] = $_comment;
     $args['entities'] = $entities;
     $post = $this->api->comment($args);
     $post->post = $this;
     return $post;
 }
开发者ID:FameBit,项目名称:vinephp,代码行数:28,代码来源:Models.php


示例16: object_type_union_isAssignableFrom_this_class

 public function object_type_union_isAssignableFrom_this_class()
 {
     $this->assertTrue(Type::$OBJECT->isAssignableFrom(typeof($this)));
 }
开发者ID:xp-framework,项目名称:core,代码行数:4,代码来源:TypeTest.class.php


示例17: type

 public function type()
 {
     $this->assertEquals(typeof($this), (new TypeMirror(self::class))->type());
 }
开发者ID:xp-forge,项目名称:mirrors,代码行数:4,代码来源:TypeMirrorTest.class.php


示例18: handle

 /**
  * Handle routing item
  *
  * @param  lang.Oject instance
  * @param  lang.reflect.Method method
  * @param  var[] args
  * @param  webservices.rest.srv.RestContext context
  * @return webservices.rest.srv.Response
  */
 public function handle($instance, $method, $args)
 {
     foreach ($args as $i => $arg) {
         $args[$i] = $this->unmarshal(typeof($arg), $arg);
     }
     // HACK: Ungeneric XML-related
     $properties = array();
     if ($method->hasAnnotation('xmlfactory', 'element')) {
         $properties['name'] = $method->getAnnotation('xmlfactory', 'element');
     } else {
         if (($class = $method->getDeclaringClass()) && $class->hasAnnotation('xmlfactory', 'element')) {
             $properties['name'] = $class->getAnnotation('xmlfactory', 'element');
         }
     }
     // Invoke the method
     try {
         $result = $method->invoke($instance, $args);
         $this->cat && $this->cat->debug('<-', $result);
     } catch (TargetInvocationException $e) {
         $this->cat && $this->cat->warn('<-', $e);
         return $this->mapException($e->getCause());
     }
     // For "VOID" methods, set status to "no content". If a response is returned,
     // use its status, headers and payload. For any other methods, set status to "OK".
     if (Type::$VOID->equals($method->getReturnType())) {
         return Response::status(HttpConstants::STATUS_NO_CONTENT);
     } else {
         if ($result instanceof webservices·rest·srv·Output) {
             $result->payload = $this->marshal($result->payload, $properties);
             return $result;
         } else {
             return Response::status(HttpConstants::STATUS_OK)->withPayload($this->marshal(new Payload($result), $properties));
         }
     }
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:44,代码来源:RestContext.class.php


示例19: type

 public function type()
 {
     $this->assertEquals(typeof($this), (new InstanceMirror($this))->type());
 }
开发者ID:xp-forge,项目名称:mirrors,代码行数:4,代码来源:InstanceMirrorTest.class.php


示例20: marshal

 /**
  * Convert value
  *
  * @param   var value
  * @return  var
  */
 public function marshal($value)
 {
     if ($value instanceof \util\Date) {
         return $value->toString('c');
         // ISO 8601, e.g. "2004-02-12T15:19:21+00:00"
     } else {
         if ($value instanceof \Traversable) {
             return new Iteration($value, [$this, 'marshal']);
         } else {
             if (is_object($value)) {
                 foreach ($this->marshallers->keys() as $t) {
                     // Specific class marshalling
                     if ($t->isInstance($value)) {
                         return $this->marshallers[$t]->marshal($value, $this);
                     }
                 }
                 $class = typeof($value);
                 $r = [];
                 foreach ($class->getFields() as $field) {
                     $m = $field->getModifiers();
                     if ($m & MODIFIER_STATIC) {
                         continue;
                     } else {
                         if ($field->getModifiers() & MODIFIER_PUBLIC) {
                             $r[$field->getName()] = $this->marshal($field->get($value));
                         } else {
                             foreach ($this->variantsOf($field->getName()) as $name) {
                                 if ($class->hasMethod($m = 'get' . $name)) {
                                     $r[$field->getName()] = $this->marshal($class->getMethod($m)->invoke($value));
                                     continue 2;
                                 }
                             }
                         }
                     }
                 }
                 return $r;
             } else {
                 if (is_array($value)) {
                     $r = [];
                     foreach ($value as $key => $val) {
                         $r[$key] = $this->marshal($val);
                     }
                     return $r;
                 }
             }
         }
     }
     return $value;
 }
开发者ID:xp-framework,项目名称:rest,代码行数:55,代码来源:RestMarshalling.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP types_get_field函数代码示例发布时间:2022-05-23
下一篇:
PHP type_to_str函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap