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


PHP is_infinite函数代码示例

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


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

示例1: stringify

 /**
  * @param mixed $value
  * @param int   $depth
  *
  * @return string
  */
 public static function stringify($value, $depth = 1)
 {
     if ($depth >= self::$maxDepthStringify) {
         return self::$maxReplacementStringify;
     }
     if (is_array($value)) {
         return static::stringifyArray($value, $depth);
     }
     if (is_object($value)) {
         return static::stringifyObject($value, $depth);
     }
     if (is_resource($value)) {
         return sprintf('`[resource] (%s)`', get_resource_type($value));
     }
     if (is_float($value)) {
         if (is_infinite($value)) {
             return ($value > 0 ? '' : '-') . 'INF';
         }
         if (is_nan($value)) {
             return 'NaN';
         }
     }
     $options = 0;
     if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
         $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
     }
     return @json_encode($value, $options) ?: $value;
 }
开发者ID:nowsolutions,项目名称:Validation,代码行数:34,代码来源:ValidationException.php

示例2: testINF

 public function testINF()
 {
     $this->assertTrue(is_infinite(GreatestCommonDivisor::greatestCommonDivisor([10, INF])));
     $this->assertTrue(is_infinite(GreatestCommonDivisor::greatestCommonDivisor([INF, INF])));
     $this->assertTrue(is_infinite(GreatestCommonDivisor::greatestCommonDivisor([INF, 10])));
     $this->assertTrue(is_infinite(GreatestCommonDivisor::greatestCommonDivisor([10, INF, 10])));
 }
开发者ID:lstrojny,项目名称:hmmmath,代码行数:7,代码来源:GreatestCommonDivisorTest.php

示例3: dump

 /**
  * Dumps a given PHP variable to a YAML string.
  *
  * @param mixed $value The PHP variable to convert
  *
  * @return string The YAML string representing the PHP array
  *
  * @throws DumpException When trying to dump PHP resource
  */
 public static function dump($value)
 {
     switch (true) {
         case is_resource($value):
             throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value)));
         case is_object($value):
             return '!!php/object:' . serialize($value);
         case is_array($value):
             return self::dumpArray($value);
         case null === $value:
             return 'null';
         case true === $value:
             return 'true';
         case false === $value:
             return 'false';
         case ctype_digit($value):
             return is_string($value) ? "'{$value}'" : (int) $value;
         case is_numeric($value):
             return is_string($value) ? "'{$value}'" : (is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : $value);
         case Escaper::requiresDoubleQuoting($value):
             return Escaper::escapeWithDoubleQuotes($value);
         case Escaper::requiresSingleQuoting($value):
             return Escaper::escapeWithSingleQuotes($value);
         case '' == $value:
             return "''";
         case preg_match(self::getTimestampRegex(), $value):
         case in_array(strtolower($value), array('null', '~', 'true', 'false')):
             return "'{$value}'";
         default:
             return $value;
     }
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:41,代码来源:Inline.php

示例4: getHuman

 public function getHuman($max_groups = INF, $short = false)
 {
     $short = (bool) $short;
     if ($max_groups < 1) {
         $max_groups = INF;
     }
     $for_print = [];
     if ($this->_years > 0) {
         $for_print[] = sprintf("%d %s", $this->_years, MeasureWord::getFormByForms($this->_forms[$short][0], intval($this->_years)));
         // years
     }
     if ($this->_months > 0) {
         $for_print[] = sprintf("%d %s", $this->_months, MeasureWord::getFormByForms($this->_forms[$short][1], intval($this->_months)));
         // months
     }
     if ($this->_days > 0) {
         $for_print[] = sprintf("%d %s", $this->_days, MeasureWord::getFormByForms($this->_forms[$short][2], intval($this->_days)));
         // days
     }
     if ($this->_hours > 0) {
         $for_print[] = sprintf("%d %s", $this->_hours, MeasureWord::getFormByForms($this->_forms[$short][3], intval($this->_hours)));
         // hours
     }
     if ($this->_minutes > 0) {
         $for_print[] = sprintf("%d %s", $this->_minutes, MeasureWord::getFormByForms($this->_forms[$short][4], intval($this->_minutes)));
         // minutes
     }
     if ($this->_seconds > 0 || empty($for_print)) {
         $for_print[] = sprintf("%d %s", $this->_seconds, MeasureWord::getFormByForms($this->_forms[$short][5], intval($this->_seconds)));
         // seconds
     }
     return trim(preg_replace('/ {2,}/', ' ', join(' ', is_infinite($max_groups) ? $for_print : array_slice($for_print, 0, $max_groups))));
 }
开发者ID:rusranx,项目名称:utils,代码行数:33,代码来源:TimeConverter.php

示例5: 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

示例6: parseNumberValue

 /**
  * Parse a string of the form "number unit" where unit is optional. The
  * results are stored in the $number and $unit parameters. Returns an
  * error code.
  * @param $value string to parse
  * @param $number call-by-ref parameter that will be set to the numerical value
  * @param $unit call-by-ref parameter that will be set to the "unit" string (after the number)
  * @return integer 0 (no errors), 1 (no number found at all), 2 (number
  * too large for this platform)
  */
 protected static function parseNumberValue($value, &$number, &$unit)
 {
     // Parse to find $number and (possibly) $unit
     $decseparator = NumberFormatter::getInstance()->getDecimalSeparatorForContentLanguage();
     $kiloseparator = NumberFormatter::getInstance()->getThousandsSeparatorForContentLanguage();
     $parts = preg_split('/([-+]?\\s*\\d+(?:\\' . $kiloseparator . '\\d\\d\\d)*' . '(?:\\' . $decseparator . '\\d+)?\\s*(?:[eE][-+]?\\d+)?)/u', trim(str_replace(array('&nbsp;', '&#160;', '&thinsp;', ' '), '', $value)), 2, PREG_SPLIT_DELIM_CAPTURE);
     if (count($parts) >= 2) {
         $numstring = str_replace($kiloseparator, '', preg_replace('/\\s*/u', '', $parts[1]));
         // simplify
         if ($decseparator != '.') {
             $numstring = str_replace($decseparator, '.', $numstring);
         }
         list($number) = sscanf($numstring, "%f");
         if (count($parts) >= 3) {
             $unit = self::normalizeUnit($parts[2]);
         }
     }
     if (count($parts) == 1 || $numstring === '') {
         // no number found
         return 1;
     } elseif (is_infinite($number)) {
         // number is too large for this platform
         return 2;
     } else {
         return 0;
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:37,代码来源:SMW_DV_Number.php

示例7: setMaintainabilityIndexWithoutComment

 /**
  * @param float $maintainabilityIndexWithoutComment
  */
 public function setMaintainabilityIndexWithoutComment($maintainabilityIndexWithoutComment)
 {
     if (is_infinite($maintainabilityIndexWithoutComment)) {
         $maintainabilityIndexWithoutComment = 171;
     }
     $this->maintainabilityIndexWithoutComment = round($maintainabilityIndexWithoutComment, 2);
 }
开发者ID:truffo,项目名称:PhpMetrics,代码行数:10,代码来源:Result.php

示例8: process

 /**
  * Process the Truncate operator.
  * 
  * @return integer|null The truncated value or NULL if the sub-expression is NaN or if the sub-expression is NULL.
  * @throws OperatorProcessingException
  */
 public function process()
 {
     $operands = $this->getOperands();
     if ($operands->containsNull() === true) {
         return null;
     }
     if ($operands->exclusivelySingle() === false) {
         $msg = "The Truncate operator only accepts operands with a single cardinality.";
         throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
     }
     if ($operands->exclusivelyNumeric() === false) {
         $msg = "The Truncate operator only accepts operands with an integer or float baseType.";
         throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
     }
     $operand = $operands[0];
     if (is_nan($operand->getValue())) {
         return null;
     } else {
         if (is_infinite($operand->getValue())) {
             return new Float(INF);
         } else {
             return new Integer(intval($operand->getValue()));
         }
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:31,代码来源:TruncateProcessor.php

示例9: logQuery

 public function logQuery(array $query)
 {
     dump($query);
     exit;
     if ($this->logger === NULL) {
         return;
     }
     if (isset($query['batchInsert']) && NULL !== $this->batchInsertTreshold && $this->batchInsertTreshold <= $query['num']) {
         $query['data'] = '**' . $query['num'] . ' item(s)**';
     }
     array_walk_recursive($query, function (&$value, $key) {
         if ($value instanceof \MongoBinData) {
             $value = base64_encode($value->bin);
             return;
         }
         if (is_float($value) && is_infinite($value)) {
             $value = ($value < 0 ? '-' : '') . 'Infinity';
             return;
         }
         if (is_float($value) && is_nan($value)) {
             $value = 'NaN';
             return;
         }
     });
     $this->logger->debug($this->prefix . json_encode($query));
 }
开发者ID:bazo,项目名称:nette-document-manager-extension,代码行数:26,代码来源:Logger.php

示例10: filter

 /**
  * Returns the result of filtering $value
  *
  * @param mixed $value
  * @return mixed
  */
 public function filter($value)
 {
     $unfilteredValue = $value;
     if (is_float($value) && !is_nan($value) && !is_infinite($value)) {
         ErrorHandler::start();
         $formatter = $this->getFormatter();
         $currencyCode = $this->setupCurrencyCode();
         $result = $formatter->formatCurrency($value, $currencyCode);
         ErrorHandler::stop();
         // FIXME: verify that this, given the initial IF condition, never happens
         // if ($result === false) {
         // return $unfilteredValue;
         // }
         // Retrieve the precision internally used by the formatter (i.e., depends from locale and currency code)
         $precision = $formatter->getAttribute(\NumberFormatter::FRACTION_DIGITS);
         // $result is considered valid if the currency's fraction digits can accomodate the $value decimal precision
         // i.e. EUR (fraction digits = 2) must NOT allow double(1.23432423432)
         $isFloatScalePrecise = $this->isFloatScalePrecise($value, $precision, $this->formatter->getAttribute(\NumberFormatter::ROUNDING_MODE));
         if ($this->getScaleCorrectness() && !$isFloatScalePrecise) {
             return $unfilteredValue;
         }
         return $result;
     }
     return $unfilteredValue;
 }
开发者ID:leodido,项目名称:moneylaundry,代码行数:31,代码来源:Currency.php

示例11: dump

 /**
  * Dumps PHP array to YAML.
  *
  * @param mixed $value PHP
  *
  * @return string YAML
  */
 public static function dump($value)
 {
     switch (true) {
         case is_resource($value):
             throw new InvalidArgumentException('Unable to dump PHP resources in a YAML file.');
         case is_object($value):
             return '!!php/object:' . serialize($value);
         case is_array($value):
             return self::dumpArray($value);
         case is_null($value):
             return 'null';
         case true === $value:
             return 'true';
         case false === $value:
             return 'false';
         case ctype_digit($value):
             return is_string($value) ? "'{$value}'" : (int) $value;
         case is_numeric($value):
             return is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : (is_string($value) ? "'{$value}'" : $value);
         case false !== strpos($value, "\n"):
             return sprintf('"%s"', str_replace(array('"', "\n", "\r"), array('\\"', '\\n', '\\r'), $value));
         case preg_match('/[ \\s \' " \\: \\{ \\} \\[ \\] , & \\* \\#]/x', $value):
             return sprintf("'%s'", str_replace('\'', '\'\'', $value));
         case '' == $value:
             return "''";
         case preg_match(self::getTimestampRegex(), $value):
             return "'{$value}'";
         case in_array(strtolower($value), array('true', 'on', '+', 'yes', 'y')):
             return "'{$value}'";
         case in_array(strtolower($value), array('false', 'off', '-', 'no', 'n')):
             return "'{$value}'";
         default:
             return $value;
     }
 }
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:42,代码来源:sfYamlInline.class.php

示例12: fromNative

 /**
  * @param float|int|string $value
  *
  * @return Decimal
  */
 public static function fromNative($value)
 {
     if (\is_infinite((double) $value)) {
         return DecimalInfinite::fromNative($value);
     }
     return new self($value);
 }
开发者ID:cubiche,项目名称:cubiche,代码行数:12,代码来源:Decimal.php

示例13: bigStep

 /**
  *
  *
  * @param Edges    $edges
  * @param int[]    $totalCostOfCheapestPathTo
  * @param Vertex[] $predecessorVertexOfCheapestPathTo
  *
  * @return Vertex|NULL
  */
 private function bigStep(Edges $edges, array &$totalCostOfCheapestPathTo, array &$predecessorVertexOfCheapestPathTo)
 {
     $changed = NULL;
     // check for all edges
     foreach ($edges as $edge) {
         // check for all "ends" of this edge (or for all targetes)
         foreach ($edge->getVerticesTarget() as $toVertex) {
             $fromVertex = $edge->getVertexFromTo($toVertex);
             // If the fromVertex already has a path
             if (isset($totalCostOfCheapestPathTo[$fromVertex->getId()])) {
                 // New possible costs of this path
                 $newCost = $totalCostOfCheapestPathTo[$fromVertex->getId()] + $edge->getWeight();
                 if (is_infinite($newCost)) {
                     $newCost = $edge->getWeight() + 0;
                 }
                 // No path has been found yet
                 if (!isset($totalCostOfCheapestPathTo[$toVertex->getId()]) || $totalCostOfCheapestPathTo[$toVertex->getId()] > $newCost) {
                     $changed = $toVertex;
                     $totalCostOfCheapestPathTo[$toVertex->getId()] = $newCost;
                     $predecessorVertexOfCheapestPathTo[$toVertex->getId()] = $fromVertex;
                 }
             }
         }
     }
     return $changed;
 }
开发者ID:feffi,项目名称:graph,代码行数:35,代码来源:MooreBellmanFord.php

示例14: parseNumber

 /**
  * @param string|float|int
  * @throws InvalidArgumentException
  * @return float|int
  */
 public static function parseNumber($s)
 {
     if (!is_numeric($s) || is_infinite($s)) {
         throw new InvalidArgumentException('Provided value cannot be converted to number');
     }
     return $s * 1;
 }
开发者ID:pilec,项目名称:Money,代码行数:12,代码来源:Math.php

示例15: iSeeAResultOfInfinity

 /**
  * @Then /^I see a result of "Infinity"$/
  */
 public function iSeeAResultOfInfinity()
 {
     $result = $this->calculator->readScreen();
     if (!is_infinite($result)) {
         throw new Exception("Wrong result, expected infinite, actual is [{$result}]");
     }
 }
开发者ID:jamespic,项目名称:sky-qa-tech-test,代码行数:10,代码来源:FeatureContext.php


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