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

PHP is_finite函数代码示例

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

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



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

示例1: testInf

 /**
  * @covers Fisharebest\PhpPolyfill\Php::inf
  * @covers Fisharebest\PhpPolyfill\Php::isLittleEndian
  * @runInSeparateProcess
  */
 public function testInf()
 {
     $this->assertTrue(is_float(Php::inf()));
     $this->assertTrue(is_double(Php::inf()));
     $this->assertTrue(is_infinite(Php::inf()));
     $this->assertFalse(is_finite(Php::inf()));
 }
开发者ID:fisharebest,项目名称:php-polyfill,代码行数:12,代码来源:PhpTest.php


示例2: toInteger

 /**
  * 与えられた値を整数型に変換して返します。
  * @link http://www.hcn.zaq.ne.jp/___/WEB/WebIDL-ja.html#es-integers Web IDL (第2版 — 日本語訳)
  * @param boolean|integer|float|string|resource|\GMP|\SplInt $value
  * @param string $type byte、octet、short、unsigned short、long、unsigned long、long long、unsigned long long
  * @param integer|float $min 浮動小数点型で正確に扱える整数の範囲よりも、整数型で扱える整数の範囲が狭ければ (整数型が32bitである環境なら) 浮動小数点数。
  * @param integer|float $max 浮動小数点型で正確に扱える整数の範囲よりも、整数型で扱える整数の範囲が狭ければ (整数型が32bitである環境なら) 浮動小数点数。
  * @param integer $bits
  * @param booelan $signed
  * @param string $extendedAttribute 拡張属性。[EnforceRange] か [Clamp] のいずれか。
  * @return integer|float 整数型の範囲を超える場合は浮動小数点数。
  * @throws \InvalidArgumentException 配列、NULL が与えられた場合。または、GMP、SplInt 以外のオブジェクトが与えられた場合。
  * @throws \DomainException $extendedAttribute が [EnforceRange]、かつ与えられたの値が $min 〜 $max に収まらなかった場合。
  */
 private static function toInteger($value, $type, $min, $max, $bits, $signed, $extendedAttribute = null)
 {
     /** @var string 要求される型。 */
     $expectedType = sprintf('%s (an integer in the range of %s to %s)', $type, is_float($min) ? number_format($min, 0, '', '') : $min, is_float($max) ? number_format($max, 0, '', '') : $max);
     if (!self::isIntegerCastable($value)) {
         throw new \InvalidArgumentException(ErrorMessageCreator::create($value, $expectedType));
     }
     if ($value instanceof \GMP || is_resource($value) && get_resource_type($value) === 'GMP integer') {
         // GMP数であれば、あらかじめ文字列に変換しておく
         $value = gmp_strval($value);
     }
     /** @var integer|float 与えられた値の数値表現。整数型の範囲を超える場合は浮動小数点数。整数値となる場合、小数部があれば0方向へ丸められる。 */
     $number = is_float($value) || (double) $value < self::$phpIntMin || (double) $value > PHP_INT_MAX ? (double) $value : (int) $value;
     if ($extendedAttribute === '[EnforceRange]') {
         /** @var integer|float 与えられた値の整数表現。整数型の範囲を超える場合は浮動小数点数。 */
         $integer = self::roundTowardZero($number);
         if (!is_finite($number) || $integer < $min || $integer > $max) {
             throw new \DomainException(ErrorMessageCreator::create($value, $expectedType));
         }
     } elseif (!is_nan($number) && $extendedAttribute === '[Clamp]') {
         $number = min(max($number, $min), $max);
         $integer = is_float($number) ? round($number, 0, PHP_ROUND_HALF_EVEN) : $number;
     } elseif (!is_finite($number)) {
         $integer = 0;
     } else {
         $integer = self::modulo(self::roundTowardZero($number), pow(2, $bits));
         if ($signed && $integer >= pow(2, $bits - 1)) {
             $integer -= pow(2, $bits);
         }
     }
     return is_float($integer) && $integer >= self::$phpIntMin && $integer <= PHP_INT_MAX ? (int) $integer : $integer;
 }
开发者ID:esperecyan,项目名称:webidl,代码行数:46,代码来源:IntegerType.php


示例3: matches

 protected function matches($actual)
 {
     $asserter = new asserters\boolean();
     try {
         $asserter->setWith(is_finite($actual))->isTrue();
     } catch (exception $exception) {
         throw new exception($asserter, $this->analyzer->getTypeOf($actual) . ' is not finite');
     }
 }
开发者ID:atoum,项目名称:phpunit-extension,代码行数:9,代码来源:finite.php


示例4: toLine

 /**
  * Dumps information about a variable in readable format.
  * @param  mixed  variable to dump
  * @return string
  */
 public static function toLine($var)
 {
     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';
     }
     if (is_bool($var)) {
         return $var ? 'TRUE' : 'FALSE';
     } elseif ($var === NULL) {
         return 'NULL';
     } elseif (is_int($var)) {
         return "{$var}";
     } elseif (is_float($var)) {
         if (!is_finite($var)) {
             return str_replace('.0', '', var_export($var, TRUE));
             // workaround for PHP 7.0.2
         }
         $var = str_replace(',', '.', "{$var}");
         return strpos($var, '.') === FALSE ? $var . '.0' : $var;
         // workaround for PHP < 7.0.2
     } elseif (is_string($var)) {
         if (preg_match('#^(.{' . self::$maxLength . '}).#su', $var, $m)) {
             $var = "{$m['1']}...";
         } elseif (strlen($var) > self::$maxLength) {
             $var = substr($var, 0, self::$maxLength) . '...';
         }
         return preg_match('#[^\\x09\\x0A\\x0D\\x20-\\x7E\\xA0-\\x{10FFFF}]#u', $var) || preg_last_error() ? '"' . strtr($var, $table) . '"' : "'{$var}'";
     } elseif (is_array($var)) {
         $out = '';
         $counter = 0;
         foreach ($var as $k => &$v) {
             $out .= $out === '' ? '' : ', ';
             if (strlen($out) > self::$maxLength) {
                 $out .= '...';
                 break;
             }
             $out .= ($k === $counter ? '' : self::toLine($k) . ' => ') . (is_array($v) && $v ? 'array(...)' : self::toLine($v));
             $counter = is_int($k) ? max($k + 1, $counter) : $counter;
         }
         return "array({$out})";
     } elseif ($var instanceof \Exception || $var instanceof \Throwable) {
         return 'Exception ' . get_class($var) . ': ' . ($var->getCode() ? '#' . $var->getCode() . ' ' : '') . $var->getMessage();
     } elseif (is_object($var)) {
         return self::objectToLine($var);
     } elseif (is_resource($var)) {
         return 'resource(' . get_resource_type($var) . ')';
     } else {
         return 'unknown type';
     }
 }
开发者ID:re1la2pse,项目名称:detinsky_projekt,代码行数:61,代码来源:Dumper.php


示例5: __toString

 function __toString()
 {
     $sql = "";
     foreach ($this as $column => $value) {
         if (isset($this->{$column})) {
             $sql = ($sql ? "{$sql}, " : "") . "{$column}=" . (is_double($value) && !is_finite($value) ? "NULL" : "'" . (self::$db ? self::$db->escape($value) : $value) . "'");
         }
     }
     return $sql;
 }
开发者ID:radoid,项目名称:subframe,代码行数:10,代码来源:Model.php


示例6: XNPV

 private function XNPV($rate, $values, $dates)
 {
     if (!is_array($values) || !is_array($dates)) {
         return null;
     }
     if (count($values) != count($dates)) {
         return null;
     }
     $xnpv = 0.0;
     for ($i = 0; $i < count($values); $i++) {
         $xnpv += $values[$i] / pow(1 + $rate, $this->DATEDIFF('day', $dates[0], $dates[$i]) / 365);
     }
     return is_finite($xnpv) ? $xnpv : null;
 }
开发者ID:scalloty,项目名称:apr,代码行数:14,代码来源:leasing_class.php


示例7: toDouble

 /**
  * 与えられた値を、NAN、INFを含まない浮動小数点型に変換して返します。
  * @link https://heycam.github.io/webidl/#idl-double Web IDL (Second Edition)
  * @link http://www.w3.org/TR/WebIDL/#idl-double Web IDL
  * @param boolean|integer|float|string|resource|\GMP|\SplFloat $value
  * @throws \InvalidArgumentException 配列、NULL が与えられた場合。または、GMP、SplFloat 以外のオブジェクトが与えられた場合。
  * @throws \DomainException 変換後の値が、NAN、INF、-INF のいずれかになった場合。
  * @return float
  */
 public static function toDouble($value)
 {
     $expectedType = 'double (a float not NAN or INF)';
     try {
         $float = self::toUnrestrictedDouble($value);
     } catch (\InvalidArgumentException $exeception) {
         throw new \InvalidArgumentException(ErrorMessageCreator::create($value, $expectedType));
     }
     if (is_finite($float)) {
         return $float;
     } else {
         throw new \DomainException(ErrorMessageCreator::create($value, $expectedType));
     }
 }
开发者ID:esperecyan,项目名称:webidl,代码行数:23,代码来源:FloatType.php


示例8: execute

 public function execute()
 {
     $src = FileBackendGroup::singleton()->get($this->getOption('src'));
     $dst = FileBackendGroup::singleton()->get($this->getOption('dst'));
     $posDir = $this->getOption('posdir');
     $posFile = $posDir ? $posDir . '/' . wfWikiID() : false;
     $start = $this->getOption('start', 0);
     if (!$start && $posFile && is_dir($posDir)) {
         $start = is_file($posFile) ? (int) trim(file_get_contents($posFile)) : 0;
         ++$start;
         // we already did this ID, start with the next one
         $startFromPosFile = true;
     } else {
         $startFromPosFile = false;
     }
     $end = $this->getOption('end', INF);
     $this->output("Synchronizing backend '{$dst->getName()}' to '{$src->getName()}'...\n");
     $this->output("Starting journal position is {$start}.\n");
     if (is_finite($end)) {
         $this->output("Ending journal position is {$end}.\n");
     }
     // Actually sync the dest backend with the reference backend
     $lastOKPos = $this->syncBackends($src, $dst, $start, $end);
     // Update the sync position file
     if ($startFromPosFile && $lastOKPos >= $start) {
         // successfully advanced
         if (file_put_contents($posFile, $lastOKPos, LOCK_EX) !== false) {
             $this->output("Updated journal position file.\n");
         } else {
             $this->output("Could not update journal position file.\n");
         }
     }
     if ($lastOKPos === false) {
         if (!$start) {
             $this->output("No journal entries found.\n");
         } else {
             $this->output("No new journal entries found.\n");
         }
     } else {
         $this->output("Stopped synchronization at journal position {$lastOKPos}.\n");
     }
     if ($this->isQuiet()) {
         print $lastOKPos;
         // give a single machine-readable number
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:46,代码来源:syncFileBackend.php


示例9: convertBeforeEncode

 static function convertBeforeEncode($val)
 {
     $arr = null;
     if (is_object($val)) {
         $_g = get_class($val);
         switch ($_g) {
             case "_hx_anonymous":
             case "stdClass":
                 $arr = php_Lib::associativeArrayOfObject($val);
                 break;
             case "_hx_array":
                 $arr = php_Lib::toPhpArray($val);
                 break;
             case "Date":
                 return Std::string($val);
                 break;
             case "HList":
                 $arr = php_Lib::toPhpArray(Lambda::harray($val));
                 break;
             case "_hx_enum":
                 $e = $val;
                 return $e->index;
                 break;
             case "StringMap":
             case "IntMap":
                 $arr = php_Lib::associativeArrayOfHash($val);
                 break;
             default:
                 $arr = php_Lib::associativeArrayOfObject($val);
                 break;
         }
     } else {
         if (is_array($val)) {
             $arr = $val;
         } else {
             if (is_float($val) && !is_finite($val)) {
                 $val = null;
             }
             return $val;
         }
     }
     return array_map(isset(haxe_Json::$convertBeforeEncode) ? haxe_Json::$convertBeforeEncode : array("haxe_Json", "convertBeforeEncode"), $arr);
 }
开发者ID:axelhuizinga,项目名称:gem,代码行数:43,代码来源:Json.class.php


示例10: factorization

 /**
  * Returns the prime factors of a number.
  * More info (http://bateru.com/news/2012/05/code-of-the-day-javascript-prime-factors-of-a-number/)
  * Taken from Ratio.js
  *
  * @param number $number
  * @return array an array of numbers
  * @example prime.factorization(20).join(',') === "2,2,5"
  **/
 public static function factorization($number = 0)
 {
     $number = floor($number);
     $continue = 1 < $number && is_finite($number);
     $factors = array();
     while ($continue) {
         $sqrt = sqrt($number);
         $x = 2;
         if (fmod($number, $x) != 0) {
             $x = 3;
             while (fmod($number, $x) != 0 && ($x += 2) < $sqrt) {
             }
         }
         $x = $sqrt < $x ? $number : $x;
         $factors[] = $x;
         $continue = $x != $number;
         $number /= $x;
     }
     return $factors;
 }
开发者ID:dbirchak,项目名称:numbers.php,代码行数:29,代码来源:Prime.php


示例11: parseDMS

 /**
  * Parses string representing degrees/minutes/seconds into numeric degrees.
  *
  * This is very flexible on formats, allowing signed decimal degrees, or deg-min-sec optionally
  * suffixed by compass direction (NSEW). A variety of separators are accepted (eg 3° 37′ 09″W).
  * Seconds and minutes may be omitted.
  *
  * @param   string|number $dmsStr - Degrees or deg/min/sec in variety of formats.
  * @returns number Degrees as decimal number.
  */
 public static function parseDMS($dmsStr)
 {
     // check for signed decimal degrees without NSEW, if so return it directly
     if (is_numeric($dmsStr) && is_finite($dmsStr)) {
         return (double) $dmsStr;
     }
     // strip off any sign or compass dir'n & split out separate d/m/s
     $dms = preg_split('/[^0-9.,]+/', preg_replace(['/^-/', '/[NSEW]$/i'], '', trim((string) $dmsStr)));
     if ($dms[count($dms) - 1] == '') {
         array_splice($dms, count($dms) - 1);
     }
     // from trailing symbol
     if ($dms == '') {
         return NAN;
     }
     // and convert to decimal degrees...
     switch (count($dms)) {
         case 3:
             // interpret 3-part result as d/m/s
             $deg = $dms[0] / 1 + $dms[1] / 60 + $dms[2] / 3600;
             break;
         case 2:
             // interpret 2-part result as d/m
             $deg = $dms[0] / 1 + $dms[1] / 60;
             break;
         case 1:
             // just d (possibly decimal) or non-separated dddmmss
             $deg = $dms[0];
             // check for fixed-width unseparated format eg 0033709W
             //if (/[NS]/i.test(dmsStr)) deg = '0' + deg;  // - normalise N/S to 3-digit degrees
             //if (/[0-9]{7}/.test(deg)) deg = deg.slice(0,3)/1 + deg.slice(3,5)/60 + deg.slice(5)/3600;
             break;
         default:
             return NAN;
     }
     if (preg_match('/^-|[WS]$/i', trim($dmsStr))) {
         $deg = -$deg;
     }
     // take '-', west and south as -ve
     return (double) $deg;
 }
开发者ID:Negromovich,项目名称:latlon-calculator,代码行数:51,代码来源:Dms.php


示例12: whatIs

 public static function whatIs($what)
 {
     $type = gettype($what);
     switch ($type) {
         case "double":
         case "integer":
             if (is_finite($what)) {
                 return $what % 1 === 0 ? "integer" : "number";
             }
             if (is_nan($what)) {
                 return "not-a-number";
             }
             return "unknown-number";
         case "NULL":
             return "null";
         case "boolean":
         case "object":
         case "array":
         case "string":
             return $type;
         default:
             return "unknown-type";
     }
 }
开发者ID:phindmarsh,项目名称:statham,代码行数:24,代码来源:Utils.php


示例13: doCast

 /**
  * Cast an value to a specific type.
  *
  * Public calls should be made to "cast" which then delegates to this method.
  *
  * @param mixed $value        Value to be casted and returned by reference.
  * @param mixed $defaultValue Value to be returned if not set.
  *
  * @return mixed New value (or default value if unmatched).
  * @throws \TypeError If defaultValue is of invalid type.
  */
 public function doCast($value, $defaultValue = null)
 {
     if (false === is_float($defaultValue) && null !== $defaultValue) {
         throw new \TypeError('DefaultValue must be a float for AsFloat casts');
     }
     if (false === is_string($value) && false === is_numeric($value)) {
         $this->setError(self::ONLY_STRINGS_NUMERICS);
         return $defaultValue;
     }
     if (false === is_float($value)) {
         $options = ['options' => ['default' => null, 'decimal' => $this->decimalSeparator]];
         // remove thousands separator
         $value = str_replace($this->digitsSeparator, '', strval($value));
         $value = filter_var($value, FILTER_VALIDATE_FLOAT, $options);
     }
     if (false === is_float($value) || true === is_nan($value) || false === is_finite($value)) {
         $this->setError(self::FLOAT_MUST_BE_ACCEPTED_FORMAT, ['decimalSeparator' => $this->decimalSeparator, 'digitsSeparator' => $this->digitsSeparator]);
         return $defaultValue;
     }
     if (null !== $this->precision) {
         $value = round($value, $this->precision);
     }
     return $value;
 }
开发者ID:bairwell,项目名称:hydrator,代码行数:35,代码来源:AsFloat.php


示例14: toJson

 /**
  * @return mixed
  */
 private static function toJson(&$var, $options, $level = 0)
 {
     if (is_bool($var) || is_null($var) || is_int($var)) {
         return $var;
     } elseif (is_float($var)) {
         return is_finite($var) ? strpos($tmp = json_encode($var), '.') ? $var : array('number' => "{$tmp}.0") : array('type' => (string) $var);
     } elseif (is_string($var)) {
         return self::encodeString($var, $options[self::TRUNCATE]);
     } elseif (is_array($var)) {
         static $marker;
         if ($marker === NULL) {
             $marker = uniqid("", TRUE);
         }
         if (isset($var[$marker]) || $level >= $options[self::DEPTH]) {
             return array(NULL);
         }
         $res = array();
         $var[$marker] = TRUE;
         foreach ($var as $k => &$v) {
             if ($k !== $marker) {
                 $k = preg_match('#^\\w{1,50}\\z#', $k) ? $k : '"' . self::encodeString($k, $options[self::TRUNCATE]) . '"';
                 $res[] = array($k, self::toJson($v, $options, $level + 1));
             }
         }
         unset($var[$marker]);
         return $res;
     } elseif (is_object($var)) {
         $obj =& self::$liveStorage[spl_object_hash($var)];
         if ($obj && $obj['level'] <= $level) {
             return array('object' => $obj['id']);
         }
         if ($options[self::LOCATION] & self::LOCATION_CLASS) {
             $rc = $var instanceof \Closure ? new \ReflectionFunction($var) : new \ReflectionClass($var);
             $editor = Helpers::editorUri($rc->getFileName(), $rc->getStartLine());
         }
         static $counter = 1;
         $obj = $obj ?: array('id' => self::$livePrefix . '0' . $counter++, 'name' => Helpers::getClass($var), 'editor' => empty($editor) ? NULL : array('file' => $rc->getFileName(), 'line' => $rc->getStartLine(), 'url' => $editor), 'level' => $level, 'object' => $var);
         if ($level < $options[self::DEPTH] || !$options[self::DEPTH]) {
             $obj['level'] = $level;
             $obj['items'] = array();
             foreach (self::exportObject($var, $options[self::OBJECT_EXPORTERS]) as $k => $v) {
                 $vis = 0;
                 if (isset($k[0]) && $k[0] === "") {
                     $vis = $k[1] === '*' ? 1 : 2;
                     $k = substr($k, strrpos($k, "") + 1);
                 }
                 $k = preg_match('#^\\w{1,50}\\z#', $k) ? $k : '"' . self::encodeString($k, $options[self::TRUNCATE]) . '"';
                 $obj['items'][] = array($k, self::toJson($v, $options, $level + 1), $vis);
             }
         }
         return array('object' => $obj['id']);
     } elseif (is_resource($var)) {
         $obj =& self::$liveStorage[(string) $var];
         if (!$obj) {
             $type = get_resource_type($var);
             $obj = array('id' => self::$livePrefix . (int) $var, 'name' => $type . ' resource');
             if (isset(self::$resources[$type])) {
                 foreach (call_user_func(self::$resources[$type], $var) as $k => $v) {
                     $obj['items'][] = array($k, self::toJson($v, $options, $level + 1));
                 }
             }
         }
         return array('resource' => $obj['id']);
     } else {
         return array('type' => 'unknown type');
     }
 }
开发者ID:kivi8,项目名称:ars-poetica,代码行数:70,代码来源:Dumper.php


示例15: newPagerForSavedQuery

 public function newPagerForSavedQuery(PhabricatorSavedQuery $saved)
 {
     if ($this->shouldUseOffsetPaging()) {
         $pager = new PHUIPagerView();
     } else {
         $pager = new AphrontCursorPagerView();
     }
     $page_size = $this->getPageSize($saved);
     if (is_finite($page_size)) {
         $pager->setPageSize($page_size);
     } else {
         // Consider an INF pagesize to mean a large finite pagesize.
         // TODO: It would be nice to handle this more gracefully, but math
         // with INF seems to vary across PHP versions, systems, and runtimes.
         $pager->setPageSize(0xffff);
     }
     return $pager;
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:18,代码来源:PhabricatorApplicationSearchEngine.php


示例16: MIRR

 public static function MIRR($values, $finance_rate, $reinvestment_rate)
 {
     if (!is_array($values)) {
         return self::$_errorCodes['value'];
     }
     $values = self::flattenArray($values);
     $finance_rate = self::flattenSingleValue($finance_rate);
     $reinvestment_rate = self::flattenSingleValue($reinvestment_rate);
     $n = count($values);
     $rr = 1.0 + $reinvestment_rate;
     $fr = 1.0 + $finance_rate;
     $npv_pos = $npv_neg = 0.0;
     foreach ($values as $i => $v) {
         if ($v >= 0) {
             $npv_pos += $v / pow($rr, $i);
         } else {
             $npv_neg += $v / pow($fr, $i);
         }
     }
     if ($npv_neg == 0 || $npv_pos == 0 || $reinvestment_rate <= -1) {
         return self::$_errorCodes['value'];
     }
     $mirr = pow(-$npv_pos * pow($rr, $n) / ($npv_neg * $rr), 1.0 / ($n - 1)) - 1.0;
     return is_finite($mirr) ? $mirr : self::$_errorCodes['value'];
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:25,代码来源:Functions.php


示例17: validateValue

 /**
  * Validate a value for addition to the result
  * @param mixed $value
  * @return array|mixed|string
  */
 private static function validateValue($value)
 {
     global $wgContLang;
     if (is_object($value)) {
         // Note we use is_callable() here instead of instanceof because
         // ApiSerializable is an informal protocol (see docs there for details).
         if (is_callable(array($value, 'serializeForApiResult'))) {
             $oldValue = $value;
             $value = $value->serializeForApiResult();
             if (is_object($value)) {
                 throw new UnexpectedValueException(get_class($oldValue) . "::serializeForApiResult() returned an object of class " . get_class($value));
             }
             // Recursive call instead of fall-through so we can throw a
             // better exception message.
             try {
                 return self::validateValue($value);
             } catch (Exception $ex) {
                 throw new UnexpectedValueException(get_class($oldValue) . "::serializeForApiResult() returned an invalid value: " . $ex->getMessage(), 0, $ex);
             }
         } elseif (is_callable(array($value, '__toString'))) {
             $value = (string) $value;
         } else {
             $value = (array) $value + array(self::META_TYPE => 'assoc');
         }
     }
     if (is_array($value)) {
         foreach ($value as $k => $v) {
             $value[$k] = self::validateValue($v);
         }
     } elseif (is_float($value) && !is_finite($value)) {
         throw new InvalidArgumentException("Cannot add non-finite floats to ApiResult");
     } elseif (is_string($value)) {
         $value = $wgContLang->normalize($value);
     } elseif ($value !== null && !is_scalar($value)) {
         $type = gettype($value);
         if (is_resource($value)) {
             $type .= '(' . get_resource_type($value) . ')';
         }
         throw new InvalidArgumentException("Cannot add {$type} to ApiResult");
     }
     return $value;
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:47,代码来源:ApiResult.php


示例18: isFinite

 static function isFinite($f)
 {
     return is_finite($f);
 }
开发者ID:adrianmm44,项目名称:zcale,代码行数:4,代码来源:Math.class.php


示例19: isFinite

 /**
  * Returns true if object is a finite number.
  *
  * @category Object Functions
  *
  * @param mixed $object the object
  *
  * @return bool
  */
 public static function isFinite($object)
 {
     return is_finite($object);
 }
开发者ID:boliviasoftware,项目名称:micro-system-maker,代码行数:13,代码来源:Underscore.php


示例20: queryLinks

 /**
  * Get the backlinks for a given table. Cached in process memory only.
  * @param string $table
  * @param int|bool $startId
  * @param int|bool $endId
  * @param int|INF $max
  * @param string $select 'all' or 'ids'
  * @return ResultWrapper
  */
 protected function queryLinks($table, $startId, $endId, $max, $select = 'all')
 {
     wfProfileIn(__METHOD__);
     $fromField = $this->getPrefix($table) . '_from';
     if (!$startId && !$endId && is_infinite($max) && isset($this->fullResultCache[$table])) {
         wfDebug(__METHOD__ . ": got results from cache\n");
         $res = $this->fullResultCache[$table];
     } else {
         wfDebug(__METHOD__ . ": got results from DB\n");
         $conds = $this->getConditions($table);
         // Use the from field in the condition rather than the joined page_id,
         // because databases are stupid and don't necessarily propagate indexes.
         if ($startId) {
             $conds[] = "{$fromField} >= " . intval($startId);
         }
         if ($endId) {
             $conds[] = "{$fromField} <= " . intval($endId);
         }
         $options = array('ORDER BY' => $fromField);
         if (is_finite($max) && $max > 0) {
             $options['LIMIT'] = $max;
         }
         if ($select === 'ids') {
             // Just select from the backlink table and ignore the page JOIN
             $res = $this->getDB()->select($table, array($this->getPrefix($table) . '_from AS page_id'), array_filter($conds, function ($clause) {
                 // kind of janky
                 return !preg_match('/(\\b|=)page_id(\\b|=)/', $clause);
             }), __METHOD__, $options);
         } else {
             // Select from the backlink table and JOIN with page title information
             $res = $this->getDB()->select(array($table, 'page'), array('page_namespace', 'page_title', 'page_id'), $conds, __METHOD__, array_merge(array('STRAIGHT_JOIN'), $options));
         }
         if ($select === 'all' && !$startId && !$endId && $res->numRows() < $max) {
             // The full results fit within the limit, so cache them
             $this->fullResultCache[$table] = $res;
         } else {
             wfDebug(__METHOD__ . ": results from DB were uncacheable\n");
         }
     }
     wfProfileOut(__METHOD__);
     return $res;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:51,代码来源:BacklinkCache.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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