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


PHP typeOf函数代码示例

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


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

示例1: read

 public function read(DOMElement $e) {
     $tn = end(explode(':',$e->tagName));
     switch($tn) {
       case 'function':
       
         foreach($e->childNodes as $cnn) {
             if (typeOf($cnn) == 'DOMElement') {
                 $cnt = end(explode(':',$cnn->tagName));
                 if ($cnt == 'from') {
                     $this->from[] = $cnn->nodeValue;
                 } elseif ($cnt == 'to') {
                     $this->to = $cnn->nodeValue;
                 } else {
                     printf("Warning: Didn't expect %s here\n", $cnn->nodeName); 
                 }
             }
         }
         
         printf(__astr("[\b{phprefactor}] Refactoring{%s} --> %s\n"), join(', ',$this->from), $this->to);
         break;
         
       default:
         printf("I don't know what to do with %s!\n", $tn);
         
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:26,代码来源:css.php

示例2: inspectArray

 static function inspectArray($data)
 {
     $ret = '<table>';
     foreach ($data as $key => $value) {
         $ret .= '<tr><th>' . htmlentities($key) . ' <br><em style="font-size:10px; font-weight:normal">' . typeOf($value) . '</em></th><td>';
         if (typeOf($value) == 'boolean') {
             if ($value) {
                 $ret .= '<img src="data:image/gif;base64,R0lGODlhEwAHAIABAAAAAP///yH5BAEKAAEALAAAAAATAAcAAAIajI+ZwMFgoHMt2imhPNn2x0XVt1zZuSkqUgAAOw==" alt="true">';
             } else {
                 $ret .= '<img src="data:image/gif;base64,R0lGODlhFwAHAIABAAAAAP///yH5BAEKAAEALAAAAAAXAAcAAAIejI+pB20eAGqSPnblxczp2nmQFlkkdpJfWY3QAi8FADs=" alt="false">';
             }
         } else {
             if (is_array($value) || is_a($value, 'StdClass')) {
                 $ret .= self::inspectArray((array) $value);
             } else {
                 if ($value === null) {
                     $ret .= '<img src="data:image/gif;base64,R0lGODdhEwAHAKECAAAAAPj4/////////ywAAAAAEwAHAAACHYSPmWIB/KKBkznIKI0iTwlKXuR8B9aUXdYprlsAADs=" alt="null">';
                 } else {
                     $ret .= htmlentities($value);
                 }
             }
         }
         $ret .= '</td></tr>';
     }
     $ret .= '</table>';
     return $ret;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:27,代码来源:debug.php

示例3: e

 /**
  * Escapes (secures) data for output.<br>
  *
  * <p>Array values are converted to space-separated value string lists.
  * > A useful use case for an array attribute is the `class` attribute.
  *
  * Object values generate either:
  * - a space-separated list of keys who's corresponding value is truthy;
  * - a semicolon-separated list of key:value elements if at least one value is a string.
  *
  * Boolean values will generate the string "true" or "false".
  *
  * NULL is converted to an empty string.
  *
  * Strings are HTML-encoded.
  *
  * @param mixed $o
  * @return string
  */
 function e($o)
 {
     switch (gettype($o)) {
         case 'string':
             break;
         case 'boolean':
             return $o ? 'true' : 'false';
         case 'integer':
         case 'double':
             return strval($o);
         case 'array':
             $at = [];
             $s = ' ';
             foreach ($o as $k => $v) {
                 if (!is_string($v) && !is_numeric($v)) {
                     throw new \InvalidArgumentException("Can't output an array with values of type " . gettype($v));
                 }
                 if (is_numeric($k)) {
                     $at[] = $v;
                 } else {
                     $at[] = "{$k}:{$v}";
                     $s = ';';
                 }
             }
             $o = implode($s, $at);
             break;
         case 'NULL':
             return '';
         default:
             return typeOf($o);
     }
     return htmlentities($o, ENT_QUOTES, 'UTF-8', false);
 }
开发者ID:php-kit,项目名称:tools,代码行数:52,代码来源:expressions.php

示例4: testShouldFormatManyAccordingToConvertMethod

 public function testShouldFormatManyAccordingToConvertMethod()
 {
     $items = ['foo', 'bar', 'baz'];
     $formatter = new MockFormatter();
     $result = $formatter->formatMany($items);
     assertThat('The result of `formatMany` should be an array of arrays.', $result, everyItem(is(typeOf('array'))));
     assertThat('The result should be the same size as the number of items passed to `formatMany`.', $result, is(arrayWithSize(count($items))));
     assertThat('The result should be correctly formatted.', $result, is(anArray([['count' => 1], ['count' => 2], ['count' => 3]])));
 }
开发者ID:graze,项目名称:formatter,代码行数:9,代码来源:AbstractFormatterTest.php

示例5: addAnimator

 public function addAnimator($property, ILpfAnimator $animator, $frstart, $frend)
 {
     if (arr::hasKey($this->_properties, $property)) {
         $this->_animators[$property][] = array('animator' => $animator, 'framestart' => $frstart, 'frameend' => $frend);
         console::writeLn("Attached animator: %s => %s", typeOf($animator), $property);
     } else {
         logger::warning("Animator attached to nonexisting property %s of object %s", $property, (string) $this->_object);
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:9,代码来源:scenegraph.php

示例6: decodeRecursive

 /**
  * @brief Recursive decoder
  * @private
  * 
  * @param String $json The JSON data to process
  * @return Mixed The parsed data
  */
 private static function decodeRecursive($json)
 {
     $arr = (array) $json;
     foreach ($arr as $k => $v) {
         if (typeOf($v) == 'stdClass' || typeOf($v) == 'array') {
             $arr[$k] = (array) self::decodeRecursive($v);
         }
     }
     return $arr;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:17,代码来源:json.php

示例7: theRequestTimeShouldBeVeryRecent

 /**
  * @Then the SpikeApi Request Time should be very recent
  */
 public function theRequestTimeShouldBeVeryRecent()
 {
     $now = time();
     $data = json_decode($this->response);
     $actual = $data->request_time;
     assertThat($actual, typeOf('integer'));
     #assertInternalType('integer', $actual);
     // we need to allow some fuzz-time, a few seconds should be OK
     assertThat("request time should be close", $now, closeTo($actual, 3));
     // We give it a little fuzz to allow for potential clock drift between machines
 }
开发者ID:alister,项目名称:expenses-avenger,代码行数:14,代码来源:SpikeApi.php

示例8: mixedValueSummary

/**
* @param Any? $value a value or null
*/
function mixedValueSummary($value, $valueIfEmpty = null, $returnKind = false)
{
    $valueToReturn = $value ? $value : (isset($valueIfEmpty) ? $valueIfEmpty : $value);
    if (!$returnKind) {
        return $valueToReturn;
    } else {
        $r = array();
        $r['kind'] = typeOf($valueToReturn);
        $r['value'] = $valueToReturn;
        return $r;
    }
}
开发者ID:GitHubTianPeng,项目名称:101worker,代码行数:15,代码来源:megalib_leftover.php

示例9: exception

 function exception(Exception $e)
 {
     if (ob_get_length() != false) {
         @ob_end_clean();
     }
     $et = typeOf($e);
     if ($et == 'FileNotFoundException' || $et == 'NavigationException') {
         response::setStatus(404);
         header('HTTP/1.1 404 Not Found', true);
         printf("<h1>404: Not Found</h1>");
         return;
     }
     if ($et == 'HttpException') {
         response::setStatus($e->getCode());
         $code = $e->getMessage();
         list($code) = explode(':', $code);
         $code = str_replace('Error ', '', $code);
         $msg = HttpException::getHttpMessage($code);
         header('HTTP/1.1 ' . $code . ' ' . $msg . ' ' . $msg);
         printf("<h1>%s: %s</h1>\n<pre>%s</pre>", $code, $msg, $msg);
         return;
     }
     response::setStatus(500);
     logger::emerg("Unhandled exception: (%s) %s in %s:%d", get_class($e), $e->getMessage(), str_replace(BASE_PATH, '', $e->getFile()), $e->getLine());
     header('HTTP/1.1 501 Server Error', true);
     $id = uniqid();
     $dbg = sprintf("Unhandled exception: (%s) %s\n  in %s:%d", get_class($e), $e->getMessage(), str_replace(SYS_PATH, '', $e->getFile()), $e->getLine()) . Console::backtrace(0, $e->getTrace(), true) . "\n" . "Loaded modules:\n" . ModuleManager::debug() . "\n" . request::getDebugInformation();
     logger::emerg($dbg);
     if (config::get('lepton.mvc.exception.log', false) == true) {
         $logfile = config::get('lepton.mvc.exception.logfile', "/tmp/" . $_SERVER['HTTP_HOST'] . "-debug.log");
         $log = "=== Unhandled Exception ===\n\n" . $dbg . "\n";
         $lf = @fopen($logfile, "a+");
         if ($lf) {
             fputs($lf, $log);
             fclose($lf);
         }
     }
     $ico_error = resource::get('warning.png');
     header('content-type: text/html; charset=utf-8');
     echo '<html><head><title>Unhandled Exception</title>' . self::$css . self::$js . '</head><body>' . '<div id="box"><div id="left"><img src="' . $ico_error . '" width="32" height="32"></div><div id="main">' . '<h1>An Unhandled Exception Occured</h1>' . '<hr noshade>' . '<p>This means that something didn\'t go quite go as planned. This could be ' . 'caused by one of several reasons, so please be patient and try ' . 'again in a little while.</p>';
     if (config::get('lepton.mvc.exception.feedback', false) == true) {
         echo '<p>The administrator of the website has been notified about this error. You ' . 'can help us find and fix the problem by writing a line or two about what you were doing when this ' . 'error occured.</p>';
         echo '<p id="feedbacklink"><a href="javascript:doFeedback();">If you would like to assist us with more information, please click here</a>.</p>';
         echo '<div id="feedback" style="display:none;"><p>Describe in a few short lines what you were doing right before you encountered this error:</p><form action="/errorevent.feedback/' . $id . '" method="post"><div><textarea name="text" style="width:100%; height:50px;"></textarea></div><div style="padding-top:5px; text-align:right;"><input type="button" value=" Close " onclick="closeFeedback();"> <input type="submit" value=" Submit Feedback "></div></form></div>';
     }
     if (config::get('lepton.mvc.exception.showdebug', false) == true) {
         echo '<hr noshade>' . '<a href="javascript:toggleAdvanced();">Details &raquo;</a>' . '<pre id="advanced" style="display:none; height:300px;">' . $dbg . '</pre>';
     }
     echo '<div>' . '</body></html>';
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:50,代码来源:exception.php

示例10: loadYmlData

 /**
  * @param $file
  *
  * @return array
  *
  * @throws \Stefanius\LaravelFixtures\Exception\FileNotFoundException
  */
 public function loadYmlData($file)
 {
     if (is_null($file)) {
         throw new \InvalidArgumentException(sprintf('The argument has to be a string. NULL given.'));
     }
     if (!is_string($file)) {
         throw new \InvalidArgumentException(sprintf('The argument has to be a string. %s given.', typeOf($file)));
     }
     $ymlFilename = sprintf($this->fixtureDataPath . DIRECTORY_SEPARATOR . '%s.yml', $file);
     if (!file_exists($ymlFilename)) {
         throw new FileNotFoundException($ymlFilename);
     }
     return Yaml::parse(file_get_contents($ymlFilename));
 }
开发者ID:stefanius,项目名称:laravel-fixtures,代码行数:21,代码来源:Loader.php

示例11: testShouldFormatTraversableAccordingToConvertMethod

 public function testShouldFormatTraversableAccordingToConvertMethod()
 {
     $items = ['foo', 'bar', 'baz'];
     /** @var Generator **/
     $result = (new MockFormatter())->formatTraversable(new ArrayIterator($items));
     assertThat('The result of `formatTraversable` should be a Generator.', $result, is(anInstanceOf('Generator')));
     /** @var Generator **/
     $result = (new MockFormatter())->formatTraversable(new ArrayIterator($items));
     assertThat('Every item in the result should be an array.', iterator_to_array($result), everyItem(is(typeOf('array'))));
     /** @var Generator **/
     $result = (new MockFormatter())->formatTraversable(new ArrayIterator($items));
     assertThat('The result should be the same size as the number of items passed to `formatTraversable`.', $result, is(traversableWithSize(count($items))));
     /** @var Generator **/
     $result = (new MockFormatter())->formatTraversable(new ArrayIterator($items));
     assertThat('The result should be correctly formatted.', iterator_to_array($result), is(anArray([['count' => 1], ['count' => 2], ['count' => 3]])));
 }
开发者ID:graze,项目名称:formatter,代码行数:16,代码来源:AbstractTraversableFormatterTest.php

示例12: _e

/**
 * Extracts and escapes text from the given value, for outputting to the HTTP client.
 *
 * <p>Note: this returns escaped text, except if the given argument is a {@see RawText} instance, in which case it
 * returns raw text.
 *
 * @param string|RawText $s
 * @return string
 */
function _e($s)
{
    if (!is_scalar($s)) {
        if (is_null($s)) {
            return '';
        }
        if ($s instanceof RawText) {
            return $s->toString();
        }
        if ($s instanceof RenderableInterface) {
            $s = $s->getRendering();
        } elseif (is_object($s) && method_exists($s, '__toString')) {
            $s = (string) $s;
        } else {
            if (is_iterable($s)) {
                return iteratorOf($s)->current();
            }
            return sprintf('[%s]', typeOf($s));
        }
    }
    return htmlentities($s, ENT_QUOTES, 'UTF-8', false);
}
开发者ID:electro-modules,项目名称:matisse,代码行数:31,代码来源:globals.php

示例13: formatErrorArg

 /**
  * @internal
  * @param mixed $arg
  * @return string
  */
 public static function formatErrorArg($arg)
 {
     if (is_object($arg)) {
         switch (get_class($arg)) {
             case \ReflectionMethod::class:
                 /** @var \ReflectionMethod $arg */
                 return sprintf('ReflectionMethod<%s::$s>', $arg->getDeclaringClass()->getName(), $arg->getName());
             case \ReflectionFunction::class:
                 /** @var \ReflectionFunction $arg */
                 return sprintf('ReflectionFunction<function at %s line %d>', $arg->getFileName(), $arg->getStartLine());
             case \ReflectionParameter::class:
                 /** @var \ReflectionParameter $arg */
                 return sprintf('ReflectionParameter<$%s>', $arg->getName());
             default:
                 return typeOf($arg);
         }
     }
     if (is_array($arg)) {
         return sprintf('[%s]', implode(',', map($arg, [__CLASS__, 'formatErrorArg'])));
     }
     return str_replace('\\\\', '\\', var_export($arg, true));
 }
开发者ID:electro-framework,项目名称:framework,代码行数:27,代码来源:ConsoleBootloader.php

示例14: __inspect_recurs

 function __inspect_recurs($data, $head = '')
 {
     $maxlenk = 30;
     $maxlent = 8;
     foreach ($data as $k => $v) {
         if (strlen($k) > $maxlenk) {
             $maxlenk = strlen($k);
         }
         if (strlen(typeOf($v)) > $maxlent) {
             $maxlent = strlen(typeOf($v));
         }
     }
     $maxlent += 2;
     $itemcount = count($data);
     $idx = 0;
     foreach ($data as $k => $v) {
         $idx++;
         if (typeOf($v) == 'array' || typeOf($v) == 'stdClass') {
             $ttl = $head . $k . ' ';
             console::writeLn($ttl);
             $myend = '|_';
             $nhead = $head;
             if ($idx++ > 0) {
                 $nhead = substr($head, 0, strlen($head) - 1) . ' ';
             }
             self::__inspect_recurs($v, $nhead . $myend);
         } else {
             switch (typeOf($v)) {
                 case 'boolean':
                     $sv = $v ? 'true' : 'false';
                     break;
                 default:
                     $sv = '"' . $v . '"';
             }
             console::writeLn('%s = %s', $head . sprintf('%s<%s>', $k, typeOf($v)), $sv);
         }
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:38,代码来源:debug.php

示例15: run

 /**
  * @brief Run the application. Invoked by Lepton.
  * Will parse the arguments and make sure everything is in order.
  *
  */
 function run()
 {
     global $argc, $argv;
     if (isset($this->arguments)) {
         if (is_string($this->arguments)) {
             $strargs = $this->arguments;
             $longargs = array();
         } elseif (is_array($this->arguments)) {
             $strargs = '';
             $longargs = array();
             foreach ($this->arguments as $arg) {
                 $strargs .= $arg[0];
                 // Scope is the : or ::
                 $scope = substr($arg[0], 1);
                 $longargs[] = $arg[1] . $scope;
             }
         } elseif (typeOf($this->arguments) == 'AppArgumentList') {
             $args = $this->arguments->getData();
             $strargs = '';
             $longargs = array();
             foreach ($args as $arg) {
                 $strargs .= $arg[0];
                 // Scope is the : or ::
                 $scope = substr($arg[0], 1);
                 $longargs[] = $arg[1] . $scope;
             }
         } else {
             console::warn('Application->$arguments is set but format is not understood');
         }
         list($args, $params) = $this->parseArguments($strargs, $longargs);
         foreach ($args as $arg => $val) {
             if (in_array($arg, $longargs)) {
                 foreach ($args as $argsrc => $v) {
                     if ($argsrc == $arg) {
                         $args[$argsrc[0]] = $val;
                         $olarg = $argsrc[0];
                     }
                 }
             } else {
                 foreach ($args as $argsrc => $v) {
                     if ($argsrc == $arg) {
                         $arg[$argsrc] = $val;
                         $olarg = $argsrc[0];
                         // Do any matching we need here
                     }
                 }
             }
         }
         $this->_args = $args;
         $this->_params = $params;
     }
     if (isset($args['h'])) {
         if (method_exists($this, 'usage')) {
             $this->usage();
         }
         return 1;
     }
     return $this->main($argc, $argv);
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:64,代码来源:application.php


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