updated-packages
This commit is contained in:
3
vendor/symfony/yaml/.gitignore
vendored
3
vendor/symfony/yaml/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
14
vendor/symfony/yaml/CHANGELOG.md
vendored
14
vendor/symfony/yaml/CHANGELOG.md
vendored
@@ -1,6 +1,18 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.4.0
|
||||
-----
|
||||
|
||||
* Added support for parsing the inline notation spanning multiple lines.
|
||||
* Added support to dump `null` as `~` by using the `Yaml::DUMP_NULL_AS_TILDE` flag.
|
||||
* deprecated accepting STDIN implicitly when using the `lint:yaml` command, use `lint:yaml -` (append a dash) instead to make it explicit.
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
* Using a mapping inside a multi-line string is deprecated and will throw a `ParseException` in 5.0.
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
@@ -148,7 +160,7 @@ CHANGELOG
|
||||
* Added support for customizing the dumped YAML string through an optional bit field:
|
||||
|
||||
```php
|
||||
Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE | Yaml::DUMP_OBJECT);
|
||||
Yaml::dump(['foo' => new A(), 'bar' => 1], 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE | Yaml::DUMP_OBJECT);
|
||||
```
|
||||
|
||||
3.0.0
|
||||
|
82
vendor/symfony/yaml/Command/LintCommand.php
vendored
82
vendor/symfony/yaml/Command/LintCommand.php
vendored
@@ -53,8 +53,8 @@ class LintCommand extends Command
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setDescription('Lints a file and outputs encountered errors')
|
||||
->addArgument('filename', InputArgument::IS_ARRAY, 'A file or a directory or STDIN')
|
||||
->setDescription('Lint a file and outputs encountered errors')
|
||||
->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN')
|
||||
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
||||
->addOption('parse-tags', null, InputOption::VALUE_NONE, 'Parse custom tags')
|
||||
->setHelp(<<<EOF
|
||||
@@ -63,7 +63,7 @@ the first encountered syntax error.
|
||||
|
||||
You can validates YAML contents passed from STDIN:
|
||||
|
||||
<info>cat filename | php %command.full_name%</info>
|
||||
<info>cat filename | php %command.full_name% -</info>
|
||||
|
||||
You can also validate the syntax of a file:
|
||||
|
||||
@@ -87,15 +87,22 @@ EOF
|
||||
$this->displayCorrectFiles = $output->isVerbose();
|
||||
$flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0;
|
||||
|
||||
if (0 === \count($filenames)) {
|
||||
if (!$stdin = $this->getStdin()) {
|
||||
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
|
||||
}
|
||||
|
||||
return $this->display($io, array($this->validate($stdin, $flags)));
|
||||
if (['-'] === $filenames) {
|
||||
return $this->display($io, [$this->validate(file_get_contents('php://stdin'), $flags)]);
|
||||
}
|
||||
|
||||
$filesInfo = array();
|
||||
// @deprecated to be removed in 5.0
|
||||
if (!$filenames) {
|
||||
if (0 === ftell(\STDIN)) {
|
||||
@trigger_error('Piping content from STDIN to the "lint:yaml" command without passing the dash symbol "-" as argument is deprecated since Symfony 4.4.', \E_USER_DEPRECATED);
|
||||
|
||||
return $this->display($io, [$this->validate(file_get_contents('php://stdin'), $flags)]);
|
||||
}
|
||||
|
||||
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
|
||||
}
|
||||
|
||||
$filesInfo = [];
|
||||
foreach ($filenames as $filename) {
|
||||
if (!$this->isReadable($filename)) {
|
||||
throw new RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));
|
||||
@@ -109,10 +116,10 @@ EOF
|
||||
return $this->display($io, $filesInfo);
|
||||
}
|
||||
|
||||
private function validate($content, $flags, $file = null)
|
||||
private function validate(string $content, int $flags, string $file = null)
|
||||
{
|
||||
$prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) {
|
||||
if (E_USER_DEPRECATED === $level) {
|
||||
if (\E_USER_DEPRECATED === $level) {
|
||||
throw new ParseException($message, $this->getParser()->getRealCurrentLineNb() + 1);
|
||||
}
|
||||
|
||||
@@ -122,15 +129,15 @@ EOF
|
||||
try {
|
||||
$this->getParser()->parse($content, Yaml::PARSE_CONSTANT | $flags);
|
||||
} catch (ParseException $e) {
|
||||
return array('file' => $file, 'line' => $e->getParsedLine(), 'valid' => false, 'message' => $e->getMessage());
|
||||
return ['file' => $file, 'line' => $e->getParsedLine(), 'valid' => false, 'message' => $e->getMessage()];
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
return array('file' => $file, 'valid' => true);
|
||||
return ['file' => $file, 'valid' => true];
|
||||
}
|
||||
|
||||
private function display(SymfonyStyle $io, array $files)
|
||||
private function display(SymfonyStyle $io, array $files): int
|
||||
{
|
||||
switch ($this->format) {
|
||||
case 'txt':
|
||||
@@ -142,10 +149,11 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
private function displayTxt(SymfonyStyle $io, array $filesInfo)
|
||||
private function displayTxt(SymfonyStyle $io, array $filesInfo): int
|
||||
{
|
||||
$countFiles = \count($filesInfo);
|
||||
$erroredFiles = 0;
|
||||
$suggestTagOption = false;
|
||||
|
||||
foreach ($filesInfo as $info) {
|
||||
if ($info['valid'] && $this->displayCorrectFiles) {
|
||||
@@ -154,19 +162,23 @@ EOF
|
||||
++$erroredFiles;
|
||||
$io->text('<error> ERROR </error>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
|
||||
$io->text(sprintf('<error> >> %s</error>', $info['message']));
|
||||
|
||||
if (false !== strpos($info['message'], 'PARSE_CUSTOM_TAGS')) {
|
||||
$suggestTagOption = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 === $erroredFiles) {
|
||||
$io->success(sprintf('All %d YAML files contain valid syntax.', $countFiles));
|
||||
} else {
|
||||
$io->warning(sprintf('%d YAML files have valid syntax and %d contain errors.', $countFiles - $erroredFiles, $erroredFiles));
|
||||
$io->warning(sprintf('%d YAML files have valid syntax and %d contain errors.%s', $countFiles - $erroredFiles, $erroredFiles, $suggestTagOption ? ' Use the --parse-tags option if you want parse custom tags.' : ''));
|
||||
}
|
||||
|
||||
return min($erroredFiles, 1);
|
||||
}
|
||||
|
||||
private function displayJson(SymfonyStyle $io, array $filesInfo)
|
||||
private function displayJson(SymfonyStyle $io, array $filesInfo): int
|
||||
{
|
||||
$errors = 0;
|
||||
|
||||
@@ -175,14 +187,18 @@ EOF
|
||||
if (!$v['valid']) {
|
||||
++$errors;
|
||||
}
|
||||
|
||||
if (isset($v['message']) && false !== strpos($v['message'], 'PARSE_CUSTOM_TAGS')) {
|
||||
$v['message'] .= ' Use the --parse-tags option if you want parse custom tags.';
|
||||
}
|
||||
});
|
||||
|
||||
$io->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
$io->writeln(json_encode($filesInfo, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES));
|
||||
|
||||
return min($errors, 1);
|
||||
}
|
||||
|
||||
private function getFiles($fileOrDirectory)
|
||||
private function getFiles(string $fileOrDirectory): iterable
|
||||
{
|
||||
if (is_file($fileOrDirectory)) {
|
||||
yield new \SplFileInfo($fileOrDirectory);
|
||||
@@ -191,7 +207,7 @@ EOF
|
||||
}
|
||||
|
||||
foreach ($this->getDirectoryIterator($fileOrDirectory) as $file) {
|
||||
if (!\in_array($file->getExtension(), array('yml', 'yaml'))) {
|
||||
if (!\in_array($file->getExtension(), ['yml', 'yaml'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -199,21 +215,7 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
private function getStdin()
|
||||
{
|
||||
if (0 !== ftell(STDIN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$inputs = '';
|
||||
while (!feof(STDIN)) {
|
||||
$inputs .= fread(STDIN, 1024);
|
||||
}
|
||||
|
||||
return $inputs;
|
||||
}
|
||||
|
||||
private function getParser()
|
||||
private function getParser(): Parser
|
||||
{
|
||||
if (!$this->parser) {
|
||||
$this->parser = new Parser();
|
||||
@@ -222,7 +224,7 @@ EOF
|
||||
return $this->parser;
|
||||
}
|
||||
|
||||
private function getDirectoryIterator($directory)
|
||||
private function getDirectoryIterator(string $directory): iterable
|
||||
{
|
||||
$default = function ($directory) {
|
||||
return new \RecursiveIteratorIterator(
|
||||
@@ -232,20 +234,20 @@ EOF
|
||||
};
|
||||
|
||||
if (null !== $this->directoryIteratorProvider) {
|
||||
return \call_user_func($this->directoryIteratorProvider, $directory, $default);
|
||||
return ($this->directoryIteratorProvider)($directory, $default);
|
||||
}
|
||||
|
||||
return $default($directory);
|
||||
}
|
||||
|
||||
private function isReadable($fileOrDirectory)
|
||||
private function isReadable(string $fileOrDirectory): bool
|
||||
{
|
||||
$default = function ($fileOrDirectory) {
|
||||
return is_readable($fileOrDirectory);
|
||||
};
|
||||
|
||||
if (null !== $this->isReadableProvider) {
|
||||
return \call_user_func($this->isReadableProvider, $fileOrDirectory, $default);
|
||||
return ($this->isReadableProvider)($fileOrDirectory, $default);
|
||||
}
|
||||
|
||||
return $default($fileOrDirectory);
|
||||
|
55
vendor/symfony/yaml/Dumper.php
vendored
55
vendor/symfony/yaml/Dumper.php
vendored
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Yaml;
|
||||
|
||||
use Symfony\Component\Yaml\Tag\TaggedValue;
|
||||
|
||||
/**
|
||||
* Dumper dumps PHP variables to YAML strings.
|
||||
*
|
||||
@@ -56,20 +58,63 @@ class Dumper
|
||||
$dumpObjectAsInlineMap = empty((array) $input);
|
||||
}
|
||||
|
||||
if ($inline <= 0 || (!\is_array($input) && $dumpObjectAsInlineMap) || empty($input)) {
|
||||
if ($inline <= 0 || (!\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap) || empty($input)) {
|
||||
$output .= $prefix.Inline::dump($input, $flags);
|
||||
} else {
|
||||
$dumpAsMap = Inline::isHash($input);
|
||||
|
||||
foreach ($input as $key => $value) {
|
||||
if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r\n")) {
|
||||
if ('' !== $output && "\n" !== $output[-1]) {
|
||||
$output .= "\n";
|
||||
}
|
||||
|
||||
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r")) {
|
||||
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
|
||||
// http://www.yaml.org/spec/1.2/spec.html#id2793979
|
||||
$blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : '';
|
||||
$output .= sprintf("%s%s%s |%s\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator);
|
||||
|
||||
foreach (preg_split('/\n|\r\n/', $value) as $row) {
|
||||
$output .= sprintf("%s%s%s\n", $prefix, str_repeat(' ', $this->indentation), $row);
|
||||
if (isset($value[-2]) && "\n" === $value[-2] && "\n" === $value[-1]) {
|
||||
$blockChompingIndicator = '+';
|
||||
} elseif ("\n" === $value[-1]) {
|
||||
$blockChompingIndicator = '';
|
||||
} else {
|
||||
$blockChompingIndicator = '-';
|
||||
}
|
||||
|
||||
$output .= sprintf('%s%s%s |%s%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator, $blockChompingIndicator);
|
||||
|
||||
foreach (explode("\n", $value) as $row) {
|
||||
if ('' === $row) {
|
||||
$output .= "\n";
|
||||
} else {
|
||||
$output .= sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($value instanceof TaggedValue) {
|
||||
$output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag());
|
||||
|
||||
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && false !== strpos($value->getValue(), "\n") && false === strpos($value->getValue(), "\r\n")) {
|
||||
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
|
||||
// http://www.yaml.org/spec/1.2/spec.html#id2793979
|
||||
$blockIndentationIndicator = (' ' === substr($value->getValue(), 0, 1)) ? (string) $this->indentation : '';
|
||||
$output .= sprintf(' |%s', $blockIndentationIndicator);
|
||||
|
||||
foreach (explode("\n", $value->getValue()) as $row) {
|
||||
$output .= sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($inline - 1 <= 0 || null === $value->getValue() || \is_scalar($value->getValue())) {
|
||||
$output .= ' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n";
|
||||
} else {
|
||||
$output .= "\n";
|
||||
$output .= $this->dump($value->getValue(), $inline - 1, $dumpAsMap ? $indent + $this->indentation : $indent + 2, $flags);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
18
vendor/symfony/yaml/Escaper.php
vendored
18
vendor/symfony/yaml/Escaper.php
vendored
@@ -22,26 +22,28 @@ namespace Symfony\Component\Yaml;
|
||||
class Escaper
|
||||
{
|
||||
// Characters that would cause a dumped string to require double quoting.
|
||||
const REGEX_CHARACTER_TO_ESCAPE = "[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9";
|
||||
public const REGEX_CHARACTER_TO_ESCAPE = "[\\x00-\\x1f]|\x7f|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9";
|
||||
|
||||
// Mapping arrays for escaping a double quoted string. The backslash is
|
||||
// first to ensure proper escaping because str_replace operates iteratively
|
||||
// on the input arrays. This ordering of the characters avoids the use of strtr,
|
||||
// which performs more slowly.
|
||||
private static $escapees = array('\\', '\\\\', '\\"', '"',
|
||||
private const ESCAPEES = ['\\', '\\\\', '\\"', '"',
|
||||
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
|
||||
"\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
|
||||
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
|
||||
"\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
|
||||
"\x7f",
|
||||
"\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",
|
||||
);
|
||||
private static $escaped = array('\\\\', '\\"', '\\\\', '\\"',
|
||||
];
|
||||
private const ESCAPED = ['\\\\', '\\"', '\\\\', '\\"',
|
||||
'\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a',
|
||||
'\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f',
|
||||
'\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17',
|
||||
'\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f',
|
||||
'\\x7f',
|
||||
'\\N', '\\_', '\\L', '\\P',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Determines if a PHP value would require double quoting in YAML.
|
||||
@@ -64,7 +66,7 @@ class Escaper
|
||||
*/
|
||||
public static function escapeWithDoubleQuotes(string $value): string
|
||||
{
|
||||
return sprintf('"%s"', str_replace(self::$escapees, self::$escaped, $value));
|
||||
return sprintf('"%s"', str_replace(self::ESCAPEES, self::ESCAPED, $value));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,13 +80,13 @@ class Escaper
|
||||
{
|
||||
// Determines if a PHP value is entirely composed of a value that would
|
||||
// require single quoting in YAML.
|
||||
if (\in_array(strtolower($value), array('null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'))) {
|
||||
if (\in_array(strtolower($value), ['null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Determines if the PHP value contains any single characters that would
|
||||
// cause it to require single quoting in YAML.
|
||||
return 0 < preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
|
||||
return 0 < preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` \p{Zs}]/xu', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
13
vendor/symfony/yaml/Exception/ParseException.php
vendored
13
vendor/symfony/yaml/Exception/ParseException.php
vendored
@@ -24,13 +24,12 @@ class ParseException extends RuntimeException
|
||||
private $rawMessage;
|
||||
|
||||
/**
|
||||
* @param string $message The error message
|
||||
* @param int $parsedLine The line where the error occurred
|
||||
* @param string|null $snippet The snippet of code near the problem
|
||||
* @param string|null $parsedFile The file name where the error occurred
|
||||
* @param \Exception|null $previous The previous exception
|
||||
* @param string $message The error message
|
||||
* @param int $parsedLine The line where the error occurred
|
||||
* @param string|null $snippet The snippet of code near the problem
|
||||
* @param string|null $parsedFile The file name where the error occurred
|
||||
*/
|
||||
public function __construct(string $message, int $parsedLine = -1, string $snippet = null, string $parsedFile = null, \Exception $previous = null)
|
||||
public function __construct(string $message, int $parsedLine = -1, string $snippet = null, string $parsedFile = null, \Throwable $previous = null)
|
||||
{
|
||||
$this->parsedFile = $parsedFile;
|
||||
$this->parsedLine = $parsedLine;
|
||||
@@ -121,7 +120,7 @@ class ParseException extends RuntimeException
|
||||
}
|
||||
|
||||
if (null !== $this->parsedFile) {
|
||||
$this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||
$this->message .= sprintf(' in %s', json_encode($this->parsedFile, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
if ($this->parsedLine >= 0) {
|
||||
|
245
vendor/symfony/yaml/Inline.php
vendored
245
vendor/symfony/yaml/Inline.php
vendored
@@ -24,7 +24,7 @@ use Symfony\Component\Yaml\Tag\TaggedValue;
|
||||
*/
|
||||
class Inline
|
||||
{
|
||||
const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*+(?:\\\\.[^"\\\\]*+)*+)"|\'([^\']*+(?:\'\'[^\']*+)*+)\')';
|
||||
public const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*+(?:\\\\.[^"\\\\]*+)*+)"|\'([^\']*+(?:\'\'[^\']*+)*+)\')';
|
||||
|
||||
public static $parsedLineNumber = -1;
|
||||
public static $parsedFilename;
|
||||
@@ -34,12 +34,7 @@ class Inline
|
||||
private static $objectForMap = false;
|
||||
private static $constantSupport = false;
|
||||
|
||||
/**
|
||||
* @param int $flags
|
||||
* @param int|null $parsedLineNumber
|
||||
* @param string|null $parsedFilename
|
||||
*/
|
||||
public static function initialize($flags, $parsedLineNumber = null, $parsedFilename = null)
|
||||
public static function initialize(int $flags, int $parsedLineNumber = null, string $parsedFilename = null)
|
||||
{
|
||||
self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags);
|
||||
self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags);
|
||||
@@ -63,7 +58,7 @@ class Inline
|
||||
*
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static function parse(string $value = null, int $flags = 0, array $references = array())
|
||||
public static function parse(string $value = null, int $flags = 0, array &$references = [])
|
||||
{
|
||||
self::initialize($flags);
|
||||
|
||||
@@ -73,40 +68,42 @@ class Inline
|
||||
return '';
|
||||
}
|
||||
|
||||
if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
|
||||
if (2 /* MB_OVERLOAD_STRING */ & (int) \ini_get('mbstring.func_overload')) {
|
||||
$mbEncoding = mb_internal_encoding();
|
||||
mb_internal_encoding('ASCII');
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$tag = self::parseTag($value, $i, $flags);
|
||||
switch ($value[$i]) {
|
||||
case '[':
|
||||
$result = self::parseSequence($value, $flags, $i, $references);
|
||||
++$i;
|
||||
break;
|
||||
case '{':
|
||||
$result = self::parseMapping($value, $flags, $i, $references);
|
||||
++$i;
|
||||
break;
|
||||
default:
|
||||
$result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
|
||||
}
|
||||
try {
|
||||
$i = 0;
|
||||
$tag = self::parseTag($value, $i, $flags);
|
||||
switch ($value[$i]) {
|
||||
case '[':
|
||||
$result = self::parseSequence($value, $flags, $i, $references);
|
||||
++$i;
|
||||
break;
|
||||
case '{':
|
||||
$result = self::parseMapping($value, $flags, $i, $references);
|
||||
++$i;
|
||||
break;
|
||||
default:
|
||||
$result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
|
||||
}
|
||||
|
||||
if (null !== $tag && '' !== $tag) {
|
||||
return new TaggedValue($tag, $result);
|
||||
}
|
||||
// some comments are allowed at the end
|
||||
if (preg_replace('/\s*#.*$/A', '', substr($value, $i))) {
|
||||
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
// some comments are allowed at the end
|
||||
if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
|
||||
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
if (null !== $tag && '' !== $tag) {
|
||||
return new TaggedValue($tag, $result);
|
||||
}
|
||||
|
||||
if (isset($mbEncoding)) {
|
||||
mb_internal_encoding($mbEncoding);
|
||||
return $result;
|
||||
} finally {
|
||||
if (isset($mbEncoding)) {
|
||||
mb_internal_encoding($mbEncoding);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,9 +124,11 @@ class Inline
|
||||
throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value)));
|
||||
}
|
||||
|
||||
return 'null';
|
||||
return self::dumpNull($flags);
|
||||
case $value instanceof \DateTimeInterface:
|
||||
return $value->format('c');
|
||||
case $value instanceof \UnitEnum:
|
||||
return sprintf('!php/const %s::%s', \get_class($value), $value->name);
|
||||
case \is_object($value):
|
||||
if ($value instanceof TaggedValue) {
|
||||
return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags);
|
||||
@@ -140,7 +139,7 @@ class Inline
|
||||
}
|
||||
|
||||
if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) {
|
||||
$output = array();
|
||||
$output = [];
|
||||
|
||||
foreach ($value as $key => $val) {
|
||||
$output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
|
||||
@@ -153,21 +152,21 @@ class Inline
|
||||
throw new DumpException('Object support when dumping a YAML file has been disabled.');
|
||||
}
|
||||
|
||||
return 'null';
|
||||
return self::dumpNull($flags);
|
||||
case \is_array($value):
|
||||
return self::dumpArray($value, $flags);
|
||||
case null === $value:
|
||||
return 'null';
|
||||
return self::dumpNull($flags);
|
||||
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):
|
||||
$locale = setlocale(LC_NUMERIC, 0);
|
||||
case \is_int($value):
|
||||
return $value;
|
||||
case is_numeric($value) && false === strpbrk($value, "\f\n\r\t\v"):
|
||||
$locale = setlocale(\LC_NUMERIC, 0);
|
||||
if (false !== $locale) {
|
||||
setlocale(LC_NUMERIC, 'C');
|
||||
setlocale(\LC_NUMERIC, 'C');
|
||||
}
|
||||
if (\is_float($value)) {
|
||||
$repr = (string) $value;
|
||||
@@ -181,7 +180,7 @@ class Inline
|
||||
$repr = \is_string($value) ? "'$value'" : (string) $value;
|
||||
}
|
||||
if (false !== $locale) {
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
setlocale(\LC_NUMERIC, $locale);
|
||||
}
|
||||
|
||||
return $repr;
|
||||
@@ -237,7 +236,7 @@ class Inline
|
||||
{
|
||||
// array
|
||||
if (($value || Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE & $flags) && !self::isHash($value)) {
|
||||
$output = array();
|
||||
$output = [];
|
||||
foreach ($value as $val) {
|
||||
$output[] = self::dump($val, $flags);
|
||||
}
|
||||
@@ -246,7 +245,7 @@ class Inline
|
||||
}
|
||||
|
||||
// hash
|
||||
$output = array();
|
||||
$output = [];
|
||||
foreach ($value as $key => $val) {
|
||||
$output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
|
||||
}
|
||||
@@ -254,6 +253,15 @@ class Inline
|
||||
return sprintf('{ %s }', implode(', ', $output));
|
||||
}
|
||||
|
||||
private static function dumpNull(int $flags): string
|
||||
{
|
||||
if (Yaml::DUMP_NULL_AS_TILDE & $flags) {
|
||||
return '~';
|
||||
}
|
||||
|
||||
return 'null';
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a YAML scalar.
|
||||
*
|
||||
@@ -261,14 +269,15 @@ class Inline
|
||||
*
|
||||
* @throws ParseException When malformed inline YAML string is parsed
|
||||
*/
|
||||
public static function parseScalar(string $scalar, int $flags = 0, array $delimiters = null, int &$i = 0, bool $evaluate = true, array $references = array())
|
||||
public static function parseScalar(string $scalar, int $flags = 0, array $delimiters = null, int &$i = 0, bool $evaluate = true, array &$references = [], bool &$isQuoted = null)
|
||||
{
|
||||
if (\in_array($scalar[$i], array('"', "'"))) {
|
||||
if (\in_array($scalar[$i], ['"', "'"])) {
|
||||
// quoted scalar
|
||||
$isQuoted = true;
|
||||
$output = self::parseQuotedScalar($scalar, $i);
|
||||
|
||||
if (null !== $delimiters) {
|
||||
$tmp = ltrim(substr($scalar, $i), ' ');
|
||||
$tmp = ltrim(substr($scalar, $i), " \n");
|
||||
if ('' === $tmp) {
|
||||
throw new ParseException(sprintf('Unexpected end of line, expected one of "%s".', implode('', $delimiters)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
@@ -278,12 +287,14 @@ class Inline
|
||||
}
|
||||
} else {
|
||||
// "normal" string
|
||||
$isQuoted = false;
|
||||
|
||||
if (!$delimiters) {
|
||||
$output = substr($scalar, $i);
|
||||
$i += \strlen($output);
|
||||
|
||||
// remove comments
|
||||
if (Parser::preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
|
||||
if (Parser::preg_match('/[ \t]+#/', $output, $match, \PREG_OFFSET_CAPTURE)) {
|
||||
$output = substr($output, 0, $match[0][1]);
|
||||
}
|
||||
} elseif (Parser::preg_match('/^(.*?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
|
||||
@@ -291,7 +302,7 @@ class Inline
|
||||
$i += \strlen($output);
|
||||
$output = trim($output);
|
||||
} else {
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $scalar), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', $scalar), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
}
|
||||
|
||||
// a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >)
|
||||
@@ -300,7 +311,7 @@ class Inline
|
||||
}
|
||||
|
||||
if ($evaluate) {
|
||||
$output = self::evaluateScalar($output, $flags, $references);
|
||||
$output = self::evaluateScalar($output, $flags, $references, $isQuoted);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,10 +323,10 @@ class Inline
|
||||
*
|
||||
* @throws ParseException When malformed inline YAML string is parsed
|
||||
*/
|
||||
private static function parseQuotedScalar(string $scalar, int &$i): string
|
||||
private static function parseQuotedScalar(string $scalar, int &$i = 0): string
|
||||
{
|
||||
if (!Parser::preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: %s.', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
$output = substr($match[0], 1, \strlen($match[0]) - 2);
|
||||
@@ -337,9 +348,9 @@ class Inline
|
||||
*
|
||||
* @throws ParseException When malformed inline YAML string is parsed
|
||||
*/
|
||||
private static function parseSequence(string $sequence, int $flags, int &$i = 0, array $references = array()): array
|
||||
private static function parseSequence(string $sequence, int $flags, int &$i = 0, array &$references = []): array
|
||||
{
|
||||
$output = array();
|
||||
$output = [];
|
||||
$len = \strlen($sequence);
|
||||
++$i;
|
||||
|
||||
@@ -365,8 +376,7 @@ class Inline
|
||||
$value = self::parseMapping($sequence, $flags, $i, $references);
|
||||
break;
|
||||
default:
|
||||
$isQuoted = \in_array($sequence[$i], array('"', "'"));
|
||||
$value = self::parseScalar($sequence, $flags, array(',', ']'), $i, null === $tag, $references);
|
||||
$value = self::parseScalar($sequence, $flags, [',', ']'], $i, null === $tag, $references, $isQuoted);
|
||||
|
||||
// the value can be an array if a reference has been resolved to an array var
|
||||
if (\is_string($value) && !$isQuoted && false !== strpos($value, ': ')) {
|
||||
@@ -379,6 +389,11 @@ class Inline
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
|
||||
$references[$matches['ref']] = $matches['value'];
|
||||
$value = $matches['value'];
|
||||
}
|
||||
|
||||
--$i;
|
||||
}
|
||||
|
||||
@@ -391,7 +406,7 @@ class Inline
|
||||
++$i;
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,9 +416,9 @@ class Inline
|
||||
*
|
||||
* @throws ParseException When malformed inline YAML string is parsed
|
||||
*/
|
||||
private static function parseMapping(string $mapping, int $flags, int &$i = 0, array $references = array())
|
||||
private static function parseMapping(string $mapping, int $flags, int &$i = 0, array &$references = [])
|
||||
{
|
||||
$output = array();
|
||||
$output = [];
|
||||
$len = \strlen($mapping);
|
||||
++$i;
|
||||
$allowOverwrite = false;
|
||||
@@ -413,6 +428,7 @@ class Inline
|
||||
switch ($mapping[$i]) {
|
||||
case ' ':
|
||||
case ',':
|
||||
case "\n":
|
||||
++$i;
|
||||
continue 2;
|
||||
case '}':
|
||||
@@ -425,13 +441,18 @@ class Inline
|
||||
|
||||
// key
|
||||
$offsetBeforeKeyParsing = $i;
|
||||
$isKeyQuoted = \in_array($mapping[$i], array('"', "'"), true);
|
||||
$key = self::parseScalar($mapping, $flags, array(':', ' '), $i, false, array());
|
||||
$isKeyQuoted = \in_array($mapping[$i], ['"', "'"], true);
|
||||
$key = self::parseScalar($mapping, $flags, [':', ' '], $i, false);
|
||||
|
||||
if ($offsetBeforeKeyParsing === $i) {
|
||||
throw new ParseException('Missing mapping key.', self::$parsedLineNumber + 1, $mapping);
|
||||
}
|
||||
|
||||
if ('!php/const' === $key) {
|
||||
$key .= ' '.self::parseScalar($mapping, $flags, [':'], $i, false);
|
||||
$key = self::evaluateScalar($key, $flags);
|
||||
}
|
||||
|
||||
if (false === $i = strpos($mapping, ':', $i)) {
|
||||
break;
|
||||
}
|
||||
@@ -444,7 +465,7 @@ class Inline
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isKeyQuoted && (!isset($mapping[$i + 1]) || !\in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true))) {
|
||||
if (!$isKeyQuoted && (!isset($mapping[$i + 1]) || !\in_array($mapping[$i + 1], [' ', ',', '[', ']', '{', '}', "\n"], true))) {
|
||||
throw new ParseException('Colons must be followed by a space or an indication character (i.e. " ", ",", "[", "]", "{", "}").', self::$parsedLineNumber + 1, $mapping);
|
||||
}
|
||||
|
||||
@@ -453,7 +474,7 @@ class Inline
|
||||
}
|
||||
|
||||
while ($i < $len) {
|
||||
if (':' === $mapping[$i] || ' ' === $mapping[$i]) {
|
||||
if (':' === $mapping[$i] || ' ' === $mapping[$i] || "\n" === $mapping[$i]) {
|
||||
++$i;
|
||||
|
||||
continue;
|
||||
@@ -502,7 +523,7 @@ class Inline
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$value = self::parseScalar($mapping, $flags, array(',', '}'), $i, null === $tag, $references);
|
||||
$value = self::parseScalar($mapping, $flags, [',', '}', "\n"], $i, null === $tag, $references, $isValueQuoted);
|
||||
// Spec: Keys MUST be unique; first one wins.
|
||||
// Parser cannot abort this mapping earlier, since lines
|
||||
// are processed sequentially.
|
||||
@@ -510,6 +531,11 @@ class Inline
|
||||
if ('<<' === $key) {
|
||||
$output += $value;
|
||||
} elseif ($allowOverwrite || !isset($output[$key])) {
|
||||
if (!$isValueQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
|
||||
$references[$matches['ref']] = $matches['value'];
|
||||
$value = $matches['value'];
|
||||
}
|
||||
|
||||
if (null !== $tag) {
|
||||
$output[$key] = new TaggedValue($tag, $value);
|
||||
} else {
|
||||
@@ -526,7 +552,7 @@ class Inline
|
||||
}
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $mapping), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', $mapping), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -536,8 +562,9 @@ class Inline
|
||||
*
|
||||
* @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved
|
||||
*/
|
||||
private static function evaluateScalar(string $scalar, int $flags, array $references = array())
|
||||
private static function evaluateScalar(string $scalar, int $flags, array &$references = [], bool &$isQuotedString = null)
|
||||
{
|
||||
$isQuotedString = false;
|
||||
$scalar = trim($scalar);
|
||||
$scalarLower = strtolower($scalar);
|
||||
|
||||
@@ -553,7 +580,7 @@ class Inline
|
||||
throw new ParseException('A reference must contain at least one character.', self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
if (!array_key_exists($value, $references)) {
|
||||
if (!\array_key_exists($value, $references)) {
|
||||
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
@@ -564,7 +591,7 @@ class Inline
|
||||
case 'null' === $scalarLower:
|
||||
case '' === $scalar:
|
||||
case '~' === $scalar:
|
||||
return;
|
||||
return null;
|
||||
case 'true' === $scalarLower:
|
||||
return true;
|
||||
case 'false' === $scalarLower:
|
||||
@@ -572,11 +599,22 @@ class Inline
|
||||
case '!' === $scalar[0]:
|
||||
switch (true) {
|
||||
case 0 === strpos($scalar, '!!str '):
|
||||
return (string) substr($scalar, 6);
|
||||
$s = (string) substr($scalar, 6);
|
||||
|
||||
if (\in_array($s[0] ?? '', ['"', "'"], true)) {
|
||||
$isQuotedString = true;
|
||||
$s = self::parseQuotedScalar($s);
|
||||
}
|
||||
|
||||
return $s;
|
||||
case 0 === strpos($scalar, '! '):
|
||||
return substr($scalar, 2);
|
||||
case 0 === strpos($scalar, '!php/object'):
|
||||
if (self::$objectSupport) {
|
||||
if (!isset($scalar[12])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return unserialize(self::parseScalar(substr($scalar, 12)));
|
||||
}
|
||||
|
||||
@@ -584,9 +622,13 @@ class Inline
|
||||
throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
return;
|
||||
return null;
|
||||
case 0 === strpos($scalar, '!php/const'):
|
||||
if (self::$constantSupport) {
|
||||
if (!isset($scalar[11])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
if (\defined($const = self::parseScalar(substr($scalar, 11), 0, null, $i, false))) {
|
||||
return \constant($const);
|
||||
@@ -595,10 +637,10 @@ class Inline
|
||||
throw new ParseException(sprintf('The constant "%s" is not defined.', $const), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
if (self::$exceptionOnInvalidType) {
|
||||
throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Did you forget to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
return;
|
||||
return null;
|
||||
case 0 === strpos($scalar, '!!float '):
|
||||
return (float) substr($scalar, 8);
|
||||
case 0 === strpos($scalar, '!!binary '):
|
||||
@@ -610,21 +652,27 @@ class Inline
|
||||
// Optimize for returning strings.
|
||||
// no break
|
||||
case '+' === $scalar[0] || '-' === $scalar[0] || '.' === $scalar[0] || is_numeric($scalar[0]):
|
||||
if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar)) {
|
||||
$scalar = str_replace('_', '', $scalar);
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar):
|
||||
$scalar = str_replace('_', '', (string) $scalar);
|
||||
// omitting the break / return as integers are handled in the next case
|
||||
// no break
|
||||
case ctype_digit($scalar):
|
||||
$raw = $scalar;
|
||||
if (preg_match('/^0[0-7]+$/', $scalar)) {
|
||||
return octdec($scalar);
|
||||
}
|
||||
|
||||
$cast = (int) $scalar;
|
||||
|
||||
return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
|
||||
return ($scalar === (string) $cast) ? $cast : $scalar;
|
||||
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
|
||||
$raw = $scalar;
|
||||
if (preg_match('/^-0[0-7]+$/', $scalar)) {
|
||||
return -octdec(substr($scalar, 1));
|
||||
}
|
||||
|
||||
$cast = (int) $scalar;
|
||||
|
||||
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw === (string) $cast) ? $cast : $raw);
|
||||
return ($scalar === (string) $cast) ? $cast : $scalar;
|
||||
case is_numeric($scalar):
|
||||
case Parser::preg_match(self::getHexRegex(), $scalar):
|
||||
$scalar = str_replace('_', '', $scalar);
|
||||
@@ -638,17 +686,22 @@ class Inline
|
||||
case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar):
|
||||
return (float) str_replace('_', '', $scalar);
|
||||
case Parser::preg_match(self::getTimestampRegex(), $scalar):
|
||||
// When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
|
||||
$time = new \DateTime($scalar, new \DateTimeZone('UTC'));
|
||||
|
||||
if (Yaml::PARSE_DATETIME & $flags) {
|
||||
// When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
|
||||
return new \DateTime($scalar, new \DateTimeZone('UTC'));
|
||||
return $time;
|
||||
}
|
||||
|
||||
$timeZone = date_default_timezone_get();
|
||||
date_default_timezone_set('UTC');
|
||||
$time = strtotime($scalar);
|
||||
date_default_timezone_set($timeZone);
|
||||
try {
|
||||
if (false !== $scalar = $time->getTimestamp()) {
|
||||
return $scalar;
|
||||
}
|
||||
} catch (\ValueError $e) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
return $time;
|
||||
return $time->format('U');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,8 +720,12 @@ class Inline
|
||||
$nextOffset = $i + $tagLength + 1;
|
||||
$nextOffset += strspn($value, ' ', $nextOffset);
|
||||
|
||||
if ('' === $tag && (!isset($value[$nextOffset]) || \in_array($value[$nextOffset], [']', '}', ','], true))) {
|
||||
throw new ParseException('Using the unquoted scalar value "!" is not supported. You must quote it.', self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
// Is followed by a scalar and is a built-in tag
|
||||
if ($tag && (!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], array('[', '{'), true)) && ('!' === $tag[0] || 'str' === $tag || 'php/const' === $tag || 'php/object' === $tag)) {
|
||||
if ('' !== $tag && (!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], ['[', '{'], true)) && ('!' === $tag[0] || 'str' === $tag || 'php/const' === $tag || 'php/object' === $tag)) {
|
||||
// Manage in {@link self::evaluateScalar()}
|
||||
return null;
|
||||
}
|
||||
@@ -676,10 +733,14 @@ class Inline
|
||||
$i = $nextOffset;
|
||||
|
||||
// Built-in tags
|
||||
if ($tag && '!' === $tag[0]) {
|
||||
if ('' !== $tag && '!' === $tag[0]) {
|
||||
throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
if ('' !== $tag && !isset($value[$i])) {
|
||||
throw new ParseException(sprintf('Missing value for tag "%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
if ('' === $tag || Yaml::PARSE_CUSTOM_TAGS & $flags) {
|
||||
return $tag;
|
||||
}
|
||||
@@ -734,8 +795,6 @@ EOF;
|
||||
|
||||
/**
|
||||
* Gets a regex that matches a YAML number in hexadecimal notation.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function getHexRegex(): string
|
||||
{
|
||||
|
2
vendor/symfony/yaml/LICENSE
vendored
2
vendor/symfony/yaml/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2018 Fabien Potencier
|
||||
Copyright (c) 2004-2022 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
454
vendor/symfony/yaml/Parser.php
vendored
454
vendor/symfony/yaml/Parser.php
vendored
@@ -23,18 +23,20 @@ use Symfony\Component\Yaml\Tag\TaggedValue;
|
||||
*/
|
||||
class Parser
|
||||
{
|
||||
const TAG_PATTERN = '(?P<tag>![\w!.\/:-]+)';
|
||||
const BLOCK_SCALAR_HEADER_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?';
|
||||
public const TAG_PATTERN = '(?P<tag>![\w!.\/:-]+)';
|
||||
public const BLOCK_SCALAR_HEADER_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?';
|
||||
public const REFERENCE_PATTERN = '#^&(?P<ref>[^ ]++) *+(?P<value>.*)#u';
|
||||
|
||||
private $filename;
|
||||
private $offset = 0;
|
||||
private $totalNumberOfLines;
|
||||
private $lines = array();
|
||||
private $lines = [];
|
||||
private $currentLineNb = -1;
|
||||
private $currentLine = '';
|
||||
private $refs = array();
|
||||
private $skippedLineNumbers = array();
|
||||
private $locallySkippedLineNumbers = array();
|
||||
private $refs = [];
|
||||
private $skippedLineNumbers = [];
|
||||
private $locallySkippedLineNumbers = [];
|
||||
private $refsBeingParsed = [];
|
||||
|
||||
/**
|
||||
* Parses a YAML file into a PHP value.
|
||||
@@ -81,12 +83,11 @@ class Parser
|
||||
throw new ParseException('The YAML value does not appear to be valid UTF-8.', -1, null, $this->filename);
|
||||
}
|
||||
|
||||
$this->refs = array();
|
||||
$this->refs = [];
|
||||
|
||||
$mbEncoding = null;
|
||||
$data = null;
|
||||
|
||||
if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
|
||||
if (2 /* MB_OVERLOAD_STRING */ & (int) \ini_get('mbstring.func_overload')) {
|
||||
$mbEncoding = mb_internal_encoding();
|
||||
mb_internal_encoding('UTF-8');
|
||||
}
|
||||
@@ -97,33 +98,26 @@ class Parser
|
||||
if (null !== $mbEncoding) {
|
||||
mb_internal_encoding($mbEncoding);
|
||||
}
|
||||
$this->lines = array();
|
||||
$this->refsBeingParsed = [];
|
||||
$this->offset = 0;
|
||||
$this->lines = [];
|
||||
$this->currentLine = '';
|
||||
$this->refs = array();
|
||||
$this->skippedLineNumbers = array();
|
||||
$this->locallySkippedLineNumbers = array();
|
||||
$this->refs = [];
|
||||
$this->skippedLineNumbers = [];
|
||||
$this->locallySkippedLineNumbers = [];
|
||||
$this->totalNumberOfLines = null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLastLineNumberBeforeDeprecation(): int
|
||||
{
|
||||
return $this->getRealCurrentLineNb();
|
||||
}
|
||||
|
||||
private function doParse(string $value, int $flags)
|
||||
{
|
||||
$this->currentLineNb = -1;
|
||||
$this->currentLine = '';
|
||||
$value = $this->cleanup($value);
|
||||
$this->lines = explode("\n", $value);
|
||||
$this->locallySkippedLineNumbers = array();
|
||||
$this->locallySkippedLineNumbers = [];
|
||||
|
||||
if (null === $this->totalNumberOfLines) {
|
||||
$this->totalNumberOfLines = \count($this->lines);
|
||||
@@ -133,7 +127,7 @@ class Parser
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data = [];
|
||||
$context = null;
|
||||
$allowOverwrite = false;
|
||||
|
||||
@@ -163,12 +157,13 @@ class Parser
|
||||
$isRef = $mergeNode = false;
|
||||
if ('-' === $this->currentLine[0] && self::preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+))?$#u', rtrim($this->currentLine), $values)) {
|
||||
if ($context && 'mapping' == $context) {
|
||||
throw new ParseException('You cannot define a sequence item when in a mapping', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
throw new ParseException('You cannot define a sequence item when in a mapping.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
$context = 'sequence';
|
||||
|
||||
if (isset($values['value']) && '&' === $values['value'][0] && self::preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {
|
||||
if (isset($values['value']) && '&' === $values['value'][0] && self::preg_match(self::REFERENCE_PATTERN, $values['value'], $matches)) {
|
||||
$isRef = $matches['ref'];
|
||||
$this->refsBeingParsed[] = $isRef;
|
||||
$values['value'] = $matches['value'];
|
||||
}
|
||||
|
||||
@@ -177,7 +172,16 @@ class Parser
|
||||
}
|
||||
|
||||
// array
|
||||
if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
|
||||
if (isset($values['value']) && 0 === strpos(ltrim($values['value'], ' '), '-')) {
|
||||
// Inline first child
|
||||
$currentLineNumber = $this->getRealCurrentLineNb();
|
||||
|
||||
$sequenceIndentation = \strlen($values['leadspaces']) + 1;
|
||||
$sequenceYaml = substr($this->currentLine, $sequenceIndentation);
|
||||
$sequenceYaml .= "\n".$this->getNextEmbedBlock($sequenceIndentation, true);
|
||||
|
||||
$data[] = $this->parseBlock($currentLineNumber, rtrim($sequenceYaml), $flags);
|
||||
} elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
|
||||
$data[] = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(null, true) ?? '', $flags);
|
||||
} elseif (null !== $subTag = $this->getLineTag(ltrim($values['value'], ' '), $flags)) {
|
||||
$data[] = new TaggedValue(
|
||||
@@ -185,8 +189,12 @@ class Parser
|
||||
$this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(null, true), $flags)
|
||||
);
|
||||
} else {
|
||||
if (isset($values['leadspaces'])
|
||||
&& self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->trimTag($values['value']), $matches)
|
||||
if (
|
||||
isset($values['leadspaces'])
|
||||
&& (
|
||||
'!' === $values['value'][0]
|
||||
|| self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->trimTag($values['value']), $matches)
|
||||
)
|
||||
) {
|
||||
// this is a compact notation element, add to next block and parse
|
||||
$block = $values['value'];
|
||||
@@ -201,13 +209,14 @@ class Parser
|
||||
}
|
||||
if ($isRef) {
|
||||
$this->refs[$isRef] = end($data);
|
||||
array_pop($this->refsBeingParsed);
|
||||
}
|
||||
} elseif (
|
||||
self::preg_match('#^(?P<key>(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(\s++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
|
||||
&& (false === strpos($values['key'], ' #') || \in_array($values['key'][0], array('"', "'")))
|
||||
self::preg_match('#^(?P<key>(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(( |\t)++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
|
||||
&& (false === strpos($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"]))
|
||||
) {
|
||||
if ($context && 'sequence' == $context) {
|
||||
throw new ParseException('You cannot define a mapping item when in a sequence', $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
throw new ParseException('You cannot define a mapping item when in a sequence.', $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
$context = 'mapping';
|
||||
|
||||
@@ -221,7 +230,7 @@ class Parser
|
||||
}
|
||||
|
||||
if (!\is_string($key) && !\is_int($key)) {
|
||||
throw new ParseException(sprintf('%s keys are not supported. Quote your evaluable mapping keys instead.', is_numeric($key) ? 'Numeric' : 'Non-string'), $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
throw new ParseException((is_numeric($key) ? 'Numeric' : 'Non-string').' keys are not supported. Quote your evaluable mapping keys instead.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
}
|
||||
|
||||
// Convert float keys to strings, to avoid being converted to integers by PHP
|
||||
@@ -234,7 +243,11 @@ class Parser
|
||||
$allowOverwrite = true;
|
||||
if (isset($values['value'][0]) && '*' === $values['value'][0]) {
|
||||
$refName = substr(rtrim($values['value']), 1);
|
||||
if (!array_key_exists($refName, $this->refs)) {
|
||||
if (!\array_key_exists($refName, $this->refs)) {
|
||||
if (false !== $pos = array_search($refName, $this->refsBeingParsed, true)) {
|
||||
throw new ParseException(sprintf('Circular reference [%s] detected for reference "%s".', implode(', ', array_merge(\array_slice($this->refsBeingParsed, $pos), [$refName])), $refName), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('Reference "%s" does not exist.', $refName), $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
@@ -286,8 +299,9 @@ class Parser
|
||||
$data += $parsed; // array union
|
||||
}
|
||||
}
|
||||
} elseif ('<<' !== $key && isset($values['value']) && '&' === $values['value'][0] && self::preg_match('#^&(?P<ref>[^ ]++) *+(?P<value>.*)#u', $values['value'], $matches)) {
|
||||
} elseif ('<<' !== $key && isset($values['value']) && '&' === $values['value'][0] && self::preg_match(self::REFERENCE_PATTERN, $values['value'], $matches)) {
|
||||
$isRef = $matches['ref'];
|
||||
$this->refsBeingParsed[] = $isRef;
|
||||
$values['value'] = $matches['value'];
|
||||
}
|
||||
|
||||
@@ -345,6 +359,62 @@ class Parser
|
||||
}
|
||||
if ($isRef) {
|
||||
$this->refs[$isRef] = $data[$key];
|
||||
array_pop($this->refsBeingParsed);
|
||||
}
|
||||
} elseif ('"' === $this->currentLine[0] || "'" === $this->currentLine[0]) {
|
||||
if (null !== $context) {
|
||||
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
try {
|
||||
return Inline::parse($this->lexInlineQuotedString(), $flags, $this->refs);
|
||||
} catch (ParseException $e) {
|
||||
$e->setParsedLine($this->getRealCurrentLineNb() + 1);
|
||||
$e->setSnippet($this->currentLine);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
} elseif ('{' === $this->currentLine[0]) {
|
||||
if (null !== $context) {
|
||||
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
try {
|
||||
$parsedMapping = Inline::parse($this->lexInlineMapping(), $flags, $this->refs);
|
||||
|
||||
while ($this->moveToNextLine()) {
|
||||
if (!$this->isCurrentLineEmpty()) {
|
||||
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
}
|
||||
|
||||
return $parsedMapping;
|
||||
} catch (ParseException $e) {
|
||||
$e->setParsedLine($this->getRealCurrentLineNb() + 1);
|
||||
$e->setSnippet($this->currentLine);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
} elseif ('[' === $this->currentLine[0]) {
|
||||
if (null !== $context) {
|
||||
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
try {
|
||||
$parsedSequence = Inline::parse($this->lexInlineSequence(), $flags, $this->refs);
|
||||
|
||||
while ($this->moveToNextLine()) {
|
||||
if (!$this->isCurrentLineEmpty()) {
|
||||
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
}
|
||||
|
||||
return $parsedSequence;
|
||||
} catch (ParseException $e) {
|
||||
$e->setParsedLine($this->getRealCurrentLineNb() + 1);
|
||||
$e->setSnippet($this->currentLine);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
} else {
|
||||
// multiple documents are not supported
|
||||
@@ -377,10 +447,18 @@ class Parser
|
||||
$value = '';
|
||||
|
||||
foreach ($this->lines as $line) {
|
||||
if ('' !== ltrim($line) && '#' === ltrim($line)[0]) {
|
||||
continue;
|
||||
}
|
||||
// If the indentation is not consistent at offset 0, it is to be considered as a ParseError
|
||||
if (0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0]) {
|
||||
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
if (false !== strpos($line, ': ')) {
|
||||
@trigger_error('Support for mapping keys in multi-line blocks is deprecated since Symfony 4.3 and will throw a ParseException in 5.0.', \E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if ('' === trim($line)) {
|
||||
$value .= "\n";
|
||||
} elseif (!$previousLineWasNewline && !$previousLineWasTerminatedWithBackslash) {
|
||||
@@ -450,6 +528,7 @@ class Parser
|
||||
$parser->totalNumberOfLines = $this->totalNumberOfLines;
|
||||
$parser->skippedLineNumbers = $skippedLineNumbers;
|
||||
$parser->refs = &$this->refs;
|
||||
$parser->refsBeingParsed = $this->refsBeingParsed;
|
||||
|
||||
return $parser->doParse($yaml, $flags);
|
||||
}
|
||||
@@ -496,12 +575,12 @@ class Parser
|
||||
*
|
||||
* @throws ParseException When indentation problem are detected
|
||||
*/
|
||||
private function getNextEmbedBlock(int $indentation = null, bool $inSequence = false): ?string
|
||||
private function getNextEmbedBlock(int $indentation = null, bool $inSequence = false): string
|
||||
{
|
||||
$oldLineIndentation = $this->getCurrentLineIndentation();
|
||||
|
||||
if (!$this->moveToNextLine()) {
|
||||
return null;
|
||||
return '';
|
||||
}
|
||||
|
||||
if (null === $indentation) {
|
||||
@@ -536,15 +615,16 @@ class Parser
|
||||
$newIndent = $indentation;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data = [];
|
||||
|
||||
if ($this->getCurrentLineIndentation() >= $newIndent) {
|
||||
$data[] = substr($this->currentLine, $newIndent);
|
||||
$data[] = substr($this->currentLine, $newIndent ?? 0);
|
||||
} elseif ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) {
|
||||
$data[] = $this->currentLine;
|
||||
} else {
|
||||
$this->moveToPreviousLine();
|
||||
|
||||
return null;
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($inSequence && $oldLineIndentation === $newIndent && isset($data[0][0]) && '-' === $data[0][0]) {
|
||||
@@ -552,12 +632,18 @@ class Parser
|
||||
// and therefore no nested list or mapping
|
||||
$this->moveToPreviousLine();
|
||||
|
||||
return null;
|
||||
return '';
|
||||
}
|
||||
|
||||
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem();
|
||||
$isItComment = $this->isCurrentLineComment();
|
||||
|
||||
while ($this->moveToNextLine()) {
|
||||
if ($isItComment && !$isItUnindentedCollection) {
|
||||
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem();
|
||||
$isItComment = $this->isCurrentLineComment();
|
||||
}
|
||||
|
||||
$indent = $this->getCurrentLineIndentation();
|
||||
|
||||
if ($isItUnindentedCollection && !$this->isCurrentLineEmpty() && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) {
|
||||
@@ -586,10 +672,13 @@ class Parser
|
||||
return implode("\n", $data);
|
||||
}
|
||||
|
||||
private function hasMoreLines(): bool
|
||||
{
|
||||
return (\count($this->lines) - 1) > $this->currentLineNb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the parser to the next line.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function moveToNextLine(): bool
|
||||
{
|
||||
@@ -604,8 +693,6 @@ class Parser
|
||||
|
||||
/**
|
||||
* Moves the parser to the previous line.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function moveToPreviousLine(): bool
|
||||
{
|
||||
@@ -638,17 +725,21 @@ class Parser
|
||||
$value = substr($value, 1);
|
||||
}
|
||||
|
||||
if (!array_key_exists($value, $this->refs)) {
|
||||
if (!\array_key_exists($value, $this->refs)) {
|
||||
if (false !== $pos = array_search($value, $this->refsBeingParsed, true)) {
|
||||
throw new ParseException(sprintf('Circular reference [%s] detected for reference "%s".', implode(', ', array_merge(\array_slice($this->refsBeingParsed, $pos), [$value])), $value), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
return $this->refs[$value];
|
||||
}
|
||||
|
||||
if (\in_array($value[0], array('!', '|', '>'), true) && self::preg_match('/^(?:'.self::TAG_PATTERN.' +)?'.self::BLOCK_SCALAR_HEADER_PATTERN.'$/', $value, $matches)) {
|
||||
$modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
|
||||
if (\in_array($value[0], ['!', '|', '>'], true) && self::preg_match('/^(?:'.self::TAG_PATTERN.' +)?'.self::BLOCK_SCALAR_HEADER_PATTERN.'$/', $value, $matches)) {
|
||||
$modifiers = $matches['modifiers'] ?? '';
|
||||
|
||||
$data = $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs($modifiers));
|
||||
$data = $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), abs((int) $modifiers));
|
||||
|
||||
if ('' !== $matches['tag'] && '!' !== $matches['tag']) {
|
||||
if ('!!binary' === $matches['tag']) {
|
||||
@@ -662,53 +753,64 @@ class Parser
|
||||
}
|
||||
|
||||
try {
|
||||
$quotation = '' !== $value && ('"' === $value[0] || "'" === $value[0]) ? $value[0] : null;
|
||||
if ('' !== $value && '{' === $value[0]) {
|
||||
$cursor = \strlen(rtrim($this->currentLine)) - \strlen(rtrim($value));
|
||||
|
||||
// do not take following lines into account when the current line is a quoted single line value
|
||||
if (null !== $quotation && self::preg_match('/^'.$quotation.'.*'.$quotation.'(\s*#.*)?$/', $value)) {
|
||||
return Inline::parse($value, $flags, $this->refs);
|
||||
return Inline::parse($this->lexInlineMapping($cursor), $flags, $this->refs);
|
||||
} elseif ('' !== $value && '[' === $value[0]) {
|
||||
$cursor = \strlen(rtrim($this->currentLine)) - \strlen(rtrim($value));
|
||||
|
||||
return Inline::parse($this->lexInlineSequence($cursor), $flags, $this->refs);
|
||||
}
|
||||
|
||||
$lines = array();
|
||||
switch ($value[0] ?? '') {
|
||||
case '"':
|
||||
case "'":
|
||||
$cursor = \strlen(rtrim($this->currentLine)) - \strlen(rtrim($value));
|
||||
$parsedValue = Inline::parse($this->lexInlineQuotedString($cursor), $flags, $this->refs);
|
||||
|
||||
while ($this->moveToNextLine()) {
|
||||
// unquoted strings end before the first unindented line
|
||||
if (null === $quotation && 0 === $this->getCurrentLineIndentation()) {
|
||||
$this->moveToPreviousLine();
|
||||
if (isset($this->currentLine[$cursor]) && preg_replace('/\s*(#.*)?$/A', '', substr($this->currentLine, $cursor))) {
|
||||
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($this->currentLine, $cursor)));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return $parsedValue;
|
||||
default:
|
||||
$lines = [];
|
||||
|
||||
$lines[] = trim($this->currentLine);
|
||||
while ($this->moveToNextLine()) {
|
||||
// unquoted strings end before the first unindented line
|
||||
if (0 === $this->getCurrentLineIndentation()) {
|
||||
$this->moveToPreviousLine();
|
||||
|
||||
// quoted string values end with a line that is terminated with the quotation character
|
||||
if ('' !== $this->currentLine && substr($this->currentLine, -1) === $quotation) {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$lines[] = trim($this->currentLine);
|
||||
}
|
||||
|
||||
for ($i = 0, $linesCount = \count($lines), $previousLineBlank = false; $i < $linesCount; ++$i) {
|
||||
if ('' === $lines[$i]) {
|
||||
$value .= "\n";
|
||||
$previousLineBlank = true;
|
||||
} elseif ($previousLineBlank) {
|
||||
$value .= $lines[$i];
|
||||
$previousLineBlank = false;
|
||||
} else {
|
||||
$value .= ' '.$lines[$i];
|
||||
$previousLineBlank = false;
|
||||
}
|
||||
}
|
||||
|
||||
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.', $this->getRealCurrentLineNb() + 1, $value, $this->filename);
|
||||
}
|
||||
|
||||
return $parsedValue;
|
||||
}
|
||||
|
||||
for ($i = 0, $linesCount = \count($lines), $previousLineBlank = false; $i < $linesCount; ++$i) {
|
||||
if ('' === $lines[$i]) {
|
||||
$value .= "\n";
|
||||
$previousLineBlank = true;
|
||||
} elseif ($previousLineBlank) {
|
||||
$value .= $lines[$i];
|
||||
$previousLineBlank = false;
|
||||
} else {
|
||||
$value .= ' '.$lines[$i];
|
||||
$previousLineBlank = false;
|
||||
}
|
||||
}
|
||||
|
||||
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.', $this->getRealCurrentLineNb() + 1, $value, $this->filename);
|
||||
}
|
||||
|
||||
return $parsedValue;
|
||||
} catch (ParseException $e) {
|
||||
$e->setParsedLine($this->getRealCurrentLineNb() + 1);
|
||||
$e->setSnippet($this->currentLine);
|
||||
@@ -723,8 +825,6 @@ class Parser
|
||||
* @param string $style The style indicator that was used to begin this block scalar (| or >)
|
||||
* @param string $chomping The chomping indicator that was used to begin this block scalar (+ or -)
|
||||
* @param int $indentation The indentation indicator that was used to begin this block scalar
|
||||
*
|
||||
* @return string The text value
|
||||
*/
|
||||
private function parseBlockScalar(string $style, string $chomping = '', int $indentation = 0): string
|
||||
{
|
||||
@@ -734,7 +834,7 @@ class Parser
|
||||
}
|
||||
|
||||
$isCurrentLineBlank = $this->isCurrentLineBlank();
|
||||
$blockLines = array();
|
||||
$blockLines = [];
|
||||
|
||||
// leading blank lines are consumed before determining indentation
|
||||
while ($notEOF && $isCurrentLineBlank) {
|
||||
@@ -888,7 +988,7 @@ class Parser
|
||||
*/
|
||||
private function isCurrentLineComment(): bool
|
||||
{
|
||||
//checking explicitly the first char of the trim is faster than loops or strpos
|
||||
// checking explicitly the first char of the trim is faster than loops or strpos
|
||||
$ltrimmedLine = ltrim($this->currentLine, ' ');
|
||||
|
||||
return '' !== $ltrimmedLine && '#' === $ltrimmedLine[0];
|
||||
@@ -908,7 +1008,7 @@ class Parser
|
||||
*/
|
||||
private function cleanup(string $value): string
|
||||
{
|
||||
$value = str_replace(array("\r\n", "\r"), "\n", $value);
|
||||
$value = str_replace(["\r\n", "\r"], "\n", $value);
|
||||
|
||||
// strip YAML header
|
||||
$count = 0;
|
||||
@@ -995,19 +1095,19 @@ class Parser
|
||||
{
|
||||
if (false === $ret = preg_match($pattern, $subject, $matches, $flags, $offset)) {
|
||||
switch (preg_last_error()) {
|
||||
case PREG_INTERNAL_ERROR:
|
||||
case \PREG_INTERNAL_ERROR:
|
||||
$error = 'Internal PCRE error.';
|
||||
break;
|
||||
case PREG_BACKTRACK_LIMIT_ERROR:
|
||||
case \PREG_BACKTRACK_LIMIT_ERROR:
|
||||
$error = 'pcre.backtrack_limit reached.';
|
||||
break;
|
||||
case PREG_RECURSION_LIMIT_ERROR:
|
||||
case \PREG_RECURSION_LIMIT_ERROR:
|
||||
$error = 'pcre.recursion_limit reached.';
|
||||
break;
|
||||
case PREG_BAD_UTF8_ERROR:
|
||||
case \PREG_BAD_UTF8_ERROR:
|
||||
$error = 'Malformed UTF-8 data.';
|
||||
break;
|
||||
case PREG_BAD_UTF8_OFFSET_ERROR:
|
||||
case \PREG_BAD_UTF8_OFFSET_ERROR:
|
||||
$error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.';
|
||||
break;
|
||||
default:
|
||||
@@ -1058,4 +1158,160 @@ class Parser
|
||||
|
||||
throw new ParseException(sprintf('Tags support is not enabled. You must use the flag "Yaml::PARSE_CUSTOM_TAGS" to use "%s".', $matches['tag']), $this->getRealCurrentLineNb() + 1, $value, $this->filename);
|
||||
}
|
||||
|
||||
private function lexInlineQuotedString(int &$cursor = 0): string
|
||||
{
|
||||
$quotation = $this->currentLine[$cursor];
|
||||
$value = $quotation;
|
||||
++$cursor;
|
||||
|
||||
$previousLineWasNewline = true;
|
||||
$previousLineWasTerminatedWithBackslash = false;
|
||||
$lineNumber = 0;
|
||||
|
||||
do {
|
||||
if (++$lineNumber > 1) {
|
||||
$cursor += strspn($this->currentLine, ' ', $cursor);
|
||||
}
|
||||
|
||||
if ($this->isCurrentLineBlank()) {
|
||||
$value .= "\n";
|
||||
} elseif (!$previousLineWasNewline && !$previousLineWasTerminatedWithBackslash) {
|
||||
$value .= ' ';
|
||||
}
|
||||
|
||||
for (; \strlen($this->currentLine) > $cursor; ++$cursor) {
|
||||
switch ($this->currentLine[$cursor]) {
|
||||
case '\\':
|
||||
if ("'" === $quotation) {
|
||||
$value .= '\\';
|
||||
} elseif (isset($this->currentLine[++$cursor])) {
|
||||
$value .= '\\'.$this->currentLine[$cursor];
|
||||
}
|
||||
|
||||
break;
|
||||
case $quotation:
|
||||
++$cursor;
|
||||
|
||||
if ("'" === $quotation && isset($this->currentLine[$cursor]) && "'" === $this->currentLine[$cursor]) {
|
||||
$value .= "''";
|
||||
break;
|
||||
}
|
||||
|
||||
return $value.$quotation;
|
||||
default:
|
||||
$value .= $this->currentLine[$cursor];
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->isCurrentLineBlank()) {
|
||||
$previousLineWasNewline = true;
|
||||
$previousLineWasTerminatedWithBackslash = false;
|
||||
} elseif ('\\' === $this->currentLine[-1]) {
|
||||
$previousLineWasNewline = false;
|
||||
$previousLineWasTerminatedWithBackslash = true;
|
||||
} else {
|
||||
$previousLineWasNewline = false;
|
||||
$previousLineWasTerminatedWithBackslash = false;
|
||||
}
|
||||
|
||||
if ($this->hasMoreLines()) {
|
||||
$cursor = 0;
|
||||
}
|
||||
} while ($this->moveToNextLine());
|
||||
|
||||
throw new ParseException('Malformed inline YAML string.');
|
||||
}
|
||||
|
||||
private function lexUnquotedString(int &$cursor): string
|
||||
{
|
||||
$offset = $cursor;
|
||||
$cursor += strcspn($this->currentLine, '[]{},: ', $cursor);
|
||||
|
||||
if ($cursor === $offset) {
|
||||
throw new ParseException('Malformed unquoted YAML string.');
|
||||
}
|
||||
|
||||
return substr($this->currentLine, $offset, $cursor - $offset);
|
||||
}
|
||||
|
||||
private function lexInlineMapping(int &$cursor = 0): string
|
||||
{
|
||||
return $this->lexInlineStructure($cursor, '}');
|
||||
}
|
||||
|
||||
private function lexInlineSequence(int &$cursor = 0): string
|
||||
{
|
||||
return $this->lexInlineStructure($cursor, ']');
|
||||
}
|
||||
|
||||
private function lexInlineStructure(int &$cursor, string $closingTag): string
|
||||
{
|
||||
$value = $this->currentLine[$cursor];
|
||||
++$cursor;
|
||||
|
||||
do {
|
||||
$this->consumeWhitespaces($cursor);
|
||||
|
||||
while (isset($this->currentLine[$cursor])) {
|
||||
switch ($this->currentLine[$cursor]) {
|
||||
case '"':
|
||||
case "'":
|
||||
$value .= $this->lexInlineQuotedString($cursor);
|
||||
break;
|
||||
case ':':
|
||||
case ',':
|
||||
$value .= $this->currentLine[$cursor];
|
||||
++$cursor;
|
||||
break;
|
||||
case '{':
|
||||
$value .= $this->lexInlineMapping($cursor);
|
||||
break;
|
||||
case '[':
|
||||
$value .= $this->lexInlineSequence($cursor);
|
||||
break;
|
||||
case $closingTag:
|
||||
$value .= $this->currentLine[$cursor];
|
||||
++$cursor;
|
||||
|
||||
return $value;
|
||||
case '#':
|
||||
break 2;
|
||||
default:
|
||||
$value .= $this->lexUnquotedString($cursor);
|
||||
}
|
||||
|
||||
if ($this->consumeWhitespaces($cursor)) {
|
||||
$value .= ' ';
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->hasMoreLines()) {
|
||||
$cursor = 0;
|
||||
}
|
||||
} while ($this->moveToNextLine());
|
||||
|
||||
throw new ParseException('Malformed inline YAML string.');
|
||||
}
|
||||
|
||||
private function consumeWhitespaces(int &$cursor): bool
|
||||
{
|
||||
$whitespacesConsumed = 0;
|
||||
|
||||
do {
|
||||
$whitespaceOnlyTokenLength = strspn($this->currentLine, ' ', $cursor);
|
||||
$whitespacesConsumed += $whitespaceOnlyTokenLength;
|
||||
$cursor += $whitespaceOnlyTokenLength;
|
||||
|
||||
if (isset($this->currentLine[$cursor])) {
|
||||
return 0 < $whitespacesConsumed;
|
||||
}
|
||||
|
||||
if ($this->hasMoreLines()) {
|
||||
$cursor = 0;
|
||||
}
|
||||
} while ($this->moveToNextLine());
|
||||
|
||||
return 0 < $whitespacesConsumed;
|
||||
}
|
||||
}
|
||||
|
10
vendor/symfony/yaml/README.md
vendored
10
vendor/symfony/yaml/README.md
vendored
@@ -6,8 +6,8 @@ The Yaml component loads and dumps YAML files.
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Documentation](https://symfony.com/doc/current/components/yaml/index.html)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
* [Documentation](https://symfony.com/doc/current/components/yaml.html)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
|
@@ -1,151 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Yaml\Tests\Command;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Component\Yaml\Command\LintCommand;
|
||||
|
||||
/**
|
||||
* Tests the YamlLintCommand.
|
||||
*
|
||||
* @author Robin Chalas <robin.chalas@gmail.com>
|
||||
*/
|
||||
class LintCommandTest extends TestCase
|
||||
{
|
||||
private $files;
|
||||
|
||||
public function testLintCorrectFile()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$filename = $this->createFile('foo: bar');
|
||||
|
||||
$ret = $tester->execute(array('filename' => $filename), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
|
||||
|
||||
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
|
||||
$this->assertRegExp('/^\/\/ OK in /', trim($tester->getDisplay()));
|
||||
}
|
||||
|
||||
public function testLintCorrectFiles()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$filename1 = $this->createFile('foo: bar');
|
||||
$filename2 = $this->createFile('bar: baz');
|
||||
|
||||
$ret = $tester->execute(array('filename' => array($filename1, $filename2)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
|
||||
|
||||
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
|
||||
$this->assertRegExp('/^\/\/ OK in /', trim($tester->getDisplay()));
|
||||
}
|
||||
|
||||
public function testLintIncorrectFile()
|
||||
{
|
||||
$incorrectContent = '
|
||||
foo:
|
||||
bar';
|
||||
$tester = $this->createCommandTester();
|
||||
$filename = $this->createFile($incorrectContent);
|
||||
|
||||
$ret = $tester->execute(array('filename' => $filename), array('decorated' => false));
|
||||
|
||||
$this->assertEquals(1, $ret, 'Returns 1 in case of error');
|
||||
$this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay()));
|
||||
}
|
||||
|
||||
public function testConstantAsKey()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
!php/const 'Symfony\Component\Yaml\Tests\Command\Foo::TEST': bar
|
||||
YAML;
|
||||
$ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
|
||||
$this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success');
|
||||
}
|
||||
|
||||
public function testCustomTags()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
foo: !my_tag {foo: bar}
|
||||
YAML;
|
||||
$ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml), '--parse-tags' => true), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
|
||||
$this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success');
|
||||
}
|
||||
|
||||
public function testCustomTagsError()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
foo: !my_tag {foo: bar}
|
||||
YAML;
|
||||
$ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
|
||||
$this->assertSame(1, $ret, 'lint:yaml exits with code 1 in case of error');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testLintFileNotReadable()
|
||||
{
|
||||
$tester = $this->createCommandTester();
|
||||
$filename = $this->createFile('');
|
||||
unlink($filename);
|
||||
|
||||
$ret = $tester->execute(array('filename' => $filename), array('decorated' => false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string Path to the new file
|
||||
*/
|
||||
private function createFile($content)
|
||||
{
|
||||
$filename = tempnam(sys_get_temp_dir().'/framework-yml-lint-test', 'sf-');
|
||||
file_put_contents($filename, $content);
|
||||
|
||||
$this->files[] = $filename;
|
||||
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CommandTester
|
||||
*/
|
||||
protected function createCommandTester()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->add(new LintCommand());
|
||||
$command = $application->find('lint:yaml');
|
||||
|
||||
return new CommandTester($command);
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->files = array();
|
||||
@mkdir(sys_get_temp_dir().'/framework-yml-lint-test');
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
foreach ($this->files as $file) {
|
||||
if (file_exists($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
rmdir(sys_get_temp_dir().'/framework-yml-lint-test');
|
||||
}
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
const TEST = 'foo';
|
||||
}
|
429
vendor/symfony/yaml/Tests/DumperTest.php
vendored
429
vendor/symfony/yaml/Tests/DumperTest.php
vendored
@@ -1,429 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Dumper;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class DumperTest extends TestCase
|
||||
{
|
||||
protected $parser;
|
||||
protected $dumper;
|
||||
protected $path;
|
||||
|
||||
protected $array = array(
|
||||
'' => 'bar',
|
||||
'foo' => '#bar',
|
||||
'foo\'bar' => array(),
|
||||
'bar' => array(1, 'foo'),
|
||||
'foobar' => array(
|
||||
'foo' => 'bar',
|
||||
'bar' => array(1, 'foo'),
|
||||
'foobar' => array(
|
||||
'foo' => 'bar',
|
||||
'bar' => array(1, 'foo'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->parser = new Parser();
|
||||
$this->dumper = new Dumper();
|
||||
$this->path = __DIR__.'/Fixtures';
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->parser = null;
|
||||
$this->dumper = null;
|
||||
$this->path = null;
|
||||
$this->array = null;
|
||||
}
|
||||
|
||||
public function testIndentationInConstructor()
|
||||
{
|
||||
$dumper = new Dumper(7);
|
||||
$expected = <<<'EOF'
|
||||
'': bar
|
||||
foo: '#bar'
|
||||
'foo''bar': { }
|
||||
bar:
|
||||
- 1
|
||||
- foo
|
||||
foobar:
|
||||
foo: bar
|
||||
bar:
|
||||
- 1
|
||||
- foo
|
||||
foobar:
|
||||
foo: bar
|
||||
bar:
|
||||
- 1
|
||||
- foo
|
||||
|
||||
EOF;
|
||||
$this->assertEquals($expected, $dumper->dump($this->array, 4, 0));
|
||||
}
|
||||
|
||||
public function testSpecifications()
|
||||
{
|
||||
$files = $this->parser->parse(file_get_contents($this->path.'/index.yml'));
|
||||
foreach ($files as $file) {
|
||||
$yamls = file_get_contents($this->path.'/'.$file.'.yml');
|
||||
|
||||
// split YAMLs documents
|
||||
foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) {
|
||||
if (!$yaml) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$test = $this->parser->parse($yaml);
|
||||
if (isset($test['dump_skip']) && $test['dump_skip']) {
|
||||
continue;
|
||||
} elseif (isset($test['todo']) && $test['todo']) {
|
||||
// TODO
|
||||
} else {
|
||||
eval('$expected = '.trim($test['php']).';');
|
||||
$this->assertSame($expected, $this->parser->parse($this->dumper->dump($expected, 10)), $test['test']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testInlineLevel()
|
||||
{
|
||||
$expected = <<<'EOF'
|
||||
{ '': bar, foo: '#bar', 'foo''bar': { }, bar: [1, foo], foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } } }
|
||||
EOF;
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument');
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument');
|
||||
|
||||
$expected = <<<'EOF'
|
||||
'': bar
|
||||
foo: '#bar'
|
||||
'foo''bar': { }
|
||||
bar: [1, foo]
|
||||
foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } }
|
||||
|
||||
EOF;
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->array, 1), '->dump() takes an inline level argument');
|
||||
|
||||
$expected = <<<'EOF'
|
||||
'': bar
|
||||
foo: '#bar'
|
||||
'foo''bar': { }
|
||||
bar:
|
||||
- 1
|
||||
- foo
|
||||
foobar:
|
||||
foo: bar
|
||||
bar: [1, foo]
|
||||
foobar: { foo: bar, bar: [1, foo] }
|
||||
|
||||
EOF;
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->array, 2), '->dump() takes an inline level argument');
|
||||
|
||||
$expected = <<<'EOF'
|
||||
'': bar
|
||||
foo: '#bar'
|
||||
'foo''bar': { }
|
||||
bar:
|
||||
- 1
|
||||
- foo
|
||||
foobar:
|
||||
foo: bar
|
||||
bar:
|
||||
- 1
|
||||
- foo
|
||||
foobar:
|
||||
foo: bar
|
||||
bar: [1, foo]
|
||||
|
||||
EOF;
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->array, 3), '->dump() takes an inline level argument');
|
||||
|
||||
$expected = <<<'EOF'
|
||||
'': bar
|
||||
foo: '#bar'
|
||||
'foo''bar': { }
|
||||
bar:
|
||||
- 1
|
||||
- foo
|
||||
foobar:
|
||||
foo: bar
|
||||
bar:
|
||||
- 1
|
||||
- foo
|
||||
foobar:
|
||||
foo: bar
|
||||
bar:
|
||||
- 1
|
||||
- foo
|
||||
|
||||
EOF;
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->array, 4), '->dump() takes an inline level argument');
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->array, 10), '->dump() takes an inline level argument');
|
||||
}
|
||||
|
||||
public function testObjectSupportEnabled()
|
||||
{
|
||||
$dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_OBJECT);
|
||||
|
||||
$this->assertEquals('{ foo: !php/object \'O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}\', bar: 1 }', $dump, '->dump() is able to dump objects');
|
||||
}
|
||||
|
||||
public function testObjectSupportDisabledButNoExceptions()
|
||||
{
|
||||
$dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1));
|
||||
|
||||
$this->assertEquals('{ foo: null, bar: 1 }', $dump, '->dump() does not dump objects when disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\DumpException
|
||||
*/
|
||||
public function testObjectSupportDisabledWithExceptions()
|
||||
{
|
||||
$this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getEscapeSequences
|
||||
*/
|
||||
public function testEscapedEscapeSequencesInQuotedScalar($input, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, $this->dumper->dump($input));
|
||||
}
|
||||
|
||||
public function getEscapeSequences()
|
||||
{
|
||||
return array(
|
||||
'empty string' => array('', "''"),
|
||||
'null' => array("\x0", '"\\0"'),
|
||||
'bell' => array("\x7", '"\\a"'),
|
||||
'backspace' => array("\x8", '"\\b"'),
|
||||
'horizontal-tab' => array("\t", '"\\t"'),
|
||||
'line-feed' => array("\n", '"\\n"'),
|
||||
'vertical-tab' => array("\v", '"\\v"'),
|
||||
'form-feed' => array("\xC", '"\\f"'),
|
||||
'carriage-return' => array("\r", '"\\r"'),
|
||||
'escape' => array("\x1B", '"\\e"'),
|
||||
'space' => array(' ', "' '"),
|
||||
'double-quote' => array('"', "'\"'"),
|
||||
'slash' => array('/', '/'),
|
||||
'backslash' => array('\\', '\\'),
|
||||
'next-line' => array("\xC2\x85", '"\\N"'),
|
||||
'non-breaking-space' => array("\xc2\xa0", '"\\_"'),
|
||||
'line-separator' => array("\xE2\x80\xA8", '"\\L"'),
|
||||
'paragraph-separator' => array("\xE2\x80\xA9", '"\\P"'),
|
||||
'colon' => array(':', "':'"),
|
||||
);
|
||||
}
|
||||
|
||||
public function testBinaryDataIsDumpedBase64Encoded()
|
||||
{
|
||||
$binaryData = file_get_contents(__DIR__.'/Fixtures/arrow.gif');
|
||||
$expected = '{ data: !!binary '.base64_encode($binaryData).' }';
|
||||
|
||||
$this->assertSame($expected, $this->dumper->dump(array('data' => $binaryData)));
|
||||
}
|
||||
|
||||
public function testNonUtf8DataIsDumpedBase64Encoded()
|
||||
{
|
||||
// "für" (ISO-8859-1 encoded)
|
||||
$this->assertSame('!!binary ZsM/cg==', $this->dumper->dump("f\xc3\x3fr"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider objectAsMapProvider
|
||||
*/
|
||||
public function testDumpObjectAsMap($object, $expected)
|
||||
{
|
||||
$yaml = $this->dumper->dump($object, 0, 0, Yaml::DUMP_OBJECT_AS_MAP);
|
||||
|
||||
$this->assertEquals($expected, Yaml::parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP));
|
||||
}
|
||||
|
||||
public function objectAsMapProvider()
|
||||
{
|
||||
$tests = array();
|
||||
|
||||
$bar = new \stdClass();
|
||||
$bar->class = 'classBar';
|
||||
$bar->args = array('bar');
|
||||
$zar = new \stdClass();
|
||||
$foo = new \stdClass();
|
||||
$foo->bar = $bar;
|
||||
$foo->zar = $zar;
|
||||
$object = new \stdClass();
|
||||
$object->foo = $foo;
|
||||
$tests['stdClass'] = array($object, $object);
|
||||
|
||||
$arrayObject = new \ArrayObject();
|
||||
$arrayObject['foo'] = 'bar';
|
||||
$arrayObject['baz'] = 'foobar';
|
||||
$parsedArrayObject = new \stdClass();
|
||||
$parsedArrayObject->foo = 'bar';
|
||||
$parsedArrayObject->baz = 'foobar';
|
||||
$tests['ArrayObject'] = array($arrayObject, $parsedArrayObject);
|
||||
|
||||
$a = new A();
|
||||
$tests['arbitrary-object'] = array($a, null);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
public function testDumpingArrayObjectInstancesRespectsInlineLevel()
|
||||
{
|
||||
$deep = new \ArrayObject(array('deep1' => 'd', 'deep2' => 'e'));
|
||||
$inner = new \ArrayObject(array('inner1' => 'b', 'inner2' => 'c', 'inner3' => $deep));
|
||||
$outer = new \ArrayObject(array('outer1' => 'a', 'outer2' => $inner));
|
||||
|
||||
$yaml = $this->dumper->dump($outer, 2, 0, Yaml::DUMP_OBJECT_AS_MAP);
|
||||
|
||||
$expected = <<<YAML
|
||||
outer1: a
|
||||
outer2:
|
||||
inner1: b
|
||||
inner2: c
|
||||
inner3: { deep1: d, deep2: e }
|
||||
|
||||
YAML;
|
||||
$this->assertSame($expected, $yaml);
|
||||
}
|
||||
|
||||
public function testDumpingArrayObjectInstancesWithNumericKeysInlined()
|
||||
{
|
||||
$deep = new \ArrayObject(array('d', 'e'));
|
||||
$inner = new \ArrayObject(array('b', 'c', $deep));
|
||||
$outer = new \ArrayObject(array('a', $inner));
|
||||
|
||||
$yaml = $this->dumper->dump($outer, 0, 0, Yaml::DUMP_OBJECT_AS_MAP);
|
||||
$expected = <<<YAML
|
||||
{ 0: a, 1: { 0: b, 1: c, 2: { 0: d, 1: e } } }
|
||||
YAML;
|
||||
$this->assertSame($expected, $yaml);
|
||||
}
|
||||
|
||||
public function testDumpingArrayObjectInstancesWithNumericKeysRespectsInlineLevel()
|
||||
{
|
||||
$deep = new \ArrayObject(array('d', 'e'));
|
||||
$inner = new \ArrayObject(array('b', 'c', $deep));
|
||||
$outer = new \ArrayObject(array('a', $inner));
|
||||
$yaml = $this->dumper->dump($outer, 2, 0, Yaml::DUMP_OBJECT_AS_MAP);
|
||||
$expected = <<<YAML
|
||||
0: a
|
||||
1:
|
||||
0: b
|
||||
1: c
|
||||
2: { 0: d, 1: e }
|
||||
|
||||
YAML;
|
||||
$this->assertEquals($expected, $yaml);
|
||||
}
|
||||
|
||||
public function testDumpEmptyArrayObjectInstanceAsMap()
|
||||
{
|
||||
$this->assertSame('{ }', $this->dumper->dump(new \ArrayObject(), 2, 0, Yaml::DUMP_OBJECT_AS_MAP));
|
||||
}
|
||||
|
||||
public function testDumpEmptyStdClassInstanceAsMap()
|
||||
{
|
||||
$this->assertSame('{ }', $this->dumper->dump(new \stdClass(), 2, 0, Yaml::DUMP_OBJECT_AS_MAP));
|
||||
}
|
||||
|
||||
public function testDumpingStdClassInstancesRespectsInlineLevel()
|
||||
{
|
||||
$deep = new \stdClass();
|
||||
$deep->deep1 = 'd';
|
||||
$deep->deep2 = 'e';
|
||||
|
||||
$inner = new \stdClass();
|
||||
$inner->inner1 = 'b';
|
||||
$inner->inner2 = 'c';
|
||||
$inner->inner3 = $deep;
|
||||
|
||||
$outer = new \stdClass();
|
||||
$outer->outer1 = 'a';
|
||||
$outer->outer2 = $inner;
|
||||
|
||||
$yaml = $this->dumper->dump($outer, 2, 0, Yaml::DUMP_OBJECT_AS_MAP);
|
||||
|
||||
$expected = <<<YAML
|
||||
outer1: a
|
||||
outer2:
|
||||
inner1: b
|
||||
inner2: c
|
||||
inner3: { deep1: d, deep2: e }
|
||||
|
||||
YAML;
|
||||
$this->assertSame($expected, $yaml);
|
||||
}
|
||||
|
||||
public function testDumpMultiLineStringAsScalarBlock()
|
||||
{
|
||||
$data = array(
|
||||
'data' => array(
|
||||
'single_line' => 'foo bar baz',
|
||||
'multi_line' => "foo\nline with trailing spaces:\n \nbar\ninteger like line:\n123456789\nempty line:\n\nbaz",
|
||||
'multi_line_with_carriage_return' => "foo\nbar\r\nbaz",
|
||||
'nested_inlined_multi_line_string' => array(
|
||||
'inlined_multi_line' => "foo\nbar\r\nempty line:\n\nbaz",
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
|
||||
}
|
||||
|
||||
public function testDumpMultiLineStringAsScalarBlockWhenFirstLineHasLeadingSpace()
|
||||
{
|
||||
$data = array(
|
||||
'data' => array(
|
||||
'multi_line' => " the first line has leading spaces\nThe second line does not.",
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
|
||||
}
|
||||
|
||||
public function testCarriageReturnIsMaintainedWhenDumpingAsMultiLineLiteralBlock()
|
||||
{
|
||||
$this->assertSame("- \"a\\r\\nb\\nc\"\n", $this->dumper->dump(array("a\r\nb\nc"), 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The indentation must be greater than zero
|
||||
*/
|
||||
public function testZeroIndentationThrowsException()
|
||||
{
|
||||
new Dumper(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The indentation must be greater than zero
|
||||
*/
|
||||
public function testNegativeIndentationThrowsException()
|
||||
{
|
||||
new Dumper(-4);
|
||||
}
|
||||
}
|
||||
|
||||
class A
|
||||
{
|
||||
public $a = 'foo';
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Simple Alias Example
|
||||
brief: >
|
||||
If you need to refer to the same item of data twice,
|
||||
you can give that item an alias. The alias is a plain
|
||||
string, starting with an ampersand. The item may then
|
||||
be referred to by the alias throughout your document
|
||||
by using an asterisk before the name of the alias.
|
||||
This is called an anchor.
|
||||
yaml: |
|
||||
- &showell Steve
|
||||
- Clark
|
||||
- Brian
|
||||
- Oren
|
||||
- *showell
|
||||
php: |
|
||||
array('Steve', 'Clark', 'Brian', 'Oren', 'Steve')
|
||||
|
||||
---
|
||||
test: Alias of a Mapping
|
||||
brief: >
|
||||
An alias can be used on any item of data, including
|
||||
sequences, mappings, and other complex data types.
|
||||
yaml: |
|
||||
- &hello
|
||||
Meat: pork
|
||||
Starch: potato
|
||||
- banana
|
||||
- *hello
|
||||
php: |
|
||||
array(array('Meat'=>'pork', 'Starch'=>'potato'), 'banana', array('Meat'=>'pork', 'Starch'=>'potato'))
|
202
vendor/symfony/yaml/Tests/Fixtures/YtsBasicTests.yml
vendored
202
vendor/symfony/yaml/Tests/Fixtures/YtsBasicTests.yml
vendored
@@ -1,202 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Simple Sequence
|
||||
brief: |
|
||||
You can specify a list in YAML by placing each
|
||||
member of the list on a new line with an opening
|
||||
dash. These lists are called sequences.
|
||||
yaml: |
|
||||
- apple
|
||||
- banana
|
||||
- carrot
|
||||
php: |
|
||||
array('apple', 'banana', 'carrot')
|
||||
---
|
||||
test: Sequence With Item Being Null In The Middle
|
||||
brief: |
|
||||
You can specify a list in YAML by placing each
|
||||
member of the list on a new line with an opening
|
||||
dash. These lists are called sequences.
|
||||
yaml: |
|
||||
- apple
|
||||
-
|
||||
- carrot
|
||||
php: |
|
||||
array('apple', null, 'carrot')
|
||||
---
|
||||
test: Sequence With Last Item Being Null
|
||||
brief: |
|
||||
You can specify a list in YAML by placing each
|
||||
member of the list on a new line with an opening
|
||||
dash. These lists are called sequences.
|
||||
yaml: |
|
||||
- apple
|
||||
- banana
|
||||
-
|
||||
php: |
|
||||
array('apple', 'banana', null)
|
||||
---
|
||||
test: Nested Sequences
|
||||
brief: |
|
||||
You can include a sequence within another
|
||||
sequence by giving the sequence an empty
|
||||
dash, followed by an indented list.
|
||||
yaml: |
|
||||
-
|
||||
- foo
|
||||
- bar
|
||||
- baz
|
||||
php: |
|
||||
array(array('foo', 'bar', 'baz'))
|
||||
---
|
||||
test: Mixed Sequences
|
||||
brief: |
|
||||
Sequences can contain any YAML data,
|
||||
including strings and other sequences.
|
||||
yaml: |
|
||||
- apple
|
||||
-
|
||||
- foo
|
||||
- bar
|
||||
- x123
|
||||
- banana
|
||||
- carrot
|
||||
php: |
|
||||
array('apple', array('foo', 'bar', 'x123'), 'banana', 'carrot')
|
||||
---
|
||||
test: Deeply Nested Sequences
|
||||
brief: |
|
||||
Sequences can be nested even deeper, with each
|
||||
level of indentation representing a level of
|
||||
depth.
|
||||
yaml: |
|
||||
-
|
||||
-
|
||||
- uno
|
||||
- dos
|
||||
php: |
|
||||
array(array(array('uno', 'dos')))
|
||||
---
|
||||
test: Simple Mapping
|
||||
brief: |
|
||||
You can add a keyed list (also known as a dictionary or
|
||||
hash) to your document by placing each member of the
|
||||
list on a new line, with a colon separating the key
|
||||
from its value. In YAML, this type of list is called
|
||||
a mapping.
|
||||
yaml: |
|
||||
foo: whatever
|
||||
bar: stuff
|
||||
php: |
|
||||
array('foo' => 'whatever', 'bar' => 'stuff')
|
||||
---
|
||||
test: Sequence in a Mapping
|
||||
brief: |
|
||||
A value in a mapping can be a sequence.
|
||||
yaml: |
|
||||
foo: whatever
|
||||
bar:
|
||||
- uno
|
||||
- dos
|
||||
php: |
|
||||
array('foo' => 'whatever', 'bar' => array('uno', 'dos'))
|
||||
---
|
||||
test: Nested Mappings
|
||||
brief: |
|
||||
A value in a mapping can be another mapping.
|
||||
yaml: |
|
||||
foo: whatever
|
||||
bar:
|
||||
fruit: apple
|
||||
name: steve
|
||||
sport: baseball
|
||||
php: |
|
||||
array(
|
||||
'foo' => 'whatever',
|
||||
'bar' => array(
|
||||
'fruit' => 'apple',
|
||||
'name' => 'steve',
|
||||
'sport' => 'baseball'
|
||||
)
|
||||
)
|
||||
---
|
||||
test: Mixed Mapping
|
||||
brief: |
|
||||
A mapping can contain any assortment
|
||||
of mappings and sequences as values.
|
||||
yaml: |
|
||||
foo: whatever
|
||||
bar:
|
||||
-
|
||||
fruit: apple
|
||||
name: steve
|
||||
sport: baseball
|
||||
- more
|
||||
-
|
||||
python: rocks
|
||||
perl: papers
|
||||
ruby: scissorses
|
||||
php: |
|
||||
array(
|
||||
'foo' => 'whatever',
|
||||
'bar' => array(
|
||||
array(
|
||||
'fruit' => 'apple',
|
||||
'name' => 'steve',
|
||||
'sport' => 'baseball'
|
||||
),
|
||||
'more',
|
||||
array(
|
||||
'python' => 'rocks',
|
||||
'perl' => 'papers',
|
||||
'ruby' => 'scissorses'
|
||||
)
|
||||
)
|
||||
)
|
||||
---
|
||||
test: Mapping-in-Sequence Shortcut
|
||||
todo: true
|
||||
brief: |
|
||||
If you are adding a mapping to a sequence, you
|
||||
can place the mapping on the same line as the
|
||||
dash as a shortcut.
|
||||
yaml: |
|
||||
- work on YAML.py:
|
||||
- work on Store
|
||||
php: |
|
||||
array(array('work on YAML.py' => array('work on Store')))
|
||||
---
|
||||
test: Sequence-in-Mapping Shortcut
|
||||
todo: true
|
||||
brief: |
|
||||
The dash in a sequence counts as indentation, so
|
||||
you can add a sequence inside of a mapping without
|
||||
needing spaces as indentation.
|
||||
yaml: |
|
||||
allow:
|
||||
- 'localhost'
|
||||
- '%.sourceforge.net'
|
||||
- '%.freepan.org'
|
||||
php: |
|
||||
array('allow' => array('localhost', '%.sourceforge.net', '%.freepan.org'))
|
||||
---
|
||||
todo: true
|
||||
test: Merge key
|
||||
brief: |
|
||||
A merge key ('<<') can be used in a mapping to insert other mappings. If
|
||||
the value associated with the merge key is a mapping, each of its key/value
|
||||
pairs is inserted into the current mapping.
|
||||
yaml: |
|
||||
mapping:
|
||||
name: Joe
|
||||
job: Accountant
|
||||
<<:
|
||||
age: 38
|
||||
php: |
|
||||
array(
|
||||
'mapping' =>
|
||||
array(
|
||||
'name' => 'Joe',
|
||||
'job' => 'Accountant',
|
||||
'age' => 38
|
||||
)
|
||||
)
|
@@ -1,51 +0,0 @@
|
||||
---
|
||||
test: One Element Mapping
|
||||
brief: |
|
||||
A mapping with one key/value pair
|
||||
yaml: |
|
||||
foo: bar
|
||||
php: |
|
||||
array('foo' => 'bar')
|
||||
---
|
||||
test: Multi Element Mapping
|
||||
brief: |
|
||||
More than one key/value pair
|
||||
yaml: |
|
||||
red: baron
|
||||
white: walls
|
||||
blue: berries
|
||||
php: |
|
||||
array(
|
||||
'red' => 'baron',
|
||||
'white' => 'walls',
|
||||
'blue' => 'berries',
|
||||
)
|
||||
---
|
||||
test: Values aligned
|
||||
brief: |
|
||||
Often times human editors of documents will align the values even
|
||||
though YAML emitters generally don't.
|
||||
yaml: |
|
||||
red: baron
|
||||
white: walls
|
||||
blue: berries
|
||||
php: |
|
||||
array(
|
||||
'red' => 'baron',
|
||||
'white' => 'walls',
|
||||
'blue' => 'berries',
|
||||
)
|
||||
---
|
||||
test: Colons aligned
|
||||
brief: |
|
||||
Spaces can come before the ': ' key/value separator.
|
||||
yaml: |
|
||||
red : baron
|
||||
white : walls
|
||||
blue : berries
|
||||
php: |
|
||||
array(
|
||||
'red' => 'baron',
|
||||
'white' => 'walls',
|
||||
'blue' => 'berries',
|
||||
)
|
@@ -1,85 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Trailing Document Separator
|
||||
todo: true
|
||||
brief: >
|
||||
You can separate YAML documents
|
||||
with a string of three dashes.
|
||||
yaml: |
|
||||
- foo: 1
|
||||
bar: 2
|
||||
---
|
||||
more: stuff
|
||||
python: |
|
||||
[
|
||||
[ { 'foo': 1, 'bar': 2 } ],
|
||||
{ 'more': 'stuff' }
|
||||
]
|
||||
ruby: |
|
||||
[ { 'foo' => 1, 'bar' => 2 } ]
|
||||
|
||||
---
|
||||
test: Leading Document Separator
|
||||
todo: true
|
||||
brief: >
|
||||
You can explicitly give an opening
|
||||
document separator to your YAML stream.
|
||||
yaml: |
|
||||
---
|
||||
- foo: 1
|
||||
bar: 2
|
||||
---
|
||||
more: stuff
|
||||
python: |
|
||||
[
|
||||
[ {'foo': 1, 'bar': 2}],
|
||||
{'more': 'stuff'}
|
||||
]
|
||||
ruby: |
|
||||
[ { 'foo' => 1, 'bar' => 2 } ]
|
||||
|
||||
---
|
||||
test: YAML Header
|
||||
todo: true
|
||||
brief: >
|
||||
The opening separator can contain directives
|
||||
to the YAML parser, such as the version
|
||||
number.
|
||||
yaml: |
|
||||
--- %YAML:1.0
|
||||
foo: 1
|
||||
bar: 2
|
||||
php: |
|
||||
array('foo' => 1, 'bar' => 2)
|
||||
documents: 1
|
||||
|
||||
---
|
||||
test: Red Herring Document Separator
|
||||
brief: >
|
||||
Separators included in blocks or strings
|
||||
are treated as blocks or strings, as the
|
||||
document separator should have no indentation
|
||||
preceding it.
|
||||
yaml: |
|
||||
foo: |
|
||||
---
|
||||
php: |
|
||||
array('foo' => "---\n")
|
||||
|
||||
---
|
||||
test: Multiple Document Separators in Block
|
||||
brief: >
|
||||
This technique allows you to embed other YAML
|
||||
documents within literal blocks.
|
||||
yaml: |
|
||||
foo: |
|
||||
---
|
||||
foo: bar
|
||||
---
|
||||
yo: baz
|
||||
bar: |
|
||||
fooness
|
||||
php: |
|
||||
array(
|
||||
'foo' => "---\nfoo: bar\n---\nyo: baz\n",
|
||||
'bar' => "fooness\n"
|
||||
)
|
@@ -1,25 +0,0 @@
|
||||
---
|
||||
test: Missing value for hash item
|
||||
todo: true
|
||||
brief: |
|
||||
Third item in this hash doesn't have a value
|
||||
yaml: |
|
||||
okay: value
|
||||
also okay: ~
|
||||
causes error because no value specified
|
||||
last key: value okay here too
|
||||
python-error: causes error because no value specified
|
||||
|
||||
---
|
||||
test: Not indenting enough
|
||||
brief: |
|
||||
There was a bug in PyYaml where it was off by one
|
||||
in the indentation check. It was allowing the YAML
|
||||
below.
|
||||
# This is actually valid YAML now. Someone should tell showell.
|
||||
yaml: |
|
||||
foo:
|
||||
firstline: 1
|
||||
secondline: 2
|
||||
php: |
|
||||
array('foo' => null, 'firstline' => 1, 'secondline' => 2)
|
@@ -1,60 +0,0 @@
|
||||
---
|
||||
test: Simple Inline Array
|
||||
brief: >
|
||||
Sequences can be contained on a
|
||||
single line, using the inline syntax.
|
||||
Separate each entry with commas and
|
||||
enclose in square brackets.
|
||||
yaml: |
|
||||
seq: [ a, b, c ]
|
||||
php: |
|
||||
array('seq' => array('a', 'b', 'c'))
|
||||
---
|
||||
test: Simple Inline Hash
|
||||
brief: >
|
||||
Mapping can also be contained on
|
||||
a single line, using the inline
|
||||
syntax. Each key-value pair is
|
||||
separated by a colon, with a comma
|
||||
between each entry in the mapping.
|
||||
Enclose with curly braces.
|
||||
yaml: |
|
||||
hash: { name: Steve, foo: bar }
|
||||
php: |
|
||||
array('hash' => array('name' => 'Steve', 'foo' => 'bar'))
|
||||
---
|
||||
test: Multi-line Inline Collections
|
||||
todo: true
|
||||
brief: >
|
||||
Both inline sequences and inline mappings
|
||||
can span multiple lines, provided that you
|
||||
indent the additional lines.
|
||||
yaml: |
|
||||
languages: [ Ruby,
|
||||
Perl,
|
||||
Python ]
|
||||
websites: { YAML: yaml.org,
|
||||
Ruby: ruby-lang.org,
|
||||
Python: python.org,
|
||||
Perl: use.perl.org }
|
||||
php: |
|
||||
array(
|
||||
'languages' => array('Ruby', 'Perl', 'Python'),
|
||||
'websites' => array(
|
||||
'YAML' => 'yaml.org',
|
||||
'Ruby' => 'ruby-lang.org',
|
||||
'Python' => 'python.org',
|
||||
'Perl' => 'use.perl.org'
|
||||
)
|
||||
)
|
||||
---
|
||||
test: Commas in Values (not in the spec!)
|
||||
todo: true
|
||||
brief: >
|
||||
List items in collections are delimited by commas, but
|
||||
there must be a space after each comma. This allows you
|
||||
to add numbers without quoting.
|
||||
yaml: |
|
||||
attendances: [ 45,123, 70,000, 17,222 ]
|
||||
php: |
|
||||
array('attendances' => array(45123, 70000, 17222))
|
@@ -1,176 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Single ending newline
|
||||
brief: >
|
||||
A pipe character, followed by an indented
|
||||
block of text is treated as a literal
|
||||
block, in which newlines are preserved
|
||||
throughout the block, including the final
|
||||
newline.
|
||||
yaml: |
|
||||
---
|
||||
this: |
|
||||
Foo
|
||||
Bar
|
||||
php: |
|
||||
array('this' => "Foo\nBar\n")
|
||||
---
|
||||
test: The '+' indicator
|
||||
brief: >
|
||||
The '+' indicator says to keep newlines at the end of text
|
||||
blocks.
|
||||
yaml: |
|
||||
normal: |
|
||||
extra new lines not kept
|
||||
|
||||
preserving: |+
|
||||
extra new lines are kept
|
||||
|
||||
|
||||
dummy: value
|
||||
php: |
|
||||
array(
|
||||
'normal' => "extra new lines not kept\n",
|
||||
'preserving' => "extra new lines are kept\n\n\n",
|
||||
'dummy' => 'value'
|
||||
)
|
||||
---
|
||||
test: Three trailing newlines in literals
|
||||
brief: >
|
||||
To give you more control over how space
|
||||
is preserved in text blocks, YAML has
|
||||
the keep '+' and chomp '-' indicators.
|
||||
The keep indicator will preserve all
|
||||
ending newlines, while the chomp indicator
|
||||
will strip all ending newlines.
|
||||
yaml: |
|
||||
clipped: |
|
||||
This has one newline.
|
||||
|
||||
|
||||
|
||||
same as "clipped" above: "This has one newline.\n"
|
||||
|
||||
stripped: |-
|
||||
This has no newline.
|
||||
|
||||
|
||||
|
||||
same as "stripped" above: "This has no newline."
|
||||
|
||||
kept: |+
|
||||
This has four newlines.
|
||||
|
||||
|
||||
|
||||
same as "kept" above: "This has four newlines.\n\n\n\n"
|
||||
php: |
|
||||
array(
|
||||
'clipped' => "This has one newline.\n",
|
||||
'same as "clipped" above' => "This has one newline.\n",
|
||||
'stripped' => 'This has no newline.',
|
||||
'same as "stripped" above' => 'This has no newline.',
|
||||
'kept' => "This has four newlines.\n\n\n\n",
|
||||
'same as "kept" above' => "This has four newlines.\n\n\n\n"
|
||||
)
|
||||
---
|
||||
test: Extra trailing newlines with spaces
|
||||
todo: true
|
||||
brief: >
|
||||
Normally, only a single newline is kept
|
||||
from the end of a literal block, unless the
|
||||
keep '+' character is used in combination
|
||||
with the pipe. The following example
|
||||
will preserve all ending whitespace
|
||||
since the last line of both literal blocks
|
||||
contains spaces which extend past the indentation
|
||||
level.
|
||||
yaml: |
|
||||
---
|
||||
this: |
|
||||
Foo
|
||||
|
||||
|
||||
kept: |+
|
||||
Foo
|
||||
|
||||
|
||||
php: |
|
||||
array('this' => "Foo\n\n \n",
|
||||
'kept' => "Foo\n\n \n" )
|
||||
|
||||
---
|
||||
test: Folded Block in a Sequence
|
||||
brief: >
|
||||
A greater-then character, followed by an indented
|
||||
block of text is treated as a folded block, in
|
||||
which lines of text separated by a single newline
|
||||
are concatenated as a single line.
|
||||
yaml: |
|
||||
---
|
||||
- apple
|
||||
- banana
|
||||
- >
|
||||
can't you see
|
||||
the beauty of yaml?
|
||||
hmm
|
||||
- dog
|
||||
php: |
|
||||
array(
|
||||
'apple',
|
||||
'banana',
|
||||
"can't you see the beauty of yaml? hmm\n",
|
||||
'dog'
|
||||
)
|
||||
---
|
||||
test: Folded Block as a Mapping Value
|
||||
brief: >
|
||||
Both literal and folded blocks can be
|
||||
used in collections, as values in a
|
||||
sequence or a mapping.
|
||||
yaml: |
|
||||
---
|
||||
quote: >
|
||||
Mark McGwire's
|
||||
year was crippled
|
||||
by a knee injury.
|
||||
source: espn
|
||||
php: |
|
||||
array(
|
||||
'quote' => "Mark McGwire's year was crippled by a knee injury.\n",
|
||||
'source' => 'espn'
|
||||
)
|
||||
---
|
||||
test: Three trailing newlines in folded blocks
|
||||
brief: >
|
||||
The keep and chomp indicators can also
|
||||
be applied to folded blocks.
|
||||
yaml: |
|
||||
clipped: >
|
||||
This has one newline.
|
||||
|
||||
|
||||
|
||||
same as "clipped" above: "This has one newline.\n"
|
||||
|
||||
stripped: >-
|
||||
This has no newline.
|
||||
|
||||
|
||||
|
||||
same as "stripped" above: "This has no newline."
|
||||
|
||||
kept: >+
|
||||
This has four newlines.
|
||||
|
||||
|
||||
|
||||
same as "kept" above: "This has four newlines.\n\n\n\n"
|
||||
php: |
|
||||
array(
|
||||
'clipped' => "This has one newline.\n",
|
||||
'same as "clipped" above' => "This has one newline.\n",
|
||||
'stripped' => 'This has no newline.',
|
||||
'same as "stripped" above' => 'This has no newline.',
|
||||
'kept' => "This has four newlines.\n\n\n\n",
|
||||
'same as "kept" above' => "This has four newlines.\n\n\n\n"
|
||||
)
|
@@ -1,45 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Empty Sequence
|
||||
brief: >
|
||||
You can represent the empty sequence
|
||||
with an empty inline sequence.
|
||||
yaml: |
|
||||
empty: []
|
||||
php: |
|
||||
array('empty' => array())
|
||||
---
|
||||
test: Empty Mapping
|
||||
brief: >
|
||||
You can represent the empty mapping
|
||||
with an empty inline mapping.
|
||||
yaml: |
|
||||
empty: {}
|
||||
php: |
|
||||
array('empty' => array())
|
||||
---
|
||||
test: Empty Sequence as Entire Document
|
||||
yaml: |
|
||||
[]
|
||||
php: |
|
||||
array()
|
||||
---
|
||||
test: Empty Mapping as Entire Document
|
||||
yaml: |
|
||||
{}
|
||||
php: |
|
||||
array()
|
||||
---
|
||||
test: Null as Document
|
||||
yaml: |
|
||||
~
|
||||
php: |
|
||||
null
|
||||
---
|
||||
test: Empty String
|
||||
brief: >
|
||||
You can represent an empty string
|
||||
with a pair of quotes.
|
||||
yaml: |
|
||||
''
|
||||
php: |
|
||||
''
|
File diff suppressed because it is too large
Load Diff
@@ -1,224 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Strings
|
||||
brief: >
|
||||
Any group of characters beginning with an
|
||||
alphabetic or numeric character is a string,
|
||||
unless it belongs to one of the groups below
|
||||
(such as an Integer or Time).
|
||||
yaml: |
|
||||
String
|
||||
php: |
|
||||
'String'
|
||||
---
|
||||
test: String characters
|
||||
brief: >
|
||||
A string can contain any alphabetic or
|
||||
numeric character, along with many
|
||||
punctuation characters, including the
|
||||
period, dash, space, quotes, exclamation, and
|
||||
question mark.
|
||||
yaml: |
|
||||
- What's Yaml?
|
||||
- It's for writing data structures in plain text.
|
||||
- And?
|
||||
- And what? That's not good enough for you?
|
||||
- No, I mean, "And what about Yaml?"
|
||||
- Oh, oh yeah. Uh.. Yaml for Ruby.
|
||||
php: |
|
||||
array(
|
||||
"What's Yaml?",
|
||||
"It's for writing data structures in plain text.",
|
||||
"And?",
|
||||
"And what? That's not good enough for you?",
|
||||
"No, I mean, \"And what about Yaml?\"",
|
||||
"Oh, oh yeah. Uh.. Yaml for Ruby."
|
||||
)
|
||||
---
|
||||
test: Indicators in Strings
|
||||
brief: >
|
||||
Be careful using indicators in strings. In particular,
|
||||
the comma, colon, and pound sign must be used carefully.
|
||||
yaml: |
|
||||
the colon followed by space is an indicator: but is a string:right here
|
||||
same for the pound sign: here we have it#in a string
|
||||
the comma can, honestly, be used in most cases: [ but not in, inline collections ]
|
||||
php: |
|
||||
array(
|
||||
'the colon followed by space is an indicator' => 'but is a string:right here',
|
||||
'same for the pound sign' => 'here we have it#in a string',
|
||||
'the comma can, honestly, be used in most cases' => array('but not in', 'inline collections')
|
||||
)
|
||||
---
|
||||
test: Forcing Strings
|
||||
brief: >
|
||||
Any YAML type can be forced into a string using the
|
||||
explicit !!str method.
|
||||
yaml: |
|
||||
date string: !!str 2001-08-01
|
||||
number string: !!str 192
|
||||
php: |
|
||||
array(
|
||||
'date string' => '2001-08-01',
|
||||
'number string' => '192'
|
||||
)
|
||||
---
|
||||
test: Single-quoted Strings
|
||||
brief: >
|
||||
You can also enclose your strings within single quotes,
|
||||
which allows use of slashes, colons, and other indicators
|
||||
freely. Inside single quotes, you can represent a single
|
||||
quote in your string by using two single quotes next to
|
||||
each other.
|
||||
yaml: |
|
||||
all my favorite symbols: '#:!/%.)'
|
||||
a few i hate: '&(*'
|
||||
why do i hate them?: 'it''s very hard to explain'
|
||||
entities: '£ me'
|
||||
php: |
|
||||
array(
|
||||
'all my favorite symbols' => '#:!/%.)',
|
||||
'a few i hate' => '&(*',
|
||||
'why do i hate them?' => 'it\'s very hard to explain',
|
||||
'entities' => '£ me'
|
||||
)
|
||||
---
|
||||
test: Double-quoted Strings
|
||||
brief: >
|
||||
Enclosing strings in double quotes allows you
|
||||
to use escapings to represent ASCII and
|
||||
Unicode characters.
|
||||
yaml: |
|
||||
i know where i want my line breaks: "one here\nand another here\n"
|
||||
php: |
|
||||
array(
|
||||
'i know where i want my line breaks' => "one here\nand another here\n"
|
||||
)
|
||||
---
|
||||
test: Multi-line Quoted Strings
|
||||
todo: true
|
||||
brief: >
|
||||
Both single- and double-quoted strings may be
|
||||
carried on to new lines in your YAML document.
|
||||
They must be indented a step and indentation
|
||||
is interpreted as a single space.
|
||||
yaml: |
|
||||
i want a long string: "so i'm going to
|
||||
let it go on and on to other lines
|
||||
until i end it with a quote."
|
||||
php: |
|
||||
array('i want a long string' => "so i'm going to ".
|
||||
"let it go on and on to other lines ".
|
||||
"until i end it with a quote."
|
||||
)
|
||||
|
||||
---
|
||||
test: Plain scalars
|
||||
todo: true
|
||||
brief: >
|
||||
Unquoted strings may also span multiple lines, if they
|
||||
are free of YAML space indicators and indented.
|
||||
yaml: |
|
||||
- My little toe is broken in two places;
|
||||
- I'm crazy to have skied this way;
|
||||
- I'm not the craziest he's seen, since there was always the German guy
|
||||
who skied for 3 hours on a broken shin bone (just below the kneecap);
|
||||
- Nevertheless, second place is respectable, and he doesn't
|
||||
recommend going for the record;
|
||||
- He's going to put my foot in plaster for a month;
|
||||
- This would impair my skiing ability somewhat for the
|
||||
duration, as can be imagined.
|
||||
php: |
|
||||
array(
|
||||
"My little toe is broken in two places;",
|
||||
"I'm crazy to have skied this way;",
|
||||
"I'm not the craziest he's seen, since there was always ".
|
||||
"the German guy who skied for 3 hours on a broken shin ".
|
||||
"bone (just below the kneecap);",
|
||||
"Nevertheless, second place is respectable, and he doesn't ".
|
||||
"recommend going for the record;",
|
||||
"He's going to put my foot in plaster for a month;",
|
||||
"This would impair my skiing ability somewhat for the duration, ".
|
||||
"as can be imagined."
|
||||
)
|
||||
---
|
||||
test: 'Null'
|
||||
brief: >
|
||||
You can use the tilde '~' character for a null value.
|
||||
yaml: |
|
||||
name: Mr. Show
|
||||
hosted by: Bob and David
|
||||
date of next season: ~
|
||||
php: |
|
||||
array(
|
||||
'name' => 'Mr. Show',
|
||||
'hosted by' => 'Bob and David',
|
||||
'date of next season' => null
|
||||
)
|
||||
---
|
||||
test: Boolean
|
||||
brief: >
|
||||
You can use 'true' and 'false' for Boolean values.
|
||||
yaml: |
|
||||
Is Gus a Liar?: true
|
||||
Do I rely on Gus for Sustenance?: false
|
||||
php: |
|
||||
array(
|
||||
'Is Gus a Liar?' => true,
|
||||
'Do I rely on Gus for Sustenance?' => false
|
||||
)
|
||||
---
|
||||
test: Integers
|
||||
dump_skip: true
|
||||
brief: >
|
||||
An integer is a series of numbers, optionally
|
||||
starting with a positive or negative sign. Integers
|
||||
may also contain commas for readability.
|
||||
yaml: |
|
||||
zero: 0
|
||||
simple: 12
|
||||
php: |
|
||||
array(
|
||||
'zero' => 0,
|
||||
'simple' => 12,
|
||||
)
|
||||
---
|
||||
test: Floats
|
||||
dump_skip: true
|
||||
brief: >
|
||||
Floats are represented by numbers with decimals,
|
||||
allowing for scientific notation, as well as
|
||||
positive and negative infinity and "not a number."
|
||||
yaml: |
|
||||
a simple float: 2.00
|
||||
scientific notation: 1.00009e+3
|
||||
php: |
|
||||
array(
|
||||
'a simple float' => 2.0,
|
||||
'scientific notation' => 1000.09
|
||||
)
|
||||
---
|
||||
test: Time
|
||||
todo: true
|
||||
brief: >
|
||||
You can represent timestamps by using
|
||||
ISO8601 format, or a variation which
|
||||
allows spaces between the date, time and
|
||||
time zone.
|
||||
yaml: |
|
||||
iso8601: 2001-12-14t21:59:43.10-05:00
|
||||
space separated: 2001-12-14 21:59:43.10 -05:00
|
||||
php: |
|
||||
array(
|
||||
'iso8601' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
|
||||
'space separated' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" )
|
||||
)
|
||||
---
|
||||
test: Date
|
||||
todo: true
|
||||
brief: >
|
||||
A date can be represented by its year,
|
||||
month and day in ISO8601 order.
|
||||
yaml: |
|
||||
1976-07-31
|
||||
php: |
|
||||
date( 1976, 7, 31 )
|
BIN
vendor/symfony/yaml/Tests/Fixtures/arrow.gif
vendored
BIN
vendor/symfony/yaml/Tests/Fixtures/arrow.gif
vendored
Binary file not shown.
Before Width: | Height: | Size: 185 B |
@@ -1,11 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Miscellaneous
|
||||
spec: 2.21
|
||||
yaml: |
|
||||
true: true
|
||||
false: false
|
||||
php: |
|
||||
array(
|
||||
'true' => true,
|
||||
'false' => false,
|
||||
)
|
@@ -1 +0,0 @@
|
||||
value: <?php echo 1 + 2 + 3 ?>
|
@@ -1,155 +0,0 @@
|
||||
test: outside double quotes
|
||||
yaml: |
|
||||
\0 \ \a \b \n
|
||||
php: |
|
||||
"\\0 \\ \\a \\b \\n"
|
||||
---
|
||||
test: 'null'
|
||||
yaml: |
|
||||
"\0"
|
||||
php: |
|
||||
"\x00"
|
||||
---
|
||||
test: bell
|
||||
yaml: |
|
||||
"\a"
|
||||
php: |
|
||||
"\x07"
|
||||
---
|
||||
test: backspace
|
||||
yaml: |
|
||||
"\b"
|
||||
php: |
|
||||
"\x08"
|
||||
---
|
||||
test: horizontal tab (1)
|
||||
yaml: |
|
||||
"\t"
|
||||
php: |
|
||||
"\x09"
|
||||
---
|
||||
test: horizontal tab (2)
|
||||
yaml: |
|
||||
"\ "
|
||||
php: |
|
||||
"\x09"
|
||||
---
|
||||
test: line feed
|
||||
yaml: |
|
||||
"\n"
|
||||
php: |
|
||||
"\x0a"
|
||||
---
|
||||
test: vertical tab
|
||||
yaml: |
|
||||
"\v"
|
||||
php: |
|
||||
"\x0b"
|
||||
---
|
||||
test: form feed
|
||||
yaml: |
|
||||
"\f"
|
||||
php: |
|
||||
"\x0c"
|
||||
---
|
||||
test: carriage return
|
||||
yaml: |
|
||||
"\r"
|
||||
php: |
|
||||
"\x0d"
|
||||
---
|
||||
test: escape
|
||||
yaml: |
|
||||
"\e"
|
||||
php: |
|
||||
"\x1b"
|
||||
---
|
||||
test: space
|
||||
yaml: |
|
||||
"\ "
|
||||
php: |
|
||||
"\x20"
|
||||
---
|
||||
test: slash
|
||||
yaml: |
|
||||
"\/"
|
||||
php: |
|
||||
"\x2f"
|
||||
---
|
||||
test: backslash
|
||||
yaml: |
|
||||
"\\"
|
||||
php: |
|
||||
"\\"
|
||||
---
|
||||
test: Unicode next line
|
||||
yaml: |
|
||||
"\N"
|
||||
php: |
|
||||
"\xc2\x85"
|
||||
---
|
||||
test: Unicode non-breaking space
|
||||
yaml: |
|
||||
"\_"
|
||||
php: |
|
||||
"\xc2\xa0"
|
||||
---
|
||||
test: Unicode line separator
|
||||
yaml: |
|
||||
"\L"
|
||||
php: |
|
||||
"\xe2\x80\xa8"
|
||||
---
|
||||
test: Unicode paragraph separator
|
||||
yaml: |
|
||||
"\P"
|
||||
php: |
|
||||
"\xe2\x80\xa9"
|
||||
---
|
||||
test: Escaped 8-bit Unicode
|
||||
yaml: |
|
||||
"\x42"
|
||||
php: |
|
||||
"B"
|
||||
---
|
||||
test: Escaped 16-bit Unicode
|
||||
yaml: |
|
||||
"\u20ac"
|
||||
php: |
|
||||
"\xe2\x82\xac"
|
||||
---
|
||||
test: Escaped 32-bit Unicode
|
||||
yaml: |
|
||||
"\U00000043"
|
||||
php: |
|
||||
"C"
|
||||
---
|
||||
test: Example 5.13 Escaped Characters
|
||||
note: |
|
||||
Currently throws an error parsing first line. Maybe Symfony Yaml doesn't support
|
||||
continuation of string across multiple lines? Keeping test here but disabled.
|
||||
todo: true
|
||||
yaml: |
|
||||
"Fun with \\
|
||||
\" \a \b \e \f \
|
||||
\n \r \t \v \0 \
|
||||
\ \_ \N \L \P \
|
||||
\x41 \u0041 \U00000041"
|
||||
php: |
|
||||
"Fun with \x5C\n\x22 \x07 \x08 \x1B \x0C\n\x0A \x0D \x09 \x0B \x00\n\x20 \xA0 \x85 \xe2\x80\xa8 \xe2\x80\xa9\nA A A"
|
||||
---
|
||||
test: Double quotes with a line feed
|
||||
yaml: |
|
||||
{ double: "some value\n \"some quoted string\" and 'some single quotes one'" }
|
||||
php: |
|
||||
array(
|
||||
'double' => "some value\n \"some quoted string\" and 'some single quotes one'"
|
||||
)
|
||||
---
|
||||
test: Backslashes
|
||||
yaml: |
|
||||
{ single: 'foo\Var', no-quotes: foo\Var, double: "foo\\Var" }
|
||||
php: |
|
||||
array(
|
||||
'single' => 'foo\Var', 'no-quotes' => 'foo\Var', 'double' => 'foo\Var'
|
||||
)
|
18
vendor/symfony/yaml/Tests/Fixtures/index.yml
vendored
18
vendor/symfony/yaml/Tests/Fixtures/index.yml
vendored
@@ -1,18 +0,0 @@
|
||||
- escapedCharacters
|
||||
- sfComments
|
||||
- sfCompact
|
||||
- sfTests
|
||||
- sfObjects
|
||||
- sfMergeKey
|
||||
- sfQuotes
|
||||
- YtsAnchorAlias
|
||||
- YtsBasicTests
|
||||
- YtsBlockMapping
|
||||
- YtsDocumentSeparator
|
||||
- YtsErrorTests
|
||||
- YtsFlowCollections
|
||||
- YtsFoldedScalars
|
||||
- YtsNullsAndEmpties
|
||||
- YtsSpecificationExamples
|
||||
- YtsTypeTransfers
|
||||
- unindentedCollections
|
@@ -1,14 +0,0 @@
|
||||
data:
|
||||
single_line: 'foo bar baz'
|
||||
multi_line: |
|
||||
foo
|
||||
line with trailing spaces:
|
||||
|
||||
bar
|
||||
integer like line:
|
||||
123456789
|
||||
empty line:
|
||||
|
||||
baz
|
||||
multi_line_with_carriage_return: "foo\nbar\r\nbaz"
|
||||
nested_inlined_multi_line_string: { inlined_multi_line: "foo\nbar\r\nempty line:\n\nbaz" }
|
@@ -1,4 +0,0 @@
|
||||
data:
|
||||
multi_line: |4
|
||||
the first line has leading spaces
|
||||
The second line does not.
|
@@ -1,3 +0,0 @@
|
||||
- booleanMappingKeys
|
||||
- numericMappingKeys
|
||||
- nullMappingKey
|
@@ -1,18 +0,0 @@
|
||||
- escapedCharacters
|
||||
- sfComments
|
||||
- sfCompact
|
||||
- sfTests
|
||||
- sfObjects
|
||||
- sfMergeKey
|
||||
- sfQuotes
|
||||
- YtsAnchorAlias
|
||||
- YtsBasicTests
|
||||
- YtsBlockMapping
|
||||
- YtsDocumentSeparator
|
||||
- YtsErrorTests
|
||||
- YtsFlowCollections
|
||||
- YtsFoldedScalars
|
||||
- YtsNullsAndEmpties
|
||||
- YtsSpecificationExamples
|
||||
- YtsTypeTransfers
|
||||
- unindentedCollections
|
@@ -1,9 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Miscellaneous
|
||||
spec: 2.21
|
||||
yaml: |
|
||||
null: ~
|
||||
php: |
|
||||
array(
|
||||
'null' => null,
|
||||
)
|
@@ -1,23 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: A sequence with an unordered array
|
||||
brief: >
|
||||
A sequence with an unordered array
|
||||
yaml: |
|
||||
1: foo
|
||||
0: bar
|
||||
php: |
|
||||
array(1 => 'foo', 0 => 'bar')
|
||||
---
|
||||
test: Integers as Map Keys
|
||||
brief: >
|
||||
An integer can be used as dictionary key.
|
||||
yaml: |
|
||||
1: one
|
||||
2: two
|
||||
3: three
|
||||
php: |
|
||||
array(
|
||||
1 => 'one',
|
||||
2 => 'two',
|
||||
3 => 'three'
|
||||
)
|
@@ -1,76 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Comments at the end of a line
|
||||
brief: >
|
||||
Comments at the end of a line
|
||||
yaml: |
|
||||
ex1: "foo # bar"
|
||||
ex2: "foo # bar" # comment
|
||||
ex3: 'foo # bar' # comment
|
||||
ex4: foo # comment
|
||||
ex5: foo # comment with tab before
|
||||
ex6: foo#foo # comment here
|
||||
ex7: foo # ignore me # and me
|
||||
php: |
|
||||
array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo', 'ex5' => 'foo', 'ex6' => 'foo#foo', 'ex7' => 'foo')
|
||||
---
|
||||
test: Comments in the middle
|
||||
brief: >
|
||||
Comments in the middle
|
||||
yaml: |
|
||||
foo:
|
||||
# some comment
|
||||
# some comment
|
||||
bar: foo
|
||||
# some comment
|
||||
# some comment
|
||||
php: |
|
||||
array('foo' => array('bar' => 'foo'))
|
||||
---
|
||||
test: Comments on a hash line
|
||||
brief: >
|
||||
Comments on a hash line
|
||||
yaml: |
|
||||
foo: # a comment
|
||||
foo: bar # a comment
|
||||
php: |
|
||||
array('foo' => array('foo' => 'bar'))
|
||||
---
|
||||
test: 'Value starting with a #'
|
||||
brief: >
|
||||
'Value starting with a #'
|
||||
yaml: |
|
||||
foo: '#bar'
|
||||
php: |
|
||||
array('foo' => '#bar')
|
||||
---
|
||||
test: Document starting with a comment and a separator
|
||||
brief: >
|
||||
Commenting before document start is allowed
|
||||
yaml: |
|
||||
# document comment
|
||||
---
|
||||
foo: bar # a comment
|
||||
php: |
|
||||
array('foo' => 'bar')
|
||||
---
|
||||
test: Comment containing a colon on a hash line
|
||||
brief: >
|
||||
Comment containing a colon on a scalar line
|
||||
yaml: 'foo # comment: this is also part of the comment'
|
||||
php: |
|
||||
'foo'
|
||||
---
|
||||
test: 'Hash key containing a #'
|
||||
brief: >
|
||||
'Hash key containing a #'
|
||||
yaml: 'foo#bar: baz'
|
||||
php: |
|
||||
array('foo#bar' => 'baz')
|
||||
---
|
||||
test: 'Hash key ending with a space and a #'
|
||||
brief: >
|
||||
'Hash key ending with a space and a #'
|
||||
yaml: |
|
||||
'foo #': baz
|
||||
php: |
|
||||
array('foo #' => 'baz')
|
159
vendor/symfony/yaml/Tests/Fixtures/sfCompact.yml
vendored
159
vendor/symfony/yaml/Tests/Fixtures/sfCompact.yml
vendored
@@ -1,159 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Compact notation
|
||||
brief: |
|
||||
Compact notation for sets of mappings with single element
|
||||
yaml: |
|
||||
---
|
||||
# products purchased
|
||||
- item : Super Hoop
|
||||
- item : Basketball
|
||||
quantity: 1
|
||||
- item:
|
||||
name: Big Shoes
|
||||
nick: Biggies
|
||||
quantity: 1
|
||||
php: |
|
||||
array (
|
||||
array (
|
||||
'item' => 'Super Hoop',
|
||||
),
|
||||
array (
|
||||
'item' => 'Basketball',
|
||||
'quantity' => 1,
|
||||
),
|
||||
array (
|
||||
'item' => array(
|
||||
'name' => 'Big Shoes',
|
||||
'nick' => 'Biggies'
|
||||
),
|
||||
'quantity' => 1
|
||||
)
|
||||
)
|
||||
---
|
||||
test: Compact notation combined with inline notation
|
||||
brief: |
|
||||
Combinations of compact and inline notation are allowed
|
||||
yaml: |
|
||||
---
|
||||
items:
|
||||
- { item: Super Hoop, quantity: 1 }
|
||||
- [ Basketball, Big Shoes ]
|
||||
php: |
|
||||
array (
|
||||
'items' => array (
|
||||
array (
|
||||
'item' => 'Super Hoop',
|
||||
'quantity' => 1,
|
||||
),
|
||||
array (
|
||||
'Basketball',
|
||||
'Big Shoes'
|
||||
)
|
||||
)
|
||||
)
|
||||
--- %YAML:1.0
|
||||
test: Compact notation
|
||||
brief: |
|
||||
Compact notation for sets of mappings with single element
|
||||
yaml: |
|
||||
---
|
||||
# products purchased
|
||||
- item : Super Hoop
|
||||
- item : Basketball
|
||||
quantity: 1
|
||||
- item:
|
||||
name: Big Shoes
|
||||
nick: Biggies
|
||||
quantity: 1
|
||||
php: |
|
||||
array (
|
||||
array (
|
||||
'item' => 'Super Hoop',
|
||||
),
|
||||
array (
|
||||
'item' => 'Basketball',
|
||||
'quantity' => 1,
|
||||
),
|
||||
array (
|
||||
'item' => array(
|
||||
'name' => 'Big Shoes',
|
||||
'nick' => 'Biggies'
|
||||
),
|
||||
'quantity' => 1
|
||||
)
|
||||
)
|
||||
---
|
||||
test: Compact notation combined with inline notation
|
||||
brief: |
|
||||
Combinations of compact and inline notation are allowed
|
||||
yaml: |
|
||||
---
|
||||
items:
|
||||
- { item: Super Hoop, quantity: 1 }
|
||||
- [ Basketball, Big Shoes ]
|
||||
php: |
|
||||
array (
|
||||
'items' => array (
|
||||
array (
|
||||
'item' => 'Super Hoop',
|
||||
'quantity' => 1,
|
||||
),
|
||||
array (
|
||||
'Basketball',
|
||||
'Big Shoes'
|
||||
)
|
||||
)
|
||||
)
|
||||
--- %YAML:1.0
|
||||
test: Compact notation
|
||||
brief: |
|
||||
Compact notation for sets of mappings with single element
|
||||
yaml: |
|
||||
---
|
||||
# products purchased
|
||||
- item : Super Hoop
|
||||
- item : Basketball
|
||||
quantity: 1
|
||||
- item:
|
||||
name: Big Shoes
|
||||
nick: Biggies
|
||||
quantity: 1
|
||||
php: |
|
||||
array (
|
||||
array (
|
||||
'item' => 'Super Hoop',
|
||||
),
|
||||
array (
|
||||
'item' => 'Basketball',
|
||||
'quantity' => 1,
|
||||
),
|
||||
array (
|
||||
'item' => array(
|
||||
'name' => 'Big Shoes',
|
||||
'nick' => 'Biggies'
|
||||
),
|
||||
'quantity' => 1
|
||||
)
|
||||
)
|
||||
---
|
||||
test: Compact notation combined with inline notation
|
||||
brief: |
|
||||
Combinations of compact and inline notation are allowed
|
||||
yaml: |
|
||||
---
|
||||
items:
|
||||
- { item: Super Hoop, quantity: 1 }
|
||||
- [ Basketball, Big Shoes ]
|
||||
php: |
|
||||
array (
|
||||
'items' => array (
|
||||
array (
|
||||
'item' => 'Super Hoop',
|
||||
'quantity' => 1,
|
||||
),
|
||||
array (
|
||||
'Basketball',
|
||||
'Big Shoes'
|
||||
)
|
||||
)
|
||||
)
|
@@ -1,61 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Simple In Place Substitution
|
||||
brief: >
|
||||
If you want to reuse an entire alias, only overwriting what is different
|
||||
you can use a << in place substitution. This is not part of the official
|
||||
YAML spec, but a widely implemented extension. See the following URL for
|
||||
details: http://yaml.org/type/merge.html
|
||||
yaml: |
|
||||
foo: &foo
|
||||
a: Steve
|
||||
b: Clark
|
||||
c: Brian
|
||||
e: notnull
|
||||
bar:
|
||||
a: before
|
||||
d: other
|
||||
e: ~
|
||||
<<: *foo
|
||||
b: new
|
||||
x: Oren
|
||||
c:
|
||||
foo: bar
|
||||
bar: foo
|
||||
bar_inline: {a: before, d: other, <<: *foo, b: new, x: Oren, c: { foo: bar, bar: foo}}
|
||||
foo2: &foo2
|
||||
a: Ballmer
|
||||
ding: &dong [ fi, fei, fo, fam]
|
||||
check:
|
||||
<<:
|
||||
- *foo
|
||||
- *dong
|
||||
isit: tested
|
||||
head:
|
||||
<<: [ *foo , *dong , *foo2 ]
|
||||
taz: &taz
|
||||
a: Steve
|
||||
w:
|
||||
p: 1234
|
||||
nested:
|
||||
<<: *taz
|
||||
d: Doug
|
||||
w: &nestedref
|
||||
p: 12345
|
||||
z:
|
||||
<<: *nestedref
|
||||
head_inline: &head_inline { <<: [ *foo , *dong , *foo2 ] }
|
||||
recursive_inline: { <<: *head_inline, c: { <<: *foo2 } }
|
||||
php: |
|
||||
array(
|
||||
'foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull'),
|
||||
'bar' => array('a' => 'before', 'd' => 'other', 'e' => null, 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'x' => 'Oren'),
|
||||
'bar_inline' => array('a' => 'before', 'd' => 'other', 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'e' => 'notnull', 'x' => 'Oren'),
|
||||
'foo2' => array('a' => 'Ballmer'),
|
||||
'ding' => array('fi', 'fei', 'fo', 'fam'),
|
||||
'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'),
|
||||
'head' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
|
||||
'taz' => array('a' => 'Steve', 'w' => array('p' => 1234)),
|
||||
'nested' => array('a' => 'Steve', 'w' => array('p' => 12345), 'd' => 'Doug', 'z' => array('p' => 12345)),
|
||||
'head_inline' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
|
||||
'recursive_inline' => array('a' => 'Steve', 'b' => 'Clark', 'c' => array('a' => 'Ballmer'), 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
|
||||
)
|
11
vendor/symfony/yaml/Tests/Fixtures/sfObjects.yml
vendored
11
vendor/symfony/yaml/Tests/Fixtures/sfObjects.yml
vendored
@@ -1,11 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Objects
|
||||
brief: >
|
||||
Comments at the end of a line
|
||||
yaml: |
|
||||
ex1: "foo # bar"
|
||||
ex2: "foo # bar" # comment
|
||||
ex3: 'foo # bar' # comment
|
||||
ex4: foo # comment
|
||||
php: |
|
||||
array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo')
|
33
vendor/symfony/yaml/Tests/Fixtures/sfQuotes.yml
vendored
33
vendor/symfony/yaml/Tests/Fixtures/sfQuotes.yml
vendored
@@ -1,33 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Some characters at the beginning of a string must be escaped
|
||||
brief: >
|
||||
Some characters at the beginning of a string must be escaped
|
||||
yaml: |
|
||||
foo: '| bar'
|
||||
php: |
|
||||
array('foo' => '| bar')
|
||||
---
|
||||
test: A key can be a quoted string
|
||||
brief: >
|
||||
A key can be a quoted string
|
||||
yaml: |
|
||||
"foo1": bar
|
||||
'foo2': bar
|
||||
"foo \" bar": bar
|
||||
'foo '' bar': bar
|
||||
'foo3: ': bar
|
||||
"foo4: ": bar
|
||||
foo5: { "foo \" bar: ": bar, 'foo '' bar: ': bar }
|
||||
php: |
|
||||
array(
|
||||
'foo1' => 'bar',
|
||||
'foo2' => 'bar',
|
||||
'foo " bar' => 'bar',
|
||||
'foo \' bar' => 'bar',
|
||||
'foo3: ' => 'bar',
|
||||
'foo4: ' => 'bar',
|
||||
'foo5' => array(
|
||||
'foo " bar: ' => 'bar',
|
||||
'foo \' bar: ' => 'bar',
|
||||
),
|
||||
)
|
140
vendor/symfony/yaml/Tests/Fixtures/sfTests.yml
vendored
140
vendor/symfony/yaml/Tests/Fixtures/sfTests.yml
vendored
@@ -1,140 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Multiple quoted string on one line
|
||||
brief: >
|
||||
Multiple quoted string on one line
|
||||
yaml: |
|
||||
stripped_title: { name: "foo bar", help: "bar foo" }
|
||||
php: |
|
||||
array('stripped_title' => array('name' => 'foo bar', 'help' => 'bar foo'))
|
||||
---
|
||||
test: Empty sequence
|
||||
yaml: |
|
||||
foo: [ ]
|
||||
php: |
|
||||
array('foo' => array())
|
||||
---
|
||||
test: Empty value
|
||||
yaml: |
|
||||
foo:
|
||||
php: |
|
||||
array('foo' => null)
|
||||
---
|
||||
test: Inline string parsing
|
||||
brief: >
|
||||
Inline string parsing
|
||||
yaml: |
|
||||
test: ['complex: string', 'another [string]']
|
||||
php: |
|
||||
array('test' => array('complex: string', 'another [string]'))
|
||||
---
|
||||
test: Boolean
|
||||
brief: >
|
||||
Boolean
|
||||
yaml: |
|
||||
- false
|
||||
- true
|
||||
- null
|
||||
- ~
|
||||
- 'false'
|
||||
- 'true'
|
||||
- 'null'
|
||||
- '~'
|
||||
php: |
|
||||
array(
|
||||
false,
|
||||
true,
|
||||
null,
|
||||
null,
|
||||
'false',
|
||||
'true',
|
||||
'null',
|
||||
'~',
|
||||
)
|
||||
---
|
||||
test: Empty lines in literal blocks
|
||||
brief: >
|
||||
Empty lines in literal blocks
|
||||
yaml: |
|
||||
foo:
|
||||
bar: |
|
||||
foo
|
||||
|
||||
|
||||
|
||||
bar
|
||||
php: |
|
||||
array('foo' => array('bar' => "foo\n\n\n \nbar\n"))
|
||||
---
|
||||
test: Empty lines in folded blocks
|
||||
brief: >
|
||||
Empty lines in folded blocks
|
||||
yaml: |
|
||||
foo:
|
||||
bar: >
|
||||
|
||||
foo
|
||||
|
||||
|
||||
bar
|
||||
php: |
|
||||
array('foo' => array('bar' => "\nfoo\n\nbar\n"))
|
||||
---
|
||||
test: IP addresses
|
||||
brief: >
|
||||
IP addresses
|
||||
yaml: |
|
||||
foo: 10.0.0.2
|
||||
php: |
|
||||
array('foo' => '10.0.0.2')
|
||||
---
|
||||
test: A sequence with an embedded mapping
|
||||
brief: >
|
||||
A sequence with an embedded mapping
|
||||
yaml: |
|
||||
- foo
|
||||
- bar: { bar: foo }
|
||||
php: |
|
||||
array('foo', array('bar' => array('bar' => 'foo')))
|
||||
---
|
||||
test: Octal
|
||||
brief: as in spec example 2.19, octal value is converted
|
||||
yaml: |
|
||||
foo: 0123
|
||||
php: |
|
||||
array('foo' => 83)
|
||||
---
|
||||
test: Octal strings
|
||||
brief: Octal notation in a string must remain a string
|
||||
yaml: |
|
||||
foo: "0123"
|
||||
php: |
|
||||
array('foo' => '0123')
|
||||
---
|
||||
test: Octal strings
|
||||
brief: Octal notation in a string must remain a string
|
||||
yaml: |
|
||||
foo: '0123'
|
||||
php: |
|
||||
array('foo' => '0123')
|
||||
---
|
||||
test: Octal strings
|
||||
brief: Octal notation in a string must remain a string
|
||||
yaml: |
|
||||
foo: |
|
||||
0123
|
||||
php: |
|
||||
array('foo' => "0123\n")
|
||||
---
|
||||
test: Document as a simple hash
|
||||
brief: Document as a simple hash
|
||||
yaml: |
|
||||
{ foo: bar }
|
||||
php: |
|
||||
array('foo' => 'bar')
|
||||
---
|
||||
test: Document as a simple array
|
||||
brief: Document as a simple array
|
||||
yaml: |
|
||||
[ foo, bar ]
|
||||
php: |
|
||||
array('foo', 'bar')
|
@@ -1,82 +0,0 @@
|
||||
--- %YAML:1.0
|
||||
test: Unindented collection
|
||||
brief: >
|
||||
Unindented collection
|
||||
yaml: |
|
||||
collection:
|
||||
- item1
|
||||
- item2
|
||||
- item3
|
||||
php: |
|
||||
array('collection' => array('item1', 'item2', 'item3'))
|
||||
---
|
||||
test: Nested unindented collection (two levels)
|
||||
brief: >
|
||||
Nested unindented collection
|
||||
yaml: |
|
||||
collection:
|
||||
key:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
php: |
|
||||
array('collection' => array('key' => array('a', 'b', 'c')))
|
||||
---
|
||||
test: Nested unindented collection (three levels)
|
||||
brief: >
|
||||
Nested unindented collection
|
||||
yaml: |
|
||||
collection:
|
||||
key:
|
||||
subkey:
|
||||
- one
|
||||
- two
|
||||
- three
|
||||
php: |
|
||||
array('collection' => array('key' => array('subkey' => array('one', 'two', 'three'))))
|
||||
---
|
||||
test: Key/value after unindented collection (1)
|
||||
brief: >
|
||||
Key/value after unindented collection (1)
|
||||
yaml: |
|
||||
collection:
|
||||
key:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
foo: bar
|
||||
php: |
|
||||
array('collection' => array('key' => array('a', 'b', 'c')), 'foo' => 'bar')
|
||||
---
|
||||
test: Key/value after unindented collection (at the same level)
|
||||
brief: >
|
||||
Key/value after unindented collection
|
||||
yaml: |
|
||||
collection:
|
||||
key:
|
||||
- a
|
||||
- b
|
||||
- c
|
||||
foo: bar
|
||||
php: |
|
||||
array('collection' => array('key' => array('a', 'b', 'c'), 'foo' => 'bar'))
|
||||
---
|
||||
test: Shortcut Key after unindented collection
|
||||
brief: >
|
||||
Key/value after unindented collection
|
||||
yaml: |
|
||||
collection:
|
||||
- key: foo
|
||||
foo: bar
|
||||
php: |
|
||||
array('collection' => array(array('key' => 'foo', 'foo' => 'bar')))
|
||||
---
|
||||
test: Shortcut Key after unindented collection with custom spaces
|
||||
brief: >
|
||||
Key/value after unindented collection
|
||||
yaml: |
|
||||
collection:
|
||||
- key: foo
|
||||
foo: bar
|
||||
php: |
|
||||
array('collection' => array(array('key' => 'foo', 'foo' => 'bar')))
|
760
vendor/symfony/yaml/Tests/InlineTest.php
vendored
760
vendor/symfony/yaml/Tests/InlineTest.php
vendored
@@ -1,760 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Inline;
|
||||
use Symfony\Component\Yaml\Tag\TaggedValue;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class InlineTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
Inline::initialize(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestsForParse
|
||||
*/
|
||||
public function testParse($yaml, $value, $flags = 0)
|
||||
{
|
||||
$this->assertSame($value, Inline::parse($yaml, $flags), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestsForParseWithMapObjects
|
||||
*/
|
||||
public function testParseWithMapObjects($yaml, $value, $flags = Yaml::PARSE_OBJECT_FOR_MAP)
|
||||
{
|
||||
$actual = Inline::parse($yaml, $flags);
|
||||
|
||||
$this->assertSame(serialize($value), serialize($actual));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestsForParsePhpConstants
|
||||
*/
|
||||
public function testParsePhpConstants($yaml, $value)
|
||||
{
|
||||
$actual = Inline::parse($yaml, Yaml::PARSE_CONSTANT);
|
||||
|
||||
$this->assertSame($value, $actual);
|
||||
}
|
||||
|
||||
public function getTestsForParsePhpConstants()
|
||||
{
|
||||
return array(
|
||||
array('!php/const Symfony\Component\Yaml\Yaml::PARSE_CONSTANT', Yaml::PARSE_CONSTANT),
|
||||
array('!php/const PHP_INT_MAX', PHP_INT_MAX),
|
||||
array('[!php/const PHP_INT_MAX]', array(PHP_INT_MAX)),
|
||||
array('{ foo: !php/const PHP_INT_MAX }', array('foo' => PHP_INT_MAX)),
|
||||
array('!php/const NULL', null),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage The constant "WRONG_CONSTANT" is not defined
|
||||
*/
|
||||
public function testParsePhpConstantThrowsExceptionWhenUndefined()
|
||||
{
|
||||
Inline::parse('!php/const WRONG_CONSTANT', Yaml::PARSE_CONSTANT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessageRegExp #The string "!php/const PHP_INT_MAX" could not be parsed as a constant.*#
|
||||
*/
|
||||
public function testParsePhpConstantThrowsExceptionOnInvalidType()
|
||||
{
|
||||
Inline::parse('!php/const PHP_INT_MAX', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestsForDump
|
||||
*/
|
||||
public function testDump($yaml, $value, $parseFlags = 0)
|
||||
{
|
||||
$this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml));
|
||||
|
||||
$this->assertSame($value, Inline::parse(Inline::dump($value), $parseFlags), 'check consistency');
|
||||
}
|
||||
|
||||
public function testDumpNumericValueWithLocale()
|
||||
{
|
||||
$locale = setlocale(LC_NUMERIC, 0);
|
||||
if (false === $locale) {
|
||||
$this->markTestSkipped('Your platform does not support locales.');
|
||||
}
|
||||
|
||||
try {
|
||||
$requiredLocales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252');
|
||||
if (false === setlocale(LC_NUMERIC, $requiredLocales)) {
|
||||
$this->markTestSkipped('Could not set any of required locales: '.implode(', ', $requiredLocales));
|
||||
}
|
||||
|
||||
$this->assertEquals('1.2', Inline::dump(1.2));
|
||||
$this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0)));
|
||||
} finally {
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
}
|
||||
}
|
||||
|
||||
public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF()
|
||||
{
|
||||
$value = '686e444';
|
||||
|
||||
$this->assertSame($value, Inline::parse(Inline::dump($value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage Found unknown escape character "\V".
|
||||
*/
|
||||
public function testParseScalarWithNonEscapedBlackslashShouldThrowException()
|
||||
{
|
||||
Inline::parse('"Foo\Var"');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException()
|
||||
{
|
||||
Inline::parse('"Foo\\"');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException()
|
||||
{
|
||||
$value = "'don't do somthin' like that'";
|
||||
Inline::parse($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException()
|
||||
{
|
||||
$value = '"don"t do somthin" like that"';
|
||||
Inline::parse($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseInvalidMappingKeyShouldThrowException()
|
||||
{
|
||||
$value = '{ "foo " bar": "bar" }';
|
||||
Inline::parse($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage Colons must be followed by a space or an indication character (i.e. " ", ",", "[", "]", "{", "}")
|
||||
*/
|
||||
public function testParseMappingKeyWithColonNotFollowedBySpace()
|
||||
{
|
||||
Inline::parse('{foo:""}');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseInvalidMappingShouldThrowException()
|
||||
{
|
||||
Inline::parse('[foo] bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseInvalidSequenceShouldThrowException()
|
||||
{
|
||||
Inline::parse('{ foo: bar } bar');
|
||||
}
|
||||
|
||||
public function testParseScalarWithCorrectlyQuotedStringShouldReturnString()
|
||||
{
|
||||
$value = "'don''t do somthin'' like that'";
|
||||
$expect = "don't do somthin' like that";
|
||||
|
||||
$this->assertSame($expect, Inline::parseScalar($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDataForParseReferences
|
||||
*/
|
||||
public function testParseReferences($yaml, $expected)
|
||||
{
|
||||
$this->assertSame($expected, Inline::parse($yaml, 0, array('var' => 'var-value')));
|
||||
}
|
||||
|
||||
public function getDataForParseReferences()
|
||||
{
|
||||
return array(
|
||||
'scalar' => array('*var', 'var-value'),
|
||||
'list' => array('[ *var ]', array('var-value')),
|
||||
'list-in-list' => array('[[ *var ]]', array(array('var-value'))),
|
||||
'map-in-list' => array('[ { key: *var } ]', array(array('key' => 'var-value'))),
|
||||
'embedded-mapping-in-list' => array('[ key: *var ]', array(array('key' => 'var-value'))),
|
||||
'map' => array('{ key: *var }', array('key' => 'var-value')),
|
||||
'list-in-map' => array('{ key: [*var] }', array('key' => array('var-value'))),
|
||||
'map-in-map' => array('{ foo: { bar: *var } }', array('foo' => array('bar' => 'var-value'))),
|
||||
);
|
||||
}
|
||||
|
||||
public function testParseMapReferenceInSequence()
|
||||
{
|
||||
$foo = array(
|
||||
'a' => 'Steve',
|
||||
'b' => 'Clark',
|
||||
'c' => 'Brian',
|
||||
);
|
||||
$this->assertSame(array($foo), Inline::parse('[*foo]', 0, array('foo' => $foo)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage A reference must contain at least one character at line 1.
|
||||
*/
|
||||
public function testParseUnquotedAsterisk()
|
||||
{
|
||||
Inline::parse('{ foo: * }');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage A reference must contain at least one character at line 1.
|
||||
*/
|
||||
public function testParseUnquotedAsteriskFollowedByAComment()
|
||||
{
|
||||
Inline::parse('{ foo: * #foo }');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getReservedIndicators
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
|
||||
{
|
||||
if (method_exists($this, 'expectExceptionMessage')) {
|
||||
$this->expectException(ParseException::class);
|
||||
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
|
||||
} else {
|
||||
$this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
|
||||
}
|
||||
|
||||
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
||||
}
|
||||
|
||||
public function getReservedIndicators()
|
||||
{
|
||||
return array(array('@'), array('`'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getScalarIndicators
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
|
||||
{
|
||||
if (method_exists($this, 'expectExceptionMessage')) {
|
||||
$this->expectException(ParseException::class);
|
||||
$this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
|
||||
} else {
|
||||
$this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo").', $indicator));
|
||||
}
|
||||
|
||||
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
||||
}
|
||||
|
||||
public function getScalarIndicators()
|
||||
{
|
||||
return array(array('|'), array('>'), array('%'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDataForIsHash
|
||||
*/
|
||||
public function testIsHash($array, $expected)
|
||||
{
|
||||
$this->assertSame($expected, Inline::isHash($array));
|
||||
}
|
||||
|
||||
public function getDataForIsHash()
|
||||
{
|
||||
return array(
|
||||
array(array(), false),
|
||||
array(array(1, 2, 3), false),
|
||||
array(array(2 => 1, 1 => 2, 0 => 3), true),
|
||||
array(array('foo' => 1, 'bar' => 2), true),
|
||||
);
|
||||
}
|
||||
|
||||
public function getTestsForParse()
|
||||
{
|
||||
return array(
|
||||
array('', ''),
|
||||
array('null', null),
|
||||
array('false', false),
|
||||
array('true', true),
|
||||
array('12', 12),
|
||||
array('-12', -12),
|
||||
array('1_2', 12),
|
||||
array('_12', '_12'),
|
||||
array('12_', 12),
|
||||
array('"quoted string"', 'quoted string'),
|
||||
array("'quoted string'", 'quoted string'),
|
||||
array('12.30e+02', 12.30e+02),
|
||||
array('123.45_67', 123.4567),
|
||||
array('0x4D2', 0x4D2),
|
||||
array('0x_4_D_2_', 0x4D2),
|
||||
array('02333', 02333),
|
||||
array('0_2_3_3_3', 02333),
|
||||
array('.Inf', -log(0)),
|
||||
array('-.Inf', log(0)),
|
||||
array("'686e444'", '686e444'),
|
||||
array('686e444', 646e444),
|
||||
array('123456789123456789123456789123456789', '123456789123456789123456789123456789'),
|
||||
array('"foo\r\nbar"', "foo\r\nbar"),
|
||||
array("'foo#bar'", 'foo#bar'),
|
||||
array("'foo # bar'", 'foo # bar'),
|
||||
array("'#cfcfcf'", '#cfcfcf'),
|
||||
array('::form_base.html.twig', '::form_base.html.twig'),
|
||||
|
||||
// Pre-YAML-1.2 booleans
|
||||
array("'y'", 'y'),
|
||||
array("'n'", 'n'),
|
||||
array("'yes'", 'yes'),
|
||||
array("'no'", 'no'),
|
||||
array("'on'", 'on'),
|
||||
array("'off'", 'off'),
|
||||
|
||||
array('2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)),
|
||||
array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)),
|
||||
array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)),
|
||||
array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)),
|
||||
array('1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)),
|
||||
|
||||
array('"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''),
|
||||
array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
|
||||
|
||||
// sequences
|
||||
// urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon
|
||||
array('[foo, http://urls.are/no/mappings, false, null, 12]', array('foo', 'http://urls.are/no/mappings', false, null, 12)),
|
||||
array('[ foo , bar , false , null , 12 ]', array('foo', 'bar', false, null, 12)),
|
||||
array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
|
||||
|
||||
// mappings
|
||||
array('{foo: bar,bar: foo,"false": false, "null": null,integer: 12}', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
|
||||
array('{ foo : bar, bar : foo, "false" : false, "null" : null, integer : 12 }', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
|
||||
array('{foo: \'bar\', bar: \'foo: bar\'}', array('foo' => 'bar', 'bar' => 'foo: bar')),
|
||||
array('{\'foo\': \'bar\', "bar": \'foo: bar\'}', array('foo' => 'bar', 'bar' => 'foo: bar')),
|
||||
array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', array('foo\'' => 'bar', 'bar"' => 'foo: bar')),
|
||||
array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', array('foo: ' => 'bar', 'bar: ' => 'foo: bar')),
|
||||
array('{"foo:bar": "baz"}', array('foo:bar' => 'baz')),
|
||||
array('{"foo":"bar"}', array('foo' => 'bar')),
|
||||
|
||||
// nested sequences and mappings
|
||||
array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
|
||||
array('[foo, {bar: foo}]', array('foo', array('bar' => 'foo'))),
|
||||
array('{ foo: {bar: foo} }', array('foo' => array('bar' => 'foo'))),
|
||||
array('{ foo: [bar, foo] }', array('foo' => array('bar', 'foo'))),
|
||||
array('{ foo:{bar: foo} }', array('foo' => array('bar' => 'foo'))),
|
||||
array('{ foo:[bar, foo] }', array('foo' => array('bar', 'foo'))),
|
||||
|
||||
array('[ foo, [ bar, foo ] ]', array('foo', array('bar', 'foo'))),
|
||||
|
||||
array('[{ foo: {bar: foo} }]', array(array('foo' => array('bar' => 'foo')))),
|
||||
|
||||
array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
|
||||
|
||||
array('[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo')))),
|
||||
|
||||
array('[foo, bar: { foo: bar }]', array('foo', '1' => array('bar' => array('foo' => 'bar')))),
|
||||
array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
|
||||
);
|
||||
}
|
||||
|
||||
public function getTestsForParseWithMapObjects()
|
||||
{
|
||||
return array(
|
||||
array('', ''),
|
||||
array('null', null),
|
||||
array('false', false),
|
||||
array('true', true),
|
||||
array('12', 12),
|
||||
array('-12', -12),
|
||||
array('"quoted string"', 'quoted string'),
|
||||
array("'quoted string'", 'quoted string'),
|
||||
array('12.30e+02', 12.30e+02),
|
||||
array('0x4D2', 0x4D2),
|
||||
array('02333', 02333),
|
||||
array('.Inf', -log(0)),
|
||||
array('-.Inf', log(0)),
|
||||
array("'686e444'", '686e444'),
|
||||
array('686e444', 646e444),
|
||||
array('123456789123456789123456789123456789', '123456789123456789123456789123456789'),
|
||||
array('"foo\r\nbar"', "foo\r\nbar"),
|
||||
array("'foo#bar'", 'foo#bar'),
|
||||
array("'foo # bar'", 'foo # bar'),
|
||||
array("'#cfcfcf'", '#cfcfcf'),
|
||||
array('::form_base.html.twig', '::form_base.html.twig'),
|
||||
|
||||
array('2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)),
|
||||
array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)),
|
||||
array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)),
|
||||
array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)),
|
||||
array('1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)),
|
||||
|
||||
array('"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''),
|
||||
array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
|
||||
|
||||
// sequences
|
||||
// urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon
|
||||
array('[foo, http://urls.are/no/mappings, false, null, 12]', array('foo', 'http://urls.are/no/mappings', false, null, 12)),
|
||||
array('[ foo , bar , false , null , 12 ]', array('foo', 'bar', false, null, 12)),
|
||||
array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
|
||||
|
||||
// mappings
|
||||
array('{foo: bar,bar: foo,"false": false,"null": null,integer: 12}', (object) array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), Yaml::PARSE_OBJECT_FOR_MAP),
|
||||
array('{ foo : bar, bar : foo, "false" : false, "null" : null, integer : 12 }', (object) array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), Yaml::PARSE_OBJECT_FOR_MAP),
|
||||
array('{foo: \'bar\', bar: \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')),
|
||||
array('{\'foo\': \'bar\', "bar": \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')),
|
||||
array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', (object) array('foo\'' => 'bar', 'bar"' => 'foo: bar')),
|
||||
array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', (object) array('foo: ' => 'bar', 'bar: ' => 'foo: bar')),
|
||||
array('{"foo:bar": "baz"}', (object) array('foo:bar' => 'baz')),
|
||||
array('{"foo":"bar"}', (object) array('foo' => 'bar')),
|
||||
|
||||
// nested sequences and mappings
|
||||
array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
|
||||
array('[foo, {bar: foo}]', array('foo', (object) array('bar' => 'foo'))),
|
||||
array('{ foo: {bar: foo} }', (object) array('foo' => (object) array('bar' => 'foo'))),
|
||||
array('{ foo: [bar, foo] }', (object) array('foo' => array('bar', 'foo'))),
|
||||
|
||||
array('[ foo, [ bar, foo ] ]', array('foo', array('bar', 'foo'))),
|
||||
|
||||
array('[{ foo: {bar: foo} }]', array((object) array('foo' => (object) array('bar' => 'foo')))),
|
||||
|
||||
array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
|
||||
|
||||
array('[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', array('foo', (object) array('bar' => 'foo', 'foo' => array('foo', (object) array('bar' => 'foo'))), array('foo', (object) array('bar' => 'foo')))),
|
||||
|
||||
array('[foo, bar: { foo: bar }]', array('foo', '1' => (object) array('bar' => (object) array('foo' => 'bar')))),
|
||||
array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', (object) array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
|
||||
|
||||
array('{}', new \stdClass()),
|
||||
array('{ foo : bar, bar : {} }', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
|
||||
array('{ foo : [], bar : {} }', (object) array('foo' => array(), 'bar' => new \stdClass())),
|
||||
array('{foo: \'bar\', bar: {} }', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
|
||||
array('{\'foo\': \'bar\', "bar": {}}', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
|
||||
array('{\'foo\': \'bar\', "bar": \'{}\'}', (object) array('foo' => 'bar', 'bar' => '{}')),
|
||||
|
||||
array('[foo, [{}, {}]]', array('foo', array(new \stdClass(), new \stdClass()))),
|
||||
array('[foo, [[], {}]]', array('foo', array(array(), new \stdClass()))),
|
||||
array('[foo, [[{}, {}], {}]]', array('foo', array(array(new \stdClass(), new \stdClass()), new \stdClass()))),
|
||||
array('[foo, {bar: {}}]', array('foo', '1' => (object) array('bar' => new \stdClass()))),
|
||||
);
|
||||
}
|
||||
|
||||
public function getTestsForDump()
|
||||
{
|
||||
return array(
|
||||
array('null', null),
|
||||
array('false', false),
|
||||
array('true', true),
|
||||
array('12', 12),
|
||||
array("'1_2'", '1_2'),
|
||||
array('_12', '_12'),
|
||||
array("'12_'", '12_'),
|
||||
array("'quoted string'", 'quoted string'),
|
||||
array('!!float 1230', 12.30e+02),
|
||||
array('1234', 0x4D2),
|
||||
array('1243', 02333),
|
||||
array("'0x_4_D_2_'", '0x_4_D_2_'),
|
||||
array("'0_2_3_3_3'", '0_2_3_3_3'),
|
||||
array('.Inf', -log(0)),
|
||||
array('-.Inf', log(0)),
|
||||
array("'686e444'", '686e444'),
|
||||
array('"foo\r\nbar"', "foo\r\nbar"),
|
||||
array("'foo#bar'", 'foo#bar'),
|
||||
array("'foo # bar'", 'foo # bar'),
|
||||
array("'#cfcfcf'", '#cfcfcf'),
|
||||
|
||||
array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
|
||||
|
||||
array("'-dash'", '-dash'),
|
||||
array("'-'", '-'),
|
||||
|
||||
// Pre-YAML-1.2 booleans
|
||||
array("'y'", 'y'),
|
||||
array("'n'", 'n'),
|
||||
array("'yes'", 'yes'),
|
||||
array("'no'", 'no'),
|
||||
array("'on'", 'on'),
|
||||
array("'off'", 'off'),
|
||||
|
||||
// sequences
|
||||
array('[foo, bar, false, null, 12]', array('foo', 'bar', false, null, 12)),
|
||||
array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
|
||||
|
||||
// mappings
|
||||
array('{ foo: bar, bar: foo, \'false\': false, \'null\': null, integer: 12 }', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
|
||||
array('{ foo: bar, bar: \'foo: bar\' }', array('foo' => 'bar', 'bar' => 'foo: bar')),
|
||||
|
||||
// nested sequences and mappings
|
||||
array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
|
||||
|
||||
array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
|
||||
|
||||
array('{ foo: { bar: foo } }', array('foo' => array('bar' => 'foo'))),
|
||||
|
||||
array('[foo, { bar: foo }]', array('foo', array('bar' => 'foo'))),
|
||||
|
||||
array('[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]', array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo')))),
|
||||
|
||||
array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
|
||||
|
||||
array('{ foo: { bar: { 1: 2, baz: 3 } } }', array('foo' => array('bar' => array(1 => 2, 'baz' => 3)))),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTimestampTests
|
||||
*/
|
||||
public function testParseTimestampAsUnixTimestampByDefault($yaml, $year, $month, $day, $hour, $minute, $second)
|
||||
{
|
||||
$this->assertSame(gmmktime($hour, $minute, $second, $month, $day, $year), Inline::parse($yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTimestampTests
|
||||
*/
|
||||
public function testParseTimestampAsDateTimeObject($yaml, $year, $month, $day, $hour, $minute, $second, $timezone)
|
||||
{
|
||||
$expected = new \DateTime($yaml);
|
||||
$expected->setTimeZone(new \DateTimeZone('UTC'));
|
||||
$expected->setDate($year, $month, $day);
|
||||
$expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second));
|
||||
|
||||
$date = Inline::parse($yaml, Yaml::PARSE_DATETIME);
|
||||
$this->assertEquals($expected, $date);
|
||||
$this->assertSame($timezone, $date->format('O'));
|
||||
}
|
||||
|
||||
public function getTimestampTests()
|
||||
{
|
||||
return array(
|
||||
'canonical' => array('2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43.1, '+0000'),
|
||||
'ISO-8601' => array('2001-12-15t21:59:43.10-05:00', 2001, 12, 16, 2, 59, 43.1, '-0500'),
|
||||
'spaced' => array('2001-12-15 21:59:43.10 -5', 2001, 12, 16, 2, 59, 43.1, '-0500'),
|
||||
'date' => array('2001-12-15', 2001, 12, 15, 0, 0, 0, '+0000'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTimestampTests
|
||||
*/
|
||||
public function testParseNestedTimestampListAsDateTimeObject($yaml, $year, $month, $day, $hour, $minute, $second)
|
||||
{
|
||||
$expected = new \DateTime($yaml);
|
||||
$expected->setTimeZone(new \DateTimeZone('UTC'));
|
||||
$expected->setDate($year, $month, $day);
|
||||
$expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second));
|
||||
|
||||
$expectedNested = array('nested' => array($expected));
|
||||
$yamlNested = "{nested: [$yaml]}";
|
||||
|
||||
$this->assertEquals($expectedNested, Inline::parse($yamlNested, Yaml::PARSE_DATETIME));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getDateTimeDumpTests
|
||||
*/
|
||||
public function testDumpDateTime($dateTime, $expected)
|
||||
{
|
||||
$this->assertSame($expected, Inline::dump($dateTime));
|
||||
}
|
||||
|
||||
public function getDateTimeDumpTests()
|
||||
{
|
||||
$tests = array();
|
||||
|
||||
$dateTime = new \DateTime('2001-12-15 21:59:43', new \DateTimeZone('UTC'));
|
||||
$tests['date-time-utc'] = array($dateTime, '2001-12-15T21:59:43+00:00');
|
||||
|
||||
$dateTime = new \DateTimeImmutable('2001-07-15 21:59:43', new \DateTimeZone('Europe/Berlin'));
|
||||
$tests['immutable-date-time-europe-berlin'] = array($dateTime, '2001-07-15T21:59:43+02:00');
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getBinaryData
|
||||
*/
|
||||
public function testParseBinaryData($data)
|
||||
{
|
||||
$this->assertSame('Hello world', Inline::parse($data));
|
||||
}
|
||||
|
||||
public function getBinaryData()
|
||||
{
|
||||
return array(
|
||||
'enclosed with double quotes' => array('!!binary "SGVsbG8gd29ybGQ="'),
|
||||
'enclosed with single quotes' => array("!!binary 'SGVsbG8gd29ybGQ='"),
|
||||
'containing spaces' => array('!!binary "SGVs bG8gd 29ybGQ="'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidBinaryData
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseInvalidBinaryData($data, $expectedMessage)
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectExceptionMessageRegExp($expectedMessage);
|
||||
} else {
|
||||
$this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage);
|
||||
}
|
||||
|
||||
Inline::parse($data);
|
||||
}
|
||||
|
||||
public function getInvalidBinaryData()
|
||||
{
|
||||
return array(
|
||||
'length not a multiple of four' => array('!!binary "SGVsbG8d29ybGQ="', '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/'),
|
||||
'invalid characters' => array('!!binary "SGVsbG8#d29ybGQ="', '/The base64 encoded data \(.*\) contains invalid characters/'),
|
||||
'too many equals characters' => array('!!binary "SGVsbG8gd29yb==="', '/The base64 encoded data \(.*\) contains invalid characters/'),
|
||||
'misplaced equals character' => array('!!binary "SGVsbG8gd29ybG=Q"', '/The base64 encoded data \(.*\) contains invalid characters/'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported} at line 1.
|
||||
*/
|
||||
public function testNotSupportedMissingValue()
|
||||
{
|
||||
Inline::parse('{this, is not, supported}');
|
||||
}
|
||||
|
||||
public function testVeryLongQuotedStrings()
|
||||
{
|
||||
$longStringWithQuotes = str_repeat("x\r\n\\\"x\"x", 1000);
|
||||
|
||||
$yamlString = Inline::dump(array('longStringWithQuotes' => $longStringWithQuotes));
|
||||
$arrayFromYaml = Inline::parse($yamlString);
|
||||
|
||||
$this->assertEquals($longStringWithQuotes, $arrayFromYaml['longStringWithQuotes']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage Missing mapping key
|
||||
*/
|
||||
public function testMappingKeysCannotBeOmitted()
|
||||
{
|
||||
Inline::parse('{: foo}');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestsForNullValues
|
||||
*/
|
||||
public function testParseMissingMappingValueAsNull($yaml, $expected)
|
||||
{
|
||||
$this->assertSame($expected, Inline::parse($yaml));
|
||||
}
|
||||
|
||||
public function getTestsForNullValues()
|
||||
{
|
||||
return array(
|
||||
'null before closing curly brace' => array('{foo:}', array('foo' => null)),
|
||||
'null before comma' => array('{foo:, bar: baz}', array('foo' => null, 'bar' => 'baz')),
|
||||
);
|
||||
}
|
||||
|
||||
public function testTheEmptyStringIsAValidMappingKey()
|
||||
{
|
||||
$this->assertSame(array('' => 'foo'), Inline::parse('{ "": foo }'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage Implicit casting of incompatible mapping keys to strings is not supported. Quote your evaluable mapping keys instead
|
||||
*
|
||||
* @dataProvider getNotPhpCompatibleMappingKeyData
|
||||
*/
|
||||
public function testImplicitStringCastingOfMappingKeysIsDeprecated($yaml, $expected)
|
||||
{
|
||||
$this->assertSame($expected, Inline::parse($yaml));
|
||||
}
|
||||
|
||||
public function getNotPhpCompatibleMappingKeyData()
|
||||
{
|
||||
return array(
|
||||
'boolean-true' => array('{true: "foo"}', array('true' => 'foo')),
|
||||
'boolean-false' => array('{false: "foo"}', array('false' => 'foo')),
|
||||
'null' => array('{null: "foo"}', array('null' => 'foo')),
|
||||
'float' => array('{0.25: "foo"}', array('0.25' => 'foo')),
|
||||
);
|
||||
}
|
||||
|
||||
public function testTagWithoutValueInSequence()
|
||||
{
|
||||
$value = Inline::parse('[!foo]', Yaml::PARSE_CUSTOM_TAGS);
|
||||
|
||||
$this->assertInstanceOf(TaggedValue::class, $value[0]);
|
||||
$this->assertSame('foo', $value[0]->getTag());
|
||||
$this->assertSame('', $value[0]->getValue());
|
||||
}
|
||||
|
||||
public function testTagWithEmptyValueInSequence()
|
||||
{
|
||||
$value = Inline::parse('[!foo ""]', Yaml::PARSE_CUSTOM_TAGS);
|
||||
|
||||
$this->assertInstanceOf(TaggedValue::class, $value[0]);
|
||||
$this->assertSame('foo', $value[0]->getTag());
|
||||
$this->assertSame('', $value[0]->getValue());
|
||||
}
|
||||
|
||||
public function testTagWithoutValueInMapping()
|
||||
{
|
||||
$value = Inline::parse('{foo: !bar}', Yaml::PARSE_CUSTOM_TAGS);
|
||||
|
||||
$this->assertInstanceOf(TaggedValue::class, $value['foo']);
|
||||
$this->assertSame('bar', $value['foo']->getTag());
|
||||
$this->assertSame('', $value['foo']->getValue());
|
||||
}
|
||||
|
||||
public function testTagWithEmptyValueInMapping()
|
||||
{
|
||||
$value = Inline::parse('{foo: !bar ""}', Yaml::PARSE_CUSTOM_TAGS);
|
||||
|
||||
$this->assertInstanceOf(TaggedValue::class, $value['foo']);
|
||||
$this->assertSame('bar', $value['foo']->getTag());
|
||||
$this->assertSame('', $value['foo']->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage Unexpected end of line, expected one of ",}" at line 1 (near "{abc: 'def'").
|
||||
*/
|
||||
public function testUnfinishedInlineMap()
|
||||
{
|
||||
Inline::parse("{abc: 'def'");
|
||||
}
|
||||
}
|
34
vendor/symfony/yaml/Tests/ParseExceptionTest.php
vendored
34
vendor/symfony/yaml/Tests/ParseExceptionTest.php
vendored
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
|
||||
class ParseExceptionTest extends TestCase
|
||||
{
|
||||
public function testGetMessage()
|
||||
{
|
||||
$exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
|
||||
$message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
|
||||
|
||||
$this->assertEquals($message, $exception->getMessage());
|
||||
}
|
||||
|
||||
public function testGetMessageWithUnicodeInFilename()
|
||||
{
|
||||
$exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml');
|
||||
$message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
|
||||
|
||||
$this->assertEquals($message, $exception->getMessage());
|
||||
}
|
||||
}
|
2108
vendor/symfony/yaml/Tests/ParserTest.php
vendored
2108
vendor/symfony/yaml/Tests/ParserTest.php
vendored
File diff suppressed because it is too large
Load Diff
44
vendor/symfony/yaml/Tests/YamlTest.php
vendored
44
vendor/symfony/yaml/Tests/YamlTest.php
vendored
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class YamlTest extends TestCase
|
||||
{
|
||||
public function testParseAndDump()
|
||||
{
|
||||
$data = array('lorem' => 'ipsum', 'dolor' => 'sit');
|
||||
$yml = Yaml::dump($data);
|
||||
$parsed = Yaml::parse($yml);
|
||||
$this->assertEquals($data, $parsed);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The indentation must be greater than zero
|
||||
*/
|
||||
public function testZeroIndentationThrowsException()
|
||||
{
|
||||
Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The indentation must be greater than zero
|
||||
*/
|
||||
public function testNegativeIndentationThrowsException()
|
||||
{
|
||||
Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, -4);
|
||||
}
|
||||
}
|
2
vendor/symfony/yaml/Unescaper.php
vendored
2
vendor/symfony/yaml/Unescaper.php
vendored
@@ -26,7 +26,7 @@ class Unescaper
|
||||
/**
|
||||
* Regex fragment that matches an escaped character in a double quoted string.
|
||||
*/
|
||||
const REGEX_ESCAPED_CHARACTER = '\\\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|.)';
|
||||
public const REGEX_ESCAPED_CHARACTER = '\\\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|.)';
|
||||
|
||||
/**
|
||||
* Unescapes a single quoted string.
|
||||
|
23
vendor/symfony/yaml/Yaml.php
vendored
23
vendor/symfony/yaml/Yaml.php
vendored
@@ -22,17 +22,18 @@ use Symfony\Component\Yaml\Exception\ParseException;
|
||||
*/
|
||||
class Yaml
|
||||
{
|
||||
const DUMP_OBJECT = 1;
|
||||
const PARSE_EXCEPTION_ON_INVALID_TYPE = 2;
|
||||
const PARSE_OBJECT = 4;
|
||||
const PARSE_OBJECT_FOR_MAP = 8;
|
||||
const DUMP_EXCEPTION_ON_INVALID_TYPE = 16;
|
||||
const PARSE_DATETIME = 32;
|
||||
const DUMP_OBJECT_AS_MAP = 64;
|
||||
const DUMP_MULTI_LINE_LITERAL_BLOCK = 128;
|
||||
const PARSE_CONSTANT = 256;
|
||||
const PARSE_CUSTOM_TAGS = 512;
|
||||
const DUMP_EMPTY_ARRAY_AS_SEQUENCE = 1024;
|
||||
public const DUMP_OBJECT = 1;
|
||||
public const PARSE_EXCEPTION_ON_INVALID_TYPE = 2;
|
||||
public const PARSE_OBJECT = 4;
|
||||
public const PARSE_OBJECT_FOR_MAP = 8;
|
||||
public const DUMP_EXCEPTION_ON_INVALID_TYPE = 16;
|
||||
public const PARSE_DATETIME = 32;
|
||||
public const DUMP_OBJECT_AS_MAP = 64;
|
||||
public const DUMP_MULTI_LINE_LITERAL_BLOCK = 128;
|
||||
public const PARSE_CONSTANT = 256;
|
||||
public const PARSE_CUSTOM_TAGS = 512;
|
||||
public const DUMP_EMPTY_ARRAY_AS_SEQUENCE = 1024;
|
||||
public const DUMP_NULL_AS_TILDE = 2048;
|
||||
|
||||
/**
|
||||
* Parses a YAML file into a PHP value.
|
||||
|
13
vendor/symfony/yaml/composer.json
vendored
13
vendor/symfony/yaml/composer.json
vendored
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"type": "library",
|
||||
"description": "Symfony Yaml Component",
|
||||
"description": "Loads and dumps YAML files",
|
||||
"keywords": [],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
@@ -16,11 +16,11 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"php": ">=7.1.3",
|
||||
"symfony/polyfill-ctype": "~1.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/console": "~3.4|~4.0"
|
||||
"symfony/console": "^3.4|^4.0|^5.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/console": "<3.4"
|
||||
@@ -34,10 +34,5 @@
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
}
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
|
30
vendor/symfony/yaml/phpunit.xml.dist
vendored
30
vendor/symfony/yaml/phpunit.xml.dist
vendored
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
failOnRisky="true"
|
||||
failOnWarning="true"
|
||||
>
|
||||
<php>
|
||||
<ini name="error_reporting" value="-1" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Symfony Yaml Component Test Suite">
|
||||
<directory>./Tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Tests</directory>
|
||||
<directory>./vendor</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
Reference in New Issue
Block a user