与えられた値を文字列型に変換して返します。
@link https://www.w3.org/TR/WebIDL-1/#idl-ByteString WebIDL Level 1
@param bool|int|float|string|object|null $value
@throws \InvalidArgumentException 配列、__toString()メソッドなどを持たないオブジェクト、またはリソースが与えられた場合。
@return string
486328
public static function toByteString($value)
    {
        if (self::isStringCastable($value)) {
            return (string)$value;
        } else {
            throw new \InvalidArgumentException(ErrorMessageCreator::create($value, 'ByteString (a string)'));
        }
    }
822059
protected function valueToString($value) : string
    {
        if ($value === null) {
            $def_value = 'null';
        } elseif ($value === false) {
            $def_value = 'false';
        } elseif ($value === true) {
            $def_value = 'true';
        } elseif (is_string($value)) {
            $def_value = '"' . str_replace('"', '\\"', $value) . '"';
        } elseif (is_numeric($value)) {
            $def_value = '' . $value;
        }

        return $def_value;
    }
637695
protected function dumpValue($value): string
    {
        if (null === $value) {
            return 'null';
        }

        if (false === $value) {
            return 'false';
        }
        if (true === $value) {
            return 'true';
        }

        if (\is_int($value) || \is_float($value)) {
            return (string)$value;
        }

        if (\is_string($value)) {
            return StringHelper::dumpString($value);
        }

        throw new \InvalidArgumentException('Unsupported data type:' . gettype($value));
    }
918133
protected function assertHeaderValue($value)
    {
        if (!is_string($value) && (!is_array($value) || array_product(array_map('is_string', $value)) === 0)) {
            throw new \InvalidArgumentException("Header value should be a string or an array of strings");
        }
    }
325297
public function get(string $value)
    {
        if (!$this->has($value)) {
            throw new \InvalidArgumentException(\sprintf(
                'Value %s is not a valid key, expecting one of %s',
                $value,
                \implode(', ', \array_keys($this->values))
            ));
        }

        return $this->values[$value];
    }
1343080
public function filter($value)
    {
        $filtered = null;
        if (!$this->validate($value, $filtered))
        {
            throw new \InvalidArgumentException(
                "Not a valid value for " . $this->__toString() . ": " . WF::str($value)
            );
        }

        return $filtered;
    }
1047759
final public static function fromString(string $value)
    {
        $uuid = (new ShortUuid())->decode($value);
        if ($uuid->getVariant() !== Uuid::RFC_4122 || !\in_array($uuid->getVersion(), \range(1, 5), true)) {
            throw new InvalidIdentityException(
                \sprintf('Provided identity value "%s" is not a valid short UUID', $value)
            );
        }

        return new static($value);
    }
570328
public static function isString($value, $message = null)
    {
        if (!is_string($value)) {
            throw new InvalidArgumentException(sprintf(
                $message ?: 'Expected string, but got %s',
                Helper::typeToString($value)
            ));
        }
    }
676055
protected function castToString($value, bool $nullable = true)
    {
        if (null === $value && $nullable) {
            return null;
        }

        return (string) $value;
    }
939461
public function padStringFilter($value, $padCharacter, $maxLength, $padType = 'STR_PAD_RIGHT')
    {
        if ($this->isNullOrEmptyString($padCharacter)) {
            throw new \InvalidArgumentException('Pad String Filter cannot accept a null value or empty string as its first argument');
        }
        if ( ! is_int($maxLength)) {
            throw new \InvalidArgumentException('Pad String Filter expects its second argument to be an integer');
        }
        $diff = (function_exists('mb_strlen'))? strlen($value) - mb_strlen($value) : 0;
        $padType = constant($padType);

        return str_pad($value, $maxLength + $diff, $padCharacter, $padType);
    }
1035037
protected function getStringValue($value)
    {
        if ($value === true) {
            return 'true';
        } elseif ($value === false) {
            return 'false';
        } elseif ($value === null) {
            return 'null';
        } elseif (is_string($value)) {
            return "\"$value\"";
        }

        return rtrim(print_r($value, true));
    }
422943
public static function emptyString($value, $isNull = true)
    {
        if (is_string($value)) {
            return strlen($value) === 0;
        }

        return ($isNull && is_null($value)) || false;
    }
454720
protected function getIdFromValue(string $value)
    {
        try {
            if (null !== $item = $this->getIriConverter()->getItemFromIri($value, ['fetch_data' => false])) {
                return $this->getPropertyAccessor()->getValue($item, 'id');
            }
        } catch (InvalidArgumentException $e) {
            // Do nothing, return the raw value
        }

        return $value;
    }
742568
private function getType($value): string
    {
        if (is_array($value)) {
            if ($value !== array_values($value)) {
                return self::DATATYPE_OBJECT;
            }

            return self::DATATYPE_ARRAY;
        }

        if (is_bool($value)) {
            return self::DATATYPE_BOOLEAN;
        }

        if (is_string($value)) {
            return self::DATATYPE_STRING;
        }

        if (is_int($value) || is_float($value)) {
            return self::DATATYPE_NUMBER;
        }

        if (null === $value) {
            return self::DATATYPE_NULL;
        }

        throw new \InvalidArgumentException(
            sprintf(
                'Value needs to be of type array|bool|string|int|float|null, %s given',
                is_object($value) ? get_class($value) : gettype($value)
            )
        );
    }
406340
public function asCode($value)
    {
        $topLevel = true;
        if (func_num_args() > 1 && false === func_get_arg(1)) {
            $topLevel = false;
        }

        $inlineList = false;
        if (func_num_args() > 2) {
            $inlineList = func_get_arg(2);
        }

        if ($value instanceof Annotation) {
            $value = (string) $value;
        } elseif (is_bool($value)) {
            $value = $value ? 'true' : 'false';
        } elseif (is_string($value)) {
            $value = '"'.$value.'"';
        } elseif (is_array($value)) {
            $tmp = array();
            $useKey = !$this->isKeysNumeric($value);
            foreach ($value as $k => $v) {
                // skip null value
                if (null === $v) {
                    continue;
                }
                $v = $this->asCode($v, false, true);
                if (false === $topLevel) {
                    $k = sprintf('"%s"', $k);
                }

                $tmp[] = $useKey ? sprintf("%s%s%s", $k, ($inlineList ? ':' : '='), $v) : $v;
            }
            $multiline = $this->getOption('multiline') && count($value) > 1;
            $value = implode($multiline ? ",\n" : ', ', $tmp).($multiline ? "\n" : '');
            if ($topLevel) {
                $value = sprintf('(%s)', $value);
            } else {
                $value = sprintf('{%s}', $value);
            }
            if ($multiline) {
                $value = $this->wrapLines($value, 1);
            }
        }

        return $value;
    }
904945
protected function checkValueStructure(BaseValue $value)
    {
        // Input file URI, if set needs to point to existing file
        if (isset($value->inputUri)) {
            if (!file_exists($value->inputUri)) {
                throw new InvalidArgumentValue(
                    '$value->inputUri',
                    $value->inputUri,
                    get_class($this)
                );
            }
        } elseif (!isset($value->id)) {
            throw new InvalidArgumentValue(
                '$value->id',
                $value->id,
                get_class($this)
            );
        }

        // Required parameter $fileName
        if (!isset($value->fileName) || !is_string($value->fileName)) {
            throw new InvalidArgumentValue(
                '$value->fileName',
                $value->fileName,
                get_class($this)
            );
        }

        // Optional parameter $fileSize
        if (isset($value->fileSize) && !is_int($value->fileSize)) {
            throw new InvalidArgumentValue(
                '$value->fileSize',
                $value->fileSize,
                get_class($this)
            );
        }
    }
335746
protected function parseValue($value)
  {
    if ('*' === substr($value, 0, 1)) {
      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 InvalidArgumentException(sprintf('Reference "%s" does not exist (%s).', $value, $this->currentLine));
      }

      return $this->refs[$value];
    }

    if (preg_match('/^(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?$/', $value, $matches)) {
      $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';

      return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers)));
    } else {
      return sfYamlInline::load($value);
    }
  }