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


PHP typeof函数代码示例

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


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


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