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


PHP ReflectionObject::isAnonymous方法代码示例

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


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

示例1: isComparable

 public function isComparable(AbstractSnapshot $snapshot)
 {
     $refl = new \ReflectionObject($snapshot);
     return $refl->isAnonymous() || parent::isComparable($snapshot);
 }
开发者ID:wisembly,项目名称:totem,代码行数:5,代码来源:AbstractSnapshotTest.php

示例2: _toPhp

 /**
  * @return string
  */
 private static function _toPhp(&$var, &$list = array(), $level = 0, &$line = 1)
 {
     if (is_float($var)) {
         $var = str_replace(',', '.', "{$var}");
         return strpos($var, '.') === FALSE ? $var . '.0' : $var;
     } elseif (is_bool($var)) {
         return $var ? 'TRUE' : 'FALSE';
     } elseif (is_string($var) && (preg_match('#[^\\x09\\x20-\\x7E\\xA0-\\x{10FFFF}]#u', $var) || preg_last_error())) {
         static $table;
         if ($table === NULL) {
             foreach (array_merge(range("", ""), range("", "ÿ")) as $ch) {
                 $table[$ch] = '\\x' . str_pad(dechex(ord($ch)), 2, '0', STR_PAD_LEFT);
             }
             $table['\\'] = '\\\\';
             $table["\r"] = '\\r';
             $table["\n"] = '\\n';
             $table["\t"] = '\\t';
             $table['$'] = '\\$';
             $table['"'] = '\\"';
         }
         return '"' . strtr($var, $table) . '"';
     } elseif (is_array($var)) {
         $space = str_repeat("\t", $level);
         static $marker;
         if ($marker === NULL) {
             $marker = uniqid("", TRUE);
         }
         if (empty($var)) {
             $out = '';
         } elseif ($level > self::$maxDepth || isset($var[$marker])) {
             return '/* Nesting level too deep or recursive dependency */';
         } else {
             $out = "\n{$space}";
             $outShort = '';
             $var[$marker] = TRUE;
             $oldLine = $line;
             $line++;
             $counter = 0;
             foreach ($var as $k => &$v) {
                 if ($k !== $marker) {
                     $item = ($k === $counter ? '' : self::_toPhp($k, $list, $level + 1, $line) . ' => ') . self::_toPhp($v, $list, $level + 1, $line);
                     $counter = is_int($k) ? max($k + 1, $counter) : $counter;
                     $outShort .= ($outShort === '' ? '' : ', ') . $item;
                     $out .= "\t{$item},\n{$space}";
                     $line++;
                 }
             }
             unset($var[$marker]);
             if (strpos($outShort, "\n") === FALSE && strlen($outShort) < self::$maxLength) {
                 $line = $oldLine;
                 $out = $outShort;
             }
         }
         return 'array(' . $out . ')';
     } elseif ($var instanceof \Closure) {
         $rc = new \ReflectionFunction($var);
         return "/* Closure defined in file {$rc->getFileName()} on line {$rc->getStartLine()} */";
     } elseif (is_object($var)) {
         if (PHP_VERSION_ID >= 70000 && ($rc = new \ReflectionObject($var)) && $rc->isAnonymous()) {
             return "/* Anonymous class defined in file {$rc->getFileName()} on line {$rc->getStartLine()} */";
         }
         $arr = (array) $var;
         $space = str_repeat("\t", $level);
         $class = get_class($var);
         $used =& $list[spl_object_hash($var)];
         if (empty($arr)) {
             $out = '';
         } elseif ($used) {
             return "/* {$class} dumped on line {$used} */";
         } elseif ($level > self::$maxDepth) {
             return '/* Nesting level too deep */';
         } else {
             $out = "\n";
             $used = $line;
             $line++;
             foreach ($arr as $k => &$v) {
                 if ($k[0] === "") {
                     $k = substr($k, strrpos($k, "") + 1);
                 }
                 $out .= "{$space}\t" . self::_toPhp($k, $list, $level + 1, $line) . ' => ' . self::_toPhp($v, $list, $level + 1, $line) . ",\n";
                 $line++;
             }
             $out .= $space;
         }
         $hash = self::hash($var);
         return $class === 'stdClass' ? "(object) /* {$hash} */ array({$out})" : "{$class}::__set_state(/* {$hash} */ array({$out}))";
     } elseif (is_resource($var)) {
         return '/* resource ' . get_resource_type($var) . ' */';
     } else {
         $res = var_export($var, TRUE);
         $line += substr_count($res, "\n");
         return $res;
     }
 }
开发者ID:re1la2pse,项目名称:detinsky_projekt,代码行数:97,代码来源:Dumper.php


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