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


PHP Inline::evaluateBinaryScalar方法代码示例

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


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

示例1: parseValue

 /**
  * Parses a YAML value.
  *
  * @param string $value   A YAML value
  * @param int    $flags   A bit field of PARSE_* constants to customize the YAML parser behavior
  * @param string $context The parser context (either sequence or mapping)
  *
  * @return mixed A PHP value
  *
  * @throws ParseException When reference does not exist
  */
 private function parseValue($value, $flags, $context)
 {
     if (0 === strpos($value, '*')) {
         if (false !== ($pos = strpos($value, '#'))) {
             $value = substr($value, 1, $pos - 2);
         } else {
             $value = substr($value, 1);
         }
         if (!array_key_exists($value, $this->refs)) {
             throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine);
         }
         return $this->refs[$value];
     }
     if (preg_match('/^' . self::TAG_PATTERN . self::BLOCK_SCALAR_HEADER_PATTERN . '$/', $value, $matches)) {
         $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
         $data = $this->parseBlockScalar($matches['separator'], preg_replace('#\\d+#', '', $modifiers), (int) abs($modifiers));
         if (isset($matches['tag']) && '!!binary' === $matches['tag']) {
             return Inline::evaluateBinaryScalar($data);
         }
         return $data;
     }
     try {
         Inline::$parsedLineNumber = $this->getRealCurrentLineNb();
         $parsedValue = Inline::parse($value, $flags, $this->refs);
         if ('mapping' === $context && is_string($parsedValue) && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($parsedValue, ': ')) {
             throw new ParseException('A colon cannot be used in an unquoted mapping value.');
         }
         return $parsedValue;
     } catch (ParseException $e) {
         $e->setParsedLine($this->getRealCurrentLineNb() + 1);
         $e->setSnippet($this->currentLine);
         throw $e;
     }
 }
开发者ID:Gladhon,项目名称:symfony,代码行数:45,代码来源:Parser.php

示例2: parseValue

 /**
  * Parses a YAML value.
  *
  * @param string $value   A YAML value
  * @param int    $flags   A bit field of PARSE_* constants to customize the YAML parser behavior
  * @param string $context The parser context (either sequence or mapping)
  *
  * @return mixed A PHP value
  *
  * @throws ParseException When reference does not exist
  */
 private function parseValue($value, $flags, $context)
 {
     if (0 === strpos($value, '*')) {
         if (false !== ($pos = strpos($value, '#'))) {
             $value = substr($value, 1, $pos - 2);
         } else {
             $value = substr($value, 1);
         }
         if (!array_key_exists($value, $this->refs)) {
             throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine);
         }
         return $this->refs[$value];
     }
     if (preg_match('/^' . self::TAG_PATTERN . self::BLOCK_SCALAR_HEADER_PATTERN . '$/', $value, $matches)) {
         $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
         $data = $this->parseBlockScalar($matches['separator'], preg_replace('#\\d+#', '', $modifiers), (int) abs($modifiers));
         if (isset($matches['tag']) && '!!binary' === $matches['tag']) {
             return Inline::evaluateBinaryScalar($data);
         }
         return $data;
     }
     try {
         $quotation = '' !== $value && ('"' === $value[0] || "'" === $value[0]) ? $value[0] : null;
         // do not take following lines into account when the current line is a quoted single line value
         if (null !== $quotation && preg_match('/^' . $quotation . '.*' . $quotation . '(\\s*#.*)?$/', $value)) {
             return Inline::parse($value, $flags, $this->refs);
         }
         while ($this->moveToNextLine()) {
             // unquoted strings end before the first unindented line
             if (null === $quotation && $this->getCurrentLineIndentation() === 0) {
                 $this->moveToPreviousLine();
                 break;
             }
             $value .= ' ' . trim($this->currentLine);
             // quoted string values end with a line that is terminated with the quotation character
             if ('' !== $this->currentLine && substr($this->currentLine, -1) === $quotation) {
                 break;
             }
         }
         Inline::$parsedLineNumber = $this->getRealCurrentLineNb();
         $parsedValue = Inline::parse($value, $flags, $this->refs);
         if ('mapping' === $context && is_string($parsedValue) && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($parsedValue, ': ')) {
             throw new ParseException('A colon cannot be used in an unquoted mapping value.');
         }
         return $parsedValue;
     } catch (ParseException $e) {
         $e->setParsedLine($this->getRealCurrentLineNb() + 1);
         $e->setSnippet($this->currentLine);
         throw $e;
     }
 }
开发者ID:ayoah,项目名称:symfony,代码行数:62,代码来源:Parser.php


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