update2
This commit is contained in:
parent
98419bd18d
commit
8a69e45efa
4919 changed files with 28311 additions and 224136 deletions
0
pfosten/vendor/symfony/yaml/.gitignore
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/.gitignore
vendored
Executable file → Normal file
31
pfosten/vendor/symfony/yaml/CHANGELOG.md
vendored
Executable file → Normal file
31
pfosten/vendor/symfony/yaml/CHANGELOG.md
vendored
Executable file → Normal file
|
|
@ -1,6 +1,24 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
* added support for parsing YAML files using the `Yaml::parseFile()` or `Parser::parseFile()` method
|
||||
|
||||
* the `Dumper`, `Parser`, and `Yaml` classes are marked as final
|
||||
|
||||
* Deprecated the `!php/object:` tag which will be replaced by the
|
||||
`!php/object` tag (without the colon) in 4.0.
|
||||
|
||||
* Deprecated the `!php/const:` tag which will be replaced by the
|
||||
`!php/const` tag (without the colon) in 4.0.
|
||||
|
||||
* Support for the `!str` tag is deprecated, use the `!!str` tag instead.
|
||||
|
||||
* Deprecated using the non-specific tag `!` as its behavior will change in 4.0.
|
||||
It will force non-evaluating your values in 4.0. Use plain integers or `!!float` instead.
|
||||
|
||||
3.3.0
|
||||
-----
|
||||
|
||||
|
|
@ -9,8 +27,7 @@ CHANGELOG
|
|||
|
||||
* Deprecated support for implicitly parsing non-string mapping keys as strings.
|
||||
Mapping keys that are no strings will lead to a `ParseException` in Symfony
|
||||
4.0. Use the `PARSE_KEYS_AS_STRINGS` flag to opt-in for keys to be parsed as
|
||||
strings.
|
||||
4.0. Use quotes to opt-in for keys to be parsed as strings.
|
||||
|
||||
Before:
|
||||
|
||||
|
|
@ -18,7 +35,6 @@ CHANGELOG
|
|||
$yaml = <<<YAML
|
||||
null: null key
|
||||
true: boolean true
|
||||
1: integer key
|
||||
2.0: float key
|
||||
YAML;
|
||||
|
||||
|
|
@ -30,13 +46,12 @@ CHANGELOG
|
|||
```php
|
||||
|
||||
$yaml = <<<YAML
|
||||
null: null key
|
||||
true: boolean true
|
||||
1: integer key
|
||||
2.0: float key
|
||||
"null": null key
|
||||
"true": boolean true
|
||||
"2.0": float key
|
||||
YAML;
|
||||
|
||||
Yaml::parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS);
|
||||
Yaml::parse($yaml);
|
||||
```
|
||||
|
||||
* Omitted mapping values will be parsed as `null`.
|
||||
|
|
|
|||
36
pfosten/vendor/symfony/yaml/Command/LintCommand.php
vendored
Executable file → Normal file
36
pfosten/vendor/symfony/yaml/Command/LintCommand.php
vendored
Executable file → Normal file
|
|
@ -12,12 +12,15 @@
|
|||
namespace Symfony\Component\Yaml\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* Validates YAML files syntax and outputs encountered errors.
|
||||
|
|
@ -27,6 +30,8 @@ use Symfony\Component\Yaml\Parser;
|
|||
*/
|
||||
class LintCommand extends Command
|
||||
{
|
||||
protected static $defaultName = 'lint:yaml';
|
||||
|
||||
private $parser;
|
||||
private $format;
|
||||
private $displayCorrectFiles;
|
||||
|
|
@ -47,10 +52,10 @@ class LintCommand extends Command
|
|||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('lint:yaml')
|
||||
->setDescription('Lints a file and outputs encountered errors')
|
||||
->addArgument('filename', null, 'A file or a directory or STDIN')
|
||||
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
||||
->addOption('parse-tags', null, InputOption::VALUE_NONE, 'Parse custom tags')
|
||||
->setHelp(<<<EOF
|
||||
The <info>%command.name%</info> command lints a YAML file and outputs to STDOUT
|
||||
the first encountered syntax error.
|
||||
|
|
@ -79,41 +84,42 @@ EOF
|
|||
$filename = $input->getArgument('filename');
|
||||
$this->format = $input->getOption('format');
|
||||
$this->displayCorrectFiles = $output->isVerbose();
|
||||
$flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0;
|
||||
|
||||
if (!$filename) {
|
||||
if (!$stdin = $this->getStdin()) {
|
||||
throw new \RuntimeException('Please provide a filename or pipe file content to STDIN.');
|
||||
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
|
||||
}
|
||||
|
||||
return $this->display($io, array($this->validate($stdin)));
|
||||
return $this->display($io, array($this->validate($stdin, $flags)));
|
||||
}
|
||||
|
||||
if (!$this->isReadable($filename)) {
|
||||
throw new \RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));
|
||||
throw new RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));
|
||||
}
|
||||
|
||||
$filesInfo = array();
|
||||
foreach ($this->getFiles($filename) as $file) {
|
||||
$filesInfo[] = $this->validate(file_get_contents($file), $file);
|
||||
$filesInfo[] = $this->validate(file_get_contents($file), $flags, $file);
|
||||
}
|
||||
|
||||
return $this->display($io, $filesInfo);
|
||||
}
|
||||
|
||||
private function validate($content, $file = null)
|
||||
private function validate($content, $flags, $file = null)
|
||||
{
|
||||
$prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) {
|
||||
if (E_USER_DEPRECATED === $level) {
|
||||
throw new ParseException($message);
|
||||
throw new ParseException($message, $this->getParser()->getRealCurrentLineNb() + 1);
|
||||
}
|
||||
|
||||
return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false;
|
||||
});
|
||||
|
||||
try {
|
||||
$this->getParser()->parse($content);
|
||||
$this->getParser()->parse($content, Yaml::PARSE_CONSTANT | $flags);
|
||||
} catch (ParseException $e) {
|
||||
return array('file' => $file, 'valid' => false, 'message' => $e->getMessage());
|
||||
return array('file' => $file, 'line' => $e->getParsedLine(), 'valid' => false, 'message' => $e->getMessage());
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
|
|
@ -129,13 +135,13 @@ EOF
|
|||
case 'json':
|
||||
return $this->displayJson($io, $files);
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('The format "%s" is not supported.', $this->format));
|
||||
throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $this->format));
|
||||
}
|
||||
}
|
||||
|
||||
private function displayTxt(SymfonyStyle $io, array $filesInfo)
|
||||
{
|
||||
$countFiles = count($filesInfo);
|
||||
$countFiles = \count($filesInfo);
|
||||
$erroredFiles = 0;
|
||||
|
||||
foreach ($filesInfo as $info) {
|
||||
|
|
@ -148,7 +154,7 @@ EOF
|
|||
}
|
||||
}
|
||||
|
||||
if ($erroredFiles === 0) {
|
||||
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));
|
||||
|
|
@ -182,7 +188,7 @@ EOF
|
|||
}
|
||||
|
||||
foreach ($this->getDirectoryIterator($fileOrDirectory) as $file) {
|
||||
if (!in_array($file->getExtension(), array('yml', 'yaml'))) {
|
||||
if (!\in_array($file->getExtension(), array('yml', 'yaml'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -223,7 +229,7 @@ EOF
|
|||
};
|
||||
|
||||
if (null !== $this->directoryIteratorProvider) {
|
||||
return call_user_func($this->directoryIteratorProvider, $directory, $default);
|
||||
return \call_user_func($this->directoryIteratorProvider, $directory, $default);
|
||||
}
|
||||
|
||||
return $default($directory);
|
||||
|
|
@ -236,7 +242,7 @@ EOF
|
|||
};
|
||||
|
||||
if (null !== $this->isReadableProvider) {
|
||||
return call_user_func($this->isReadableProvider, $fileOrDirectory, $default);
|
||||
return \call_user_func($this->isReadableProvider, $fileOrDirectory, $default);
|
||||
}
|
||||
|
||||
return $default($fileOrDirectory);
|
||||
|
|
|
|||
23
pfosten/vendor/symfony/yaml/Dumper.php
vendored
Executable file → Normal file
23
pfosten/vendor/symfony/yaml/Dumper.php
vendored
Executable file → Normal file
|
|
@ -15,6 +15,8 @@ namespace Symfony\Component\Yaml;
|
|||
* Dumper dumps PHP variables to YAML strings.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since version 3.4
|
||||
*/
|
||||
class Dumper
|
||||
{
|
||||
|
|
@ -46,7 +48,7 @@ class Dumper
|
|||
*/
|
||||
public function setIndentation($num)
|
||||
{
|
||||
@trigger_error('The '.__METHOD__.' method is deprecated since version 3.1 and will be removed in 4.0. Pass the indentation to the constructor instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('The '.__METHOD__.' method is deprecated since Symfony 3.1 and will be removed in 4.0. Pass the indentation to the constructor instead.', E_USER_DEPRECATED);
|
||||
|
||||
$this->indentation = (int) $num;
|
||||
}
|
||||
|
|
@ -63,8 +65,8 @@ class Dumper
|
|||
*/
|
||||
public function dump($input, $inline = 0, $indent = 0, $flags = 0)
|
||||
{
|
||||
if (is_bool($flags)) {
|
||||
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
|
||||
if (\is_bool($flags)) {
|
||||
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if ($flags) {
|
||||
$flags = Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE;
|
||||
|
|
@ -73,8 +75,8 @@ class Dumper
|
|||
}
|
||||
}
|
||||
|
||||
if (func_num_args() >= 5) {
|
||||
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
|
||||
if (\func_num_args() >= 5) {
|
||||
@trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (func_get_arg(4)) {
|
||||
$flags |= Yaml::DUMP_OBJECT;
|
||||
|
|
@ -89,14 +91,17 @@ class Dumper
|
|||
$dumpObjectAsInlineMap = empty((array) $input);
|
||||
}
|
||||
|
||||
if ($inline <= 0 || (!is_array($input) && $dumpObjectAsInlineMap) || empty($input)) {
|
||||
if ($inline <= 0 || (!\is_array($input) && $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")) {
|
||||
$output .= sprintf("%s%s%s |\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '');
|
||||
if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\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, 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);
|
||||
|
|
@ -111,7 +116,7 @@ class Dumper
|
|||
$dumpObjectAsInlineMap = empty((array) $value);
|
||||
}
|
||||
|
||||
$willBeInlined = $inline - 1 <= 0 || !is_array($value) && $dumpObjectAsInlineMap || empty($value);
|
||||
$willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || empty($value);
|
||||
|
||||
$output .= sprintf('%s%s%s%s',
|
||||
$prefix,
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/yaml/Escaper.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/yaml/Escaper.php
vendored
Executable file → Normal file
|
|
@ -78,7 +78,7 @@ 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), array('null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/yaml/Exception/DumpException.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Exception/DumpException.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Exception/ExceptionInterface.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Exception/ExceptionInterface.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/yaml/Exception/ParseException.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/yaml/Exception/ParseException.php
vendored
Executable file → Normal file
|
|
@ -24,8 +24,6 @@ class ParseException extends RuntimeException
|
|||
private $rawMessage;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @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
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/yaml/Exception/RuntimeException.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Exception/RuntimeException.php
vendored
Executable file → Normal file
266
pfosten/vendor/symfony/yaml/Inline.php
vendored
Executable file → Normal file
266
pfosten/vendor/symfony/yaml/Inline.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\Yaml;
|
||||
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Exception\DumpException;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Tag\TaggedValue;
|
||||
|
||||
/**
|
||||
|
|
@ -26,13 +26,32 @@ class Inline
|
|||
{
|
||||
const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*+(?:\\\\.[^"\\\\]*+)*+)"|\'([^\']*+(?:\'\'[^\']*+)*+)\')';
|
||||
|
||||
public static $parsedLineNumber;
|
||||
public static $parsedLineNumber = -1;
|
||||
public static $parsedFilename;
|
||||
|
||||
private static $exceptionOnInvalidType = false;
|
||||
private static $objectSupport = false;
|
||||
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)
|
||||
{
|
||||
self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags);
|
||||
self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags);
|
||||
self::$objectForMap = (bool) (Yaml::PARSE_OBJECT_FOR_MAP & $flags);
|
||||
self::$constantSupport = (bool) (Yaml::PARSE_CONSTANT & $flags);
|
||||
self::$parsedFilename = $parsedFilename;
|
||||
|
||||
if (null !== $parsedLineNumber) {
|
||||
self::$parsedLineNumber = $parsedLineNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a YAML string to a PHP value.
|
||||
*
|
||||
|
|
@ -46,8 +65,8 @@ class Inline
|
|||
*/
|
||||
public static function parse($value, $flags = 0, $references = array())
|
||||
{
|
||||
if (is_bool($flags)) {
|
||||
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
|
||||
if (\is_bool($flags)) {
|
||||
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if ($flags) {
|
||||
$flags = Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE;
|
||||
|
|
@ -56,32 +75,29 @@ class Inline
|
|||
}
|
||||
}
|
||||
|
||||
if (func_num_args() >= 3 && !is_array($references)) {
|
||||
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
|
||||
if (\func_num_args() >= 3 && !\is_array($references)) {
|
||||
@trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if ($references) {
|
||||
$flags |= Yaml::PARSE_OBJECT;
|
||||
}
|
||||
|
||||
if (func_num_args() >= 4) {
|
||||
@trigger_error('Passing a boolean flag to toggle object for map support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
|
||||
if (\func_num_args() >= 4) {
|
||||
@trigger_error('Passing a boolean flag to toggle object for map support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (func_get_arg(3)) {
|
||||
$flags |= Yaml::PARSE_OBJECT_FOR_MAP;
|
||||
}
|
||||
}
|
||||
|
||||
if (func_num_args() >= 5) {
|
||||
if (\func_num_args() >= 5) {
|
||||
$references = func_get_arg(4);
|
||||
} else {
|
||||
$references = array();
|
||||
}
|
||||
}
|
||||
|
||||
self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags);
|
||||
self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags);
|
||||
self::$objectForMap = (bool) (Yaml::PARSE_OBJECT_FOR_MAP & $flags);
|
||||
self::$constantSupport = (bool) (Yaml::PARSE_CONSTANT & $flags);
|
||||
self::initialize($flags);
|
||||
|
||||
$value = trim($value);
|
||||
|
||||
|
|
@ -115,7 +131,7 @@ class Inline
|
|||
|
||||
// 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)));
|
||||
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
if (isset($mbEncoding)) {
|
||||
|
|
@ -137,8 +153,8 @@ class Inline
|
|||
*/
|
||||
public static function dump($value, $flags = 0)
|
||||
{
|
||||
if (is_bool($flags)) {
|
||||
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
|
||||
if (\is_bool($flags)) {
|
||||
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if ($flags) {
|
||||
$flags = Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE;
|
||||
|
|
@ -147,8 +163,8 @@ class Inline
|
|||
}
|
||||
}
|
||||
|
||||
if (func_num_args() >= 3) {
|
||||
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
|
||||
if (\func_num_args() >= 3) {
|
||||
@trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (func_get_arg(2)) {
|
||||
$flags |= Yaml::DUMP_OBJECT;
|
||||
|
|
@ -156,7 +172,7 @@ class Inline
|
|||
}
|
||||
|
||||
switch (true) {
|
||||
case is_resource($value):
|
||||
case \is_resource($value):
|
||||
if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) {
|
||||
throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value)));
|
||||
}
|
||||
|
|
@ -164,13 +180,13 @@ class Inline
|
|||
return 'null';
|
||||
case $value instanceof \DateTimeInterface:
|
||||
return $value->format('c');
|
||||
case is_object($value):
|
||||
case \is_object($value):
|
||||
if ($value instanceof TaggedValue) {
|
||||
return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags);
|
||||
}
|
||||
|
||||
if (Yaml::DUMP_OBJECT & $flags) {
|
||||
return '!php/object:'.serialize($value);
|
||||
return '!php/object '.self::dump(serialize($value));
|
||||
}
|
||||
|
||||
if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) {
|
||||
|
|
@ -182,7 +198,7 @@ class Inline
|
|||
}
|
||||
|
||||
return 'null';
|
||||
case is_array($value):
|
||||
case \is_array($value):
|
||||
return self::dumpArray($value, $flags);
|
||||
case null === $value:
|
||||
return 'null';
|
||||
|
|
@ -191,13 +207,13 @@ class Inline
|
|||
case false === $value:
|
||||
return 'false';
|
||||
case ctype_digit($value):
|
||||
return is_string($value) ? "'$value'" : (int) $value;
|
||||
return \is_string($value) ? "'$value'" : (int) $value;
|
||||
case is_numeric($value):
|
||||
$locale = setlocale(LC_NUMERIC, 0);
|
||||
if (false !== $locale) {
|
||||
setlocale(LC_NUMERIC, 'C');
|
||||
}
|
||||
if (is_float($value)) {
|
||||
if (\is_float($value)) {
|
||||
$repr = (string) $value;
|
||||
if (is_infinite($value)) {
|
||||
$repr = str_ireplace('INF', '.Inf', $repr);
|
||||
|
|
@ -206,7 +222,7 @@ class Inline
|
|||
$repr = '!!float '.$repr;
|
||||
}
|
||||
} else {
|
||||
$repr = is_string($value) ? "'$value'" : (string) $value;
|
||||
$repr = \is_string($value) ? "'$value'" : (string) $value;
|
||||
}
|
||||
if (false !== $locale) {
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
|
|
@ -302,21 +318,24 @@ class Inline
|
|||
*/
|
||||
public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i = 0, $evaluate = true, $references = array(), $legacyOmittedKeySupport = false)
|
||||
{
|
||||
if (in_array($scalar[$i], array('"', "'"))) {
|
||||
if (\in_array($scalar[$i], array('"', "'"))) {
|
||||
// quoted scalar
|
||||
$output = self::parseQuotedScalar($scalar, $i);
|
||||
|
||||
if (null !== $delimiters) {
|
||||
$tmp = ltrim(substr($scalar, $i), ' ');
|
||||
if (!in_array($tmp[0], $delimiters)) {
|
||||
throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)));
|
||||
if ('' === $tmp) {
|
||||
throw new ParseException(sprintf('Unexpected end of line, expected one of "%s".', implode($delimiters)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
if (!\in_array($tmp[0], $delimiters)) {
|
||||
throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// "normal" string
|
||||
if (!$delimiters) {
|
||||
$output = substr($scalar, $i);
|
||||
$i += strlen($output);
|
||||
$i += \strlen($output);
|
||||
|
||||
// remove comments
|
||||
if (Parser::preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
|
||||
|
|
@ -324,18 +343,18 @@ class Inline
|
|||
}
|
||||
} elseif (Parser::preg_match('/^(.'.($legacyOmittedKeySupport ? '+' : '*').'?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
|
||||
$output = $match[1];
|
||||
$i += strlen($output);
|
||||
$i += \strlen($output);
|
||||
} else {
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $scalar));
|
||||
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 >)
|
||||
if ($output && ('@' === $output[0] || '`' === $output[0] || '|' === $output[0] || '>' === $output[0])) {
|
||||
throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0]));
|
||||
throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0]), self::$parsedLineNumber + 1, $output, self::$parsedFilename);
|
||||
}
|
||||
|
||||
if ($output && '%' === $output[0]) {
|
||||
@trigger_error(sprintf('Not quoting the scalar "%s" starting with the "%%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', $output), E_USER_DEPRECATED);
|
||||
@trigger_error(self::getDeprecationMessage(sprintf('Not quoting the scalar "%s" starting with the "%%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', $output)), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if ($evaluate) {
|
||||
|
|
@ -359,10 +378,10 @@ class Inline
|
|||
private static function parseQuotedScalar($scalar, &$i)
|
||||
{
|
||||
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)));
|
||||
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);
|
||||
$output = substr($match[0], 1, \strlen($match[0]) - 2);
|
||||
|
||||
$unescaper = new Unescaper();
|
||||
if ('"' == $scalar[$i]) {
|
||||
|
|
@ -371,7 +390,7 @@ class Inline
|
|||
$output = $unescaper->unescapeSingleQuotedString($output);
|
||||
}
|
||||
|
||||
$i += strlen($match[0]);
|
||||
$i += \strlen($match[0]);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -391,7 +410,7 @@ class Inline
|
|||
private static function parseSequence($sequence, $flags, &$i = 0, $references = array())
|
||||
{
|
||||
$output = array();
|
||||
$len = strlen($sequence);
|
||||
$len = \strlen($sequence);
|
||||
++$i;
|
||||
|
||||
// [foo, bar, ...]
|
||||
|
|
@ -416,11 +435,11 @@ class Inline
|
|||
$value = self::parseMapping($sequence, $flags, $i, $references);
|
||||
break;
|
||||
default:
|
||||
$isQuoted = in_array($sequence[$i], array('"', "'"));
|
||||
$isQuoted = \in_array($sequence[$i], array('"', "'"));
|
||||
$value = self::parseScalar($sequence, $flags, array(',', ']'), $i, null === $tag, $references);
|
||||
|
||||
// the value can be an array if a reference has been resolved to an array var
|
||||
if (is_string($value) && !$isQuoted && false !== strpos($value, ': ')) {
|
||||
if (\is_string($value) && !$isQuoted && false !== strpos($value, ': ')) {
|
||||
// embedded mapping?
|
||||
try {
|
||||
$pos = 0;
|
||||
|
|
@ -442,7 +461,7 @@ class Inline
|
|||
++$i;
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $sequence));
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -460,8 +479,9 @@ class Inline
|
|||
private static function parseMapping($mapping, $flags, &$i = 0, $references = array())
|
||||
{
|
||||
$output = array();
|
||||
$len = strlen($mapping);
|
||||
$len = \strlen($mapping);
|
||||
++$i;
|
||||
$allowOverwrite = false;
|
||||
|
||||
// {foo: bar, bar:foo, ...}
|
||||
while ($i < $len) {
|
||||
|
|
@ -479,7 +499,7 @@ class Inline
|
|||
}
|
||||
|
||||
// key
|
||||
$isKeyQuoted = in_array($mapping[$i], array('"', "'"), true);
|
||||
$isKeyQuoted = \in_array($mapping[$i], array('"', "'"), true);
|
||||
$key = self::parseScalar($mapping, $flags, array(':', ' '), $i, false, array(), true);
|
||||
|
||||
if (':' !== $key && false === $i = strpos($mapping, ':', $i)) {
|
||||
|
|
@ -487,19 +507,23 @@ class Inline
|
|||
}
|
||||
|
||||
if (':' === $key) {
|
||||
@trigger_error('Omitting the key of a mapping is deprecated and will throw a ParseException in 4.0.', E_USER_DEPRECATED);
|
||||
@trigger_error(self::getDeprecationMessage('Omitting the key of a mapping is deprecated and will throw a ParseException in 4.0.'), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if (!(Yaml::PARSE_KEYS_AS_STRINGS & $flags)) {
|
||||
if (!$isKeyQuoted) {
|
||||
$evaluatedKey = self::evaluateScalar($key, $flags, $references);
|
||||
|
||||
if ('' !== $key && $evaluatedKey !== $key && !is_string($evaluatedKey)) {
|
||||
@trigger_error('Implicit casting of incompatible mapping keys to strings is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Pass the PARSE_KEYS_AS_STRING flag to explicitly enable the type casts.', E_USER_DEPRECATED);
|
||||
if ('' !== $key && $evaluatedKey !== $key && !\is_string($evaluatedKey) && !\is_int($evaluatedKey)) {
|
||||
@trigger_error(self::getDeprecationMessage('Implicit casting of incompatible mapping keys to strings is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead.'), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
if (':' !== $key && !$isKeyQuoted && (!isset($mapping[$i + 1]) || !in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true))) {
|
||||
@trigger_error('Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since version 3.2 and will throw a ParseException in 4.0.', E_USER_DEPRECATED);
|
||||
if (':' !== $key && !$isKeyQuoted && (!isset($mapping[$i + 1]) || !\in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true))) {
|
||||
@trigger_error(self::getDeprecationMessage('Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since Symfony 3.2 and will throw a ParseException in 4.0.'), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if ('<<' === $key) {
|
||||
$allowOverwrite = true;
|
||||
}
|
||||
|
||||
while ($i < $len) {
|
||||
|
|
@ -510,7 +534,6 @@ class Inline
|
|||
}
|
||||
|
||||
$tag = self::parseTag($mapping, $i, $flags);
|
||||
$duplicate = false;
|
||||
switch ($mapping[$i]) {
|
||||
case '[':
|
||||
// nested sequence
|
||||
|
|
@ -518,9 +541,19 @@ class Inline
|
|||
// Spec: Keys MUST be unique; first one wins.
|
||||
// Parser cannot abort this mapping earlier, since lines
|
||||
// are processed sequentially.
|
||||
if (isset($output[$key])) {
|
||||
@trigger_error(sprintf('Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
|
||||
$duplicate = true;
|
||||
// But overwriting is allowed when a merge node is used in current block.
|
||||
if ('<<' === $key) {
|
||||
foreach ($value as $parsedValue) {
|
||||
$output += $parsedValue;
|
||||
}
|
||||
} elseif ($allowOverwrite || !isset($output[$key])) {
|
||||
if (null !== $tag) {
|
||||
$output[$key] = new TaggedValue($tag, $value);
|
||||
} else {
|
||||
$output[$key] = $value;
|
||||
}
|
||||
} elseif (isset($output[$key])) {
|
||||
@trigger_error(self::getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED);
|
||||
}
|
||||
break;
|
||||
case '{':
|
||||
|
|
@ -529,9 +562,17 @@ class Inline
|
|||
// Spec: Keys MUST be unique; first one wins.
|
||||
// Parser cannot abort this mapping earlier, since lines
|
||||
// are processed sequentially.
|
||||
if (isset($output[$key])) {
|
||||
@trigger_error(sprintf('Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
|
||||
$duplicate = true;
|
||||
// But overwriting is allowed when a merge node is used in current block.
|
||||
if ('<<' === $key) {
|
||||
$output += $value;
|
||||
} elseif ($allowOverwrite || !isset($output[$key])) {
|
||||
if (null !== $tag) {
|
||||
$output[$key] = new TaggedValue($tag, $value);
|
||||
} else {
|
||||
$output[$key] = $value;
|
||||
}
|
||||
} elseif (isset($output[$key])) {
|
||||
@trigger_error(self::getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
@ -539,27 +580,27 @@ class Inline
|
|||
// Spec: Keys MUST be unique; first one wins.
|
||||
// Parser cannot abort this mapping earlier, since lines
|
||||
// are processed sequentially.
|
||||
if (isset($output[$key])) {
|
||||
@trigger_error(sprintf('Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
|
||||
$duplicate = true;
|
||||
// But overwriting is allowed when a merge node is used in current block.
|
||||
if ('<<' === $key) {
|
||||
$output += $value;
|
||||
} elseif ($allowOverwrite || !isset($output[$key])) {
|
||||
if (null !== $tag) {
|
||||
$output[$key] = new TaggedValue($tag, $value);
|
||||
} else {
|
||||
$output[$key] = $value;
|
||||
}
|
||||
} elseif (isset($output[$key])) {
|
||||
@trigger_error(self::getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED);
|
||||
}
|
||||
--$i;
|
||||
}
|
||||
|
||||
if (!$duplicate) {
|
||||
if (null !== $tag) {
|
||||
$output[$key] = new TaggedValue($tag, $value);
|
||||
} else {
|
||||
$output[$key] = $value;
|
||||
}
|
||||
}
|
||||
++$i;
|
||||
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $mapping));
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $mapping), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -587,11 +628,11 @@ class Inline
|
|||
|
||||
// an unquoted *
|
||||
if (false === $value || '' === $value) {
|
||||
throw new ParseException('A reference must contain at least one character.');
|
||||
throw new ParseException('A reference must contain at least one character.', self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
if (!array_key_exists($value, $references)) {
|
||||
throw new ParseException(sprintf('Reference "%s" does not exist.', $value));
|
||||
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
return $references[$value];
|
||||
|
|
@ -606,44 +647,78 @@ class Inline
|
|||
return true;
|
||||
case 'false' === $scalarLower:
|
||||
return false;
|
||||
case $scalar[0] === '!':
|
||||
case '!' === $scalar[0]:
|
||||
switch (true) {
|
||||
case 0 === strpos($scalar, '!str'):
|
||||
@trigger_error(self::getDeprecationMessage('Support for the !str tag is deprecated since Symfony 3.4. Use the !!str tag instead.'), E_USER_DEPRECATED);
|
||||
|
||||
return (string) substr($scalar, 5);
|
||||
case 0 === strpos($scalar, '!!str '):
|
||||
return (string) substr($scalar, 6);
|
||||
case 0 === strpos($scalar, '! '):
|
||||
@trigger_error(self::getDeprecationMessage('Using the non-specific tag "!" is deprecated since Symfony 3.4 as its behavior will change in 4.0. It will force non-evaluating your values in 4.0. Use plain integers or !!float instead.'), E_USER_DEPRECATED);
|
||||
|
||||
return (int) self::parseScalar(substr($scalar, 2), $flags);
|
||||
case 0 === strpos($scalar, '!php/object:'):
|
||||
if (self::$objectSupport) {
|
||||
@trigger_error(self::getDeprecationMessage('The !php/object: tag to indicate dumped PHP objects is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/object (without the colon) tag instead.'), E_USER_DEPRECATED);
|
||||
|
||||
return unserialize(substr($scalar, 12));
|
||||
}
|
||||
|
||||
if (self::$exceptionOnInvalidType) {
|
||||
throw new ParseException('Object support when parsing a YAML file has been disabled.');
|
||||
throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
return;
|
||||
case 0 === strpos($scalar, '!!php/object:'):
|
||||
if (self::$objectSupport) {
|
||||
@trigger_error('The !!php/object tag to indicate dumped PHP objects is deprecated since version 3.1 and will be removed in 4.0. Use the !php/object tag instead.', E_USER_DEPRECATED);
|
||||
@trigger_error(self::getDeprecationMessage('The !!php/object: tag to indicate dumped PHP objects is deprecated since Symfony 3.1 and will be removed in 4.0. Use the !php/object (without the colon) tag instead.'), E_USER_DEPRECATED);
|
||||
|
||||
return unserialize(substr($scalar, 13));
|
||||
}
|
||||
|
||||
if (self::$exceptionOnInvalidType) {
|
||||
throw new ParseException('Object support when parsing a YAML file has been disabled.');
|
||||
throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
return;
|
||||
case 0 === strpos($scalar, '!php/object'):
|
||||
if (self::$objectSupport) {
|
||||
return unserialize(self::parseScalar(substr($scalar, 12)));
|
||||
}
|
||||
|
||||
if (self::$exceptionOnInvalidType) {
|
||||
throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
return;
|
||||
case 0 === strpos($scalar, '!php/const:'):
|
||||
if (self::$constantSupport) {
|
||||
if (defined($const = substr($scalar, 11))) {
|
||||
return constant($const);
|
||||
@trigger_error(self::getDeprecationMessage('The !php/const: tag to indicate dumped PHP constants is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead.'), E_USER_DEPRECATED);
|
||||
|
||||
if (\defined($const = substr($scalar, 11))) {
|
||||
return \constant($const);
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('The constant "%s" is not defined.', $const));
|
||||
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));
|
||||
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);
|
||||
}
|
||||
|
||||
return;
|
||||
case 0 === strpos($scalar, '!php/const'):
|
||||
if (self::$constantSupport) {
|
||||
$i = 0;
|
||||
if (\defined($const = self::parseScalar(substr($scalar, 11), 0, null, $i, false))) {
|
||||
return \constant($const);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
@ -652,15 +727,17 @@ class Inline
|
|||
case 0 === strpos($scalar, '!!binary '):
|
||||
return self::evaluateBinaryScalar(substr($scalar, 9));
|
||||
default:
|
||||
@trigger_error(sprintf('Using the unquoted scalar value "%s" is deprecated since version 3.3 and will be considered as a tagged value in 4.0. You must quote it.', $scalar), E_USER_DEPRECATED);
|
||||
@trigger_error(self::getDeprecationMessage(sprintf('Using the unquoted scalar value "%s" is deprecated since Symfony 3.3 and will be considered as a tagged value in 4.0. You must quote it.', $scalar)), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
// Optimize for returning strings.
|
||||
case $scalar[0] === '+' || $scalar[0] === '-' || $scalar[0] === '.' || is_numeric($scalar[0]):
|
||||
// no break
|
||||
case '+' === $scalar[0] || '-' === $scalar[0] || '.' === $scalar[0] || is_numeric($scalar[0]):
|
||||
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;
|
||||
$cast = (int) $scalar;
|
||||
|
|
@ -684,7 +761,7 @@ class Inline
|
|||
case Parser::preg_match('/^(-|\+)?[0-9][0-9,]*(\.[0-9_]+)?$/', $scalar):
|
||||
case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar):
|
||||
if (false !== strpos($scalar, ',')) {
|
||||
@trigger_error('Using the comma as a group separator for floats is deprecated since version 3.2 and will be removed in 4.0.', E_USER_DEPRECATED);
|
||||
@trigger_error(self::getDeprecationMessage('Using the comma as a group separator for floats is deprecated since Symfony 3.2 and will be removed in 4.0.'), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
return (float) str_replace(array(',', '_'), '', $scalar);
|
||||
|
|
@ -726,14 +803,14 @@ class Inline
|
|||
$nextOffset += strspn($value, ' ', $nextOffset);
|
||||
|
||||
// Is followed by a scalar
|
||||
if (!isset($value[$nextOffset]) || !in_array($value[$nextOffset], array('[', '{'), true)) {
|
||||
// Manage scalars in {@link self::evaluateScalar()}
|
||||
if ((!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], array('[', '{'), true)) && 'tagged' !== $tag) {
|
||||
// Manage non-whitelisted scalars in {@link self::evaluateScalar()}
|
||||
return;
|
||||
}
|
||||
|
||||
// Built-in tags
|
||||
if ($tag && '!' === $tag[0]) {
|
||||
throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag));
|
||||
throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
if (Yaml::PARSE_CUSTOM_TAGS & $flags) {
|
||||
|
|
@ -742,7 +819,7 @@ class Inline
|
|||
return $tag;
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('Tags support is not enabled. Enable the `Yaml::PARSE_CUSTOM_TAGS` flag to use "!%s".', $tag));
|
||||
throw new ParseException(sprintf('Tags support is not enabled. Enable the `Yaml::PARSE_CUSTOM_TAGS` flag to use "!%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -756,12 +833,12 @@ class Inline
|
|||
{
|
||||
$parsedBinaryData = self::parseScalar(preg_replace('/\s/', '', $scalar));
|
||||
|
||||
if (0 !== (strlen($parsedBinaryData) % 4)) {
|
||||
throw new ParseException(sprintf('The normalized base64 encoded data (data without whitespace characters) length must be a multiple of four (%d bytes given).', strlen($parsedBinaryData)));
|
||||
if (0 !== (\strlen($parsedBinaryData) % 4)) {
|
||||
throw new ParseException(sprintf('The normalized base64 encoded data (data without whitespace characters) length must be a multiple of four (%d bytes given).', \strlen($parsedBinaryData)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
if (!Parser::preg_match('#^[A-Z0-9+/]+={0,2}$#i', $parsedBinaryData)) {
|
||||
throw new ParseException(sprintf('The base64 encoded data (%s) contains invalid characters.', $parsedBinaryData));
|
||||
throw new ParseException(sprintf('The base64 encoded data (%s) contains invalid characters.', $parsedBinaryData), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
return base64_decode($parsedBinaryData, true);
|
||||
|
|
@ -806,4 +883,19 @@ EOF;
|
|||
{
|
||||
return '~^0x[0-9a-f_]++$~i';
|
||||
}
|
||||
|
||||
private static function getDeprecationMessage($message)
|
||||
{
|
||||
$message = rtrim($message, '.');
|
||||
|
||||
if (null !== self::$parsedFilename) {
|
||||
$message .= ' in '.self::$parsedFilename;
|
||||
}
|
||||
|
||||
if (-1 !== self::$parsedLineNumber) {
|
||||
$message .= ' on line '.(self::$parsedLineNumber + 1);
|
||||
}
|
||||
|
||||
return $message.'.';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
pfosten/vendor/symfony/yaml/LICENSE
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/yaml/LICENSE
vendored
Executable file → Normal file
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2004-2017 Fabien Potencier
|
||||
Copyright (c) 2004-2018 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
|
||||
|
|
|
|||
354
pfosten/vendor/symfony/yaml/Parser.php
vendored
Executable file → Normal file
354
pfosten/vendor/symfony/yaml/Parser.php
vendored
Executable file → Normal file
|
|
@ -18,12 +18,15 @@ use Symfony\Component\Yaml\Tag\TaggedValue;
|
|||
* Parser parses YAML strings to convert them to PHP arrays.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since version 3.4
|
||||
*/
|
||||
class Parser
|
||||
{
|
||||
const TAG_PATTERN = '(?P<tag>![\w!.\/:-]+)';
|
||||
const BLOCK_SCALAR_HEADER_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?';
|
||||
|
||||
private $filename;
|
||||
private $offset = 0;
|
||||
private $totalNumberOfLines;
|
||||
private $lines = array();
|
||||
|
|
@ -35,19 +38,48 @@ class Parser
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
if (\func_num_args() > 0) {
|
||||
@trigger_error(sprintf('The constructor arguments $offset, $totalNumberOfLines, $skippedLineNumbers of %s are deprecated and will be removed in 4.0', self::class), E_USER_DEPRECATED);
|
||||
|
||||
$this->offset = func_get_arg(0);
|
||||
if (func_num_args() > 1) {
|
||||
if (\func_num_args() > 1) {
|
||||
$this->totalNumberOfLines = func_get_arg(1);
|
||||
}
|
||||
if (func_num_args() > 2) {
|
||||
if (\func_num_args() > 2) {
|
||||
$this->skippedLineNumbers = func_get_arg(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a YAML file into a PHP value.
|
||||
*
|
||||
* @param string $filename The path to the YAML file to be parsed
|
||||
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
|
||||
*
|
||||
* @return mixed The YAML converted to a PHP value
|
||||
*
|
||||
* @throws ParseException If the file could not be read or the YAML is not valid
|
||||
*/
|
||||
public function parseFile($filename, $flags = 0)
|
||||
{
|
||||
if (!is_file($filename)) {
|
||||
throw new ParseException(sprintf('File "%s" does not exist.', $filename));
|
||||
}
|
||||
|
||||
if (!is_readable($filename)) {
|
||||
throw new ParseException(sprintf('File "%s" cannot be read.', $filename));
|
||||
}
|
||||
|
||||
$this->filename = $filename;
|
||||
|
||||
try {
|
||||
return $this->parse(file_get_contents($filename), $flags);
|
||||
} finally {
|
||||
$this->filename = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a YAML string to a PHP value.
|
||||
*
|
||||
|
|
@ -60,8 +92,8 @@ class Parser
|
|||
*/
|
||||
public function parse($value, $flags = 0)
|
||||
{
|
||||
if (is_bool($flags)) {
|
||||
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
|
||||
if (\is_bool($flags)) {
|
||||
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if ($flags) {
|
||||
$flags = Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE;
|
||||
|
|
@ -70,24 +102,28 @@ class Parser
|
|||
}
|
||||
}
|
||||
|
||||
if (func_num_args() >= 3) {
|
||||
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
|
||||
if (\func_num_args() >= 3) {
|
||||
@trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (func_get_arg(2)) {
|
||||
$flags |= Yaml::PARSE_OBJECT;
|
||||
}
|
||||
}
|
||||
|
||||
if (func_num_args() >= 4) {
|
||||
@trigger_error('Passing a boolean flag to toggle object for map support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
|
||||
if (\func_num_args() >= 4) {
|
||||
@trigger_error('Passing a boolean flag to toggle object for map support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (func_get_arg(3)) {
|
||||
$flags |= Yaml::PARSE_OBJECT_FOR_MAP;
|
||||
}
|
||||
}
|
||||
|
||||
if (Yaml::PARSE_KEYS_AS_STRINGS & $flags) {
|
||||
@trigger_error('Using the Yaml::PARSE_KEYS_AS_STRINGS flag is deprecated since Symfony 3.4 as it will be removed in 4.0. Quote your keys when they are evaluable instead.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if (false === preg_match('//u', $value)) {
|
||||
throw new ParseException('The YAML value does not appear to be valid UTF-8.');
|
||||
throw new ParseException('The YAML value does not appear to be valid UTF-8.', -1, null, $this->filename);
|
||||
}
|
||||
|
||||
$this->refs = array();
|
||||
|
|
@ -133,7 +169,7 @@ class Parser
|
|||
$this->locallySkippedLineNumbers = array();
|
||||
|
||||
if (null === $this->totalNumberOfLines) {
|
||||
$this->totalNumberOfLines = count($this->lines);
|
||||
$this->totalNumberOfLines = \count($this->lines);
|
||||
}
|
||||
|
||||
if (!$this->moveToNextLine()) {
|
||||
|
|
@ -162,13 +198,15 @@ class Parser
|
|||
|
||||
// tab?
|
||||
if ("\t" === $this->currentLine[0]) {
|
||||
throw new ParseException('A YAML file cannot contain tabs as indentation.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
throw new ParseException('A YAML file cannot contain tabs as indentation.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
Inline::initialize($flags, $this->getRealCurrentLineNb(), $this->filename);
|
||||
|
||||
$isRef = $mergeNode = false;
|
||||
if (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);
|
||||
throw new ParseException('You cannot define a sequence item when in a mapping', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
$context = 'sequence';
|
||||
|
||||
|
|
@ -178,7 +216,7 @@ class Parser
|
|||
}
|
||||
|
||||
if (isset($values['value'][1]) && '?' === $values['value'][0] && ' ' === $values['value'][1]) {
|
||||
@trigger_error('Starting an unquoted string with a question mark followed by a space is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', E_USER_DEPRECATED);
|
||||
@trigger_error($this->getDeprecationMessage('Starting an unquoted string with a question mark followed by a space is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.'), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
// array
|
||||
|
|
@ -196,7 +234,7 @@ class Parser
|
|||
// this is a compact notation element, add to next block and parse
|
||||
$block = $values['value'];
|
||||
if ($this->isNextLineIndented()) {
|
||||
$block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + strlen($values['leadspaces']) + 1);
|
||||
$block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + \strlen($values['leadspaces']) + 1);
|
||||
}
|
||||
|
||||
$data[] = $this->parseBlock($this->getRealCurrentLineNb(), $block, $flags);
|
||||
|
|
@ -208,18 +246,15 @@ class Parser
|
|||
$this->refs[$isRef] = end($data);
|
||||
}
|
||||
} elseif (
|
||||
self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?(?:![^\s]++\s++)?[^ \'"\[\{!].*?) *\:(\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:)?[^ \'"\[\{!].*?)) *\:(\s++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
|
||||
&& (false === strpos($values['key'], ' #') || \in_array($values['key'][0], array('"', "'")))
|
||||
) {
|
||||
if ($context && 'sequence' == $context) {
|
||||
throw new ParseException('You cannot define a mapping item when in a sequence', $this->currentLineNb + 1, $this->currentLine);
|
||||
throw new ParseException('You cannot define a mapping item when in a sequence', $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
$context = 'mapping';
|
||||
|
||||
// force correct settings
|
||||
Inline::parse(null, $flags, $this->refs);
|
||||
try {
|
||||
Inline::$parsedLineNumber = $this->getRealCurrentLineNb();
|
||||
$i = 0;
|
||||
$evaluateKey = !(Yaml::PARSE_KEYS_AS_STRINGS & $flags);
|
||||
|
||||
|
|
@ -236,42 +271,50 @@ class Parser
|
|||
throw $e;
|
||||
}
|
||||
|
||||
if (!(Yaml::PARSE_KEYS_AS_STRINGS & $flags) && !is_string($key)) {
|
||||
$keyType = is_numeric($key) ? 'numeric key' : 'incompatible key type';
|
||||
@trigger_error(sprintf('Implicit casting of %s to string on line %d is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Pass the PARSE_KEYS_AS_STRING flag to explicitly enable the type casts.', $keyType, $this->getRealCurrentLineNb()), E_USER_DEPRECATED);
|
||||
if (!\is_string($key) && !\is_int($key)) {
|
||||
$keyType = is_numeric($key) ? 'numeric key' : 'non-string key';
|
||||
@trigger_error($this->getDeprecationMessage(sprintf('Implicit casting of %s to string is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead.', $keyType)), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
// Convert float keys to strings, to avoid being converted to integers by PHP
|
||||
if (is_float($key)) {
|
||||
if (\is_float($key)) {
|
||||
$key = (string) $key;
|
||||
}
|
||||
|
||||
if ('<<' === $key) {
|
||||
if ('<<' === $key && (!isset($values['value']) || !self::preg_match('#^&(?P<ref>[^ ]+)#u', $values['value'], $refMatches))) {
|
||||
$mergeNode = true;
|
||||
$allowOverwrite = true;
|
||||
if (isset($values['value']) && 0 === strpos($values['value'], '*')) {
|
||||
if (isset($values['value'][0]) && '*' === $values['value'][0]) {
|
||||
$refName = substr(rtrim($values['value']), 1);
|
||||
if (!array_key_exists($refName, $this->refs)) {
|
||||
throw new ParseException(sprintf('Reference "%s" does not exist.', $refName), $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
throw new ParseException(sprintf('Reference "%s" does not exist.', $refName), $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
$refValue = $this->refs[$refName];
|
||||
|
||||
if (!is_array($refValue)) {
|
||||
throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $refValue instanceof \stdClass) {
|
||||
$refValue = (array) $refValue;
|
||||
}
|
||||
|
||||
if (!\is_array($refValue)) {
|
||||
throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
$data += $refValue; // array union
|
||||
} else {
|
||||
if (isset($values['value']) && $values['value'] !== '') {
|
||||
if (isset($values['value']) && '' !== $values['value']) {
|
||||
$value = $values['value'];
|
||||
} else {
|
||||
$value = $this->getNextEmbedBlock();
|
||||
}
|
||||
$parsed = $this->parseBlock($this->getRealCurrentLineNb() + 1, $value, $flags);
|
||||
|
||||
if (!is_array($parsed)) {
|
||||
throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $parsed instanceof \stdClass) {
|
||||
$parsed = (array) $parsed;
|
||||
}
|
||||
|
||||
if (!\is_array($parsed)) {
|
||||
throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
if (isset($parsed[0])) {
|
||||
|
|
@ -279,8 +322,12 @@ class Parser
|
|||
// and each of these nodes is merged in turn according to its order in the sequence. Keys in mapping nodes earlier
|
||||
// in the sequence override keys specified in later mapping nodes.
|
||||
foreach ($parsed as $parsedItem) {
|
||||
if (!is_array($parsedItem)) {
|
||||
throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem);
|
||||
if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $parsedItem instanceof \stdClass) {
|
||||
$parsedItem = (array) $parsedItem;
|
||||
}
|
||||
|
||||
if (!\is_array($parsedItem)) {
|
||||
throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem, $this->filename);
|
||||
}
|
||||
|
||||
$data += $parsedItem; // array union
|
||||
|
|
@ -291,7 +338,7 @@ class Parser
|
|||
$data += $parsed; // array union
|
||||
}
|
||||
}
|
||||
} elseif (isset($values['value']) && self::preg_match('#^&(?P<ref>[^ ]++) *+(?P<value>.*)#u', $values['value'], $matches)) {
|
||||
} elseif ('<<' !== $key && isset($values['value']) && self::preg_match('#^&(?P<ref>[^ ]++) *+(?P<value>.*)#u', $values['value'], $matches)) {
|
||||
$isRef = $matches['ref'];
|
||||
$values['value'] = $matches['value'];
|
||||
}
|
||||
|
|
@ -299,7 +346,7 @@ class Parser
|
|||
$subTag = null;
|
||||
if ($mergeNode) {
|
||||
// Merge keys
|
||||
} elseif (!isset($values['value']) || '' === $values['value'] || 0 === strpos($values['value'], '#') || (null !== $subTag = $this->getLineTag($values['value'], $flags))) {
|
||||
} elseif (!isset($values['value']) || '' === $values['value'] || 0 === strpos($values['value'], '#') || (null !== $subTag = $this->getLineTag($values['value'], $flags)) || '<<' === $key) {
|
||||
// hash
|
||||
// if next line is less indented or equal, then it means that the current value is null
|
||||
if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) {
|
||||
|
|
@ -312,22 +359,28 @@ class Parser
|
|||
$data[$key] = null;
|
||||
}
|
||||
} else {
|
||||
@trigger_error(sprintf('Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key, $this->getRealCurrentLineNb() + 1), E_USER_DEPRECATED);
|
||||
@trigger_error($this->getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED);
|
||||
}
|
||||
} else {
|
||||
// remember the parsed line number here in case we need it to provide some contexts in error messages below
|
||||
$realCurrentLineNbKey = $this->getRealCurrentLineNb();
|
||||
$value = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(), $flags);
|
||||
// Spec: Keys MUST be unique; first one wins.
|
||||
// But overwriting is allowed when a merge node is used in current block.
|
||||
if ($allowOverwrite || !isset($data[$key])) {
|
||||
if ('<<' === $key) {
|
||||
$this->refs[$refMatches['ref']] = $value;
|
||||
|
||||
if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $value instanceof \stdClass) {
|
||||
$value = (array) $value;
|
||||
}
|
||||
|
||||
$data += $value;
|
||||
} elseif ($allowOverwrite || !isset($data[$key])) {
|
||||
// Spec: Keys MUST be unique; first one wins.
|
||||
// But overwriting is allowed when a merge node is used in current block.
|
||||
if (null !== $subTag) {
|
||||
$data[$key] = new TaggedValue($subTag, $value);
|
||||
} else {
|
||||
$data[$key] = $value;
|
||||
}
|
||||
} else {
|
||||
@trigger_error(sprintf('Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key, $realCurrentLineNbKey + 1), E_USER_DEPRECATED);
|
||||
@trigger_error($this->getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -337,7 +390,7 @@ class Parser
|
|||
if ($allowOverwrite || !isset($data[$key])) {
|
||||
$data[$key] = $value;
|
||||
} else {
|
||||
@trigger_error(sprintf('Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key, $this->getRealCurrentLineNb() + 1), E_USER_DEPRECATED);
|
||||
@trigger_error($this->getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
if ($isRef) {
|
||||
|
|
@ -346,17 +399,16 @@ class Parser
|
|||
} else {
|
||||
// multiple documents are not supported
|
||||
if ('---' === $this->currentLine) {
|
||||
throw new ParseException('Multiple documents are not supported.', $this->currentLineNb + 1, $this->currentLine);
|
||||
throw new ParseException('Multiple documents are not supported.', $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
if (isset($this->currentLine[1]) && '?' === $this->currentLine[0] && ' ' === $this->currentLine[1]) {
|
||||
@trigger_error('Starting an unquoted string with a question mark followed by a space is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', E_USER_DEPRECATED);
|
||||
if ($deprecatedUsage = (isset($this->currentLine[1]) && '?' === $this->currentLine[0] && ' ' === $this->currentLine[1])) {
|
||||
@trigger_error($this->getDeprecationMessage('Starting an unquoted string with a question mark followed by a space is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.'), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
// 1-liner optionally followed by newline(s)
|
||||
if (is_string($value) && $this->lines[0] === trim($value)) {
|
||||
if (\is_string($value) && $this->lines[0] === trim($value)) {
|
||||
try {
|
||||
Inline::$parsedLineNumber = $this->getRealCurrentLineNb();
|
||||
$value = Inline::parse($this->lines[0], $flags, $this->refs);
|
||||
} catch (ParseException $e) {
|
||||
$e->setParsedLine($this->getRealCurrentLineNb() + 1);
|
||||
|
|
@ -370,45 +422,47 @@ class Parser
|
|||
|
||||
// try to parse the value as a multi-line string as a last resort
|
||||
if (0 === $this->currentLineNb) {
|
||||
$parseError = false;
|
||||
$previousLineWasNewline = false;
|
||||
$previousLineWasTerminatedWithBackslash = false;
|
||||
$value = '';
|
||||
|
||||
foreach ($this->lines as $line) {
|
||||
try {
|
||||
if (isset($line[0]) && ('"' === $line[0] || "'" === $line[0])) {
|
||||
$parsedLine = $line;
|
||||
} else {
|
||||
$parsedLine = Inline::parse($line, $flags, $this->refs);
|
||||
}
|
||||
// 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 ('' === trim($line)) {
|
||||
$value .= "\n";
|
||||
} elseif (!$previousLineWasNewline && !$previousLineWasTerminatedWithBackslash) {
|
||||
$value .= ' ';
|
||||
}
|
||||
|
||||
if (!is_string($parsedLine)) {
|
||||
$parseError = true;
|
||||
break;
|
||||
}
|
||||
if ('' !== trim($line) && '\\' === substr($line, -1)) {
|
||||
$value .= ltrim(substr($line, 0, -1));
|
||||
} elseif ('' !== trim($line)) {
|
||||
$value .= trim($line);
|
||||
}
|
||||
|
||||
if ('' === trim($parsedLine)) {
|
||||
$value .= "\n";
|
||||
$previousLineWasNewline = true;
|
||||
} elseif ($previousLineWasNewline) {
|
||||
$value .= trim($parsedLine);
|
||||
$previousLineWasNewline = false;
|
||||
} else {
|
||||
$value .= ' '.trim($parsedLine);
|
||||
$previousLineWasNewline = false;
|
||||
}
|
||||
} catch (ParseException $e) {
|
||||
$parseError = true;
|
||||
break;
|
||||
if ('' === trim($line)) {
|
||||
$previousLineWasNewline = true;
|
||||
$previousLineWasTerminatedWithBackslash = false;
|
||||
} elseif ('\\' === substr($line, -1)) {
|
||||
$previousLineWasNewline = false;
|
||||
$previousLineWasTerminatedWithBackslash = true;
|
||||
} else {
|
||||
$previousLineWasNewline = false;
|
||||
$previousLineWasTerminatedWithBackslash = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$parseError) {
|
||||
return trim($value);
|
||||
try {
|
||||
return Inline::parse(trim($value));
|
||||
} catch (ParseException $e) {
|
||||
// fall-through to the ParseException thrown below
|
||||
}
|
||||
}
|
||||
|
||||
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
} while ($this->moveToNextLine());
|
||||
|
||||
|
|
@ -416,7 +470,7 @@ class Parser
|
|||
$data = new TaggedValue($tag, $data);
|
||||
}
|
||||
|
||||
if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && !is_object($data) && 'mapping' === $context) {
|
||||
if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && !\is_object($data) && 'mapping' === $context) {
|
||||
$object = new \stdClass();
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
|
|
@ -453,9 +507,11 @@ class Parser
|
|||
/**
|
||||
* Returns the current line number (takes the offset into account).
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @return int The current line number
|
||||
*/
|
||||
private function getRealCurrentLineNb()
|
||||
public function getRealCurrentLineNb()
|
||||
{
|
||||
$realCurrentLineNumber = $this->currentLineNb + $this->offset;
|
||||
|
||||
|
|
@ -477,7 +533,7 @@ class Parser
|
|||
*/
|
||||
private function getCurrentLineIndentation()
|
||||
{
|
||||
return strlen($this->currentLine) - strlen(ltrim($this->currentLine, ' '));
|
||||
return \strlen($this->currentLine) - \strlen(ltrim($this->currentLine, ' '));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -504,12 +560,32 @@ class Parser
|
|||
}
|
||||
|
||||
if (null === $indentation) {
|
||||
$newIndent = $this->getCurrentLineIndentation();
|
||||
$newIndent = null;
|
||||
$movements = 0;
|
||||
|
||||
do {
|
||||
$EOF = false;
|
||||
|
||||
// empty and comment-like lines do not influence the indentation depth
|
||||
if ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) {
|
||||
$EOF = !$this->moveToNextLine();
|
||||
|
||||
if (!$EOF) {
|
||||
++$movements;
|
||||
}
|
||||
} else {
|
||||
$newIndent = $this->getCurrentLineIndentation();
|
||||
}
|
||||
} while (!$EOF && null === $newIndent);
|
||||
|
||||
for ($i = 0; $i < $movements; ++$i) {
|
||||
$this->moveToPreviousLine();
|
||||
}
|
||||
|
||||
$unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem();
|
||||
|
||||
if (!$this->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) {
|
||||
throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
} else {
|
||||
$newIndent = $indentation;
|
||||
|
|
@ -518,6 +594,8 @@ class Parser
|
|||
$data = array();
|
||||
if ($this->getCurrentLineIndentation() >= $newIndent) {
|
||||
$data[] = substr($this->currentLine, $newIndent);
|
||||
} elseif ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) {
|
||||
$data[] = $this->currentLine;
|
||||
} else {
|
||||
$this->moveToPreviousLine();
|
||||
|
||||
|
|
@ -544,7 +622,7 @@ class Parser
|
|||
$indent = $this->getCurrentLineIndentation();
|
||||
|
||||
// terminate all block scalars that are more indented than the current line
|
||||
if (!empty($blockScalarIndentations) && $indent < $previousLineIndentation && trim($this->currentLine) !== '') {
|
||||
if (!empty($blockScalarIndentations) && $indent < $previousLineIndentation && '' !== trim($this->currentLine)) {
|
||||
foreach ($blockScalarIndentations as $key => $blockScalarIndentation) {
|
||||
if ($blockScalarIndentation >= $indent) {
|
||||
unset($blockScalarIndentations[$key]);
|
||||
|
|
@ -568,27 +646,16 @@ class Parser
|
|||
continue;
|
||||
}
|
||||
|
||||
// we ignore "comment" lines only when we are not inside a scalar block
|
||||
if (empty($blockScalarIndentations) && $this->isCurrentLineComment()) {
|
||||
// remember ignored comment lines (they are used later in nested
|
||||
// parser calls to determine real line numbers)
|
||||
//
|
||||
// CAUTION: beware to not populate the global property here as it
|
||||
// will otherwise influence the getRealCurrentLineNb() call here
|
||||
// for consecutive comment lines and subsequent embedded blocks
|
||||
$this->locallySkippedLineNumbers[] = $this->getRealCurrentLineNb();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($indent >= $newIndent) {
|
||||
$data[] = substr($this->currentLine, $newIndent);
|
||||
} elseif ($this->isCurrentLineComment()) {
|
||||
$data[] = $this->currentLine;
|
||||
} elseif (0 == $indent) {
|
||||
$this->moveToPreviousLine();
|
||||
|
||||
break;
|
||||
} else {
|
||||
throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -602,7 +669,7 @@ class Parser
|
|||
*/
|
||||
private function moveToNextLine()
|
||||
{
|
||||
if ($this->currentLineNb >= count($this->lines) - 1) {
|
||||
if ($this->currentLineNb >= \count($this->lines) - 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -648,7 +715,7 @@ class Parser
|
|||
}
|
||||
|
||||
if (!array_key_exists($value, $this->refs)) {
|
||||
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine);
|
||||
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
return $this->refs[$value];
|
||||
|
|
@ -662,8 +729,10 @@ class Parser
|
|||
if ('' !== $matches['tag']) {
|
||||
if ('!!binary' === $matches['tag']) {
|
||||
return Inline::evaluateBinaryScalar($data);
|
||||
} elseif ('tagged' === $matches['tag']) {
|
||||
return new TaggedValue(substr($matches['tag'], 1), $data);
|
||||
} elseif ('!' !== $matches['tag']) {
|
||||
@trigger_error(sprintf('Using the custom tag "%s" for the value "%s" is deprecated since version 3.3. It will be replaced by an instance of %s in 4.0.', $matches['tag'], $data, TaggedValue::class), E_USER_DEPRECATED);
|
||||
@trigger_error($this->getDeprecationMessage(sprintf('Using the custom tag "%s" for the value "%s" is deprecated since Symfony 3.3. It will be replaced by an instance of %s in 4.0.', $matches['tag'], $data, TaggedValue::class)), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -678,15 +747,17 @@ class Parser
|
|||
return Inline::parse($value, $flags, $this->refs);
|
||||
}
|
||||
|
||||
$lines = array();
|
||||
|
||||
while ($this->moveToNextLine()) {
|
||||
// unquoted strings end before the first unindented line
|
||||
if (null === $quotation && $this->getCurrentLineIndentation() === 0) {
|
||||
if (null === $quotation && 0 === $this->getCurrentLineIndentation()) {
|
||||
$this->moveToPreviousLine();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$value .= ' '.trim($this->currentLine);
|
||||
$lines[] = trim($this->currentLine);
|
||||
|
||||
// quoted string values end with a line that is terminated with the quotation character
|
||||
if ('' !== $this->currentLine && substr($this->currentLine, -1) === $quotation) {
|
||||
|
|
@ -694,11 +765,25 @@ class Parser
|
|||
}
|
||||
}
|
||||
|
||||
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.');
|
||||
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;
|
||||
|
|
@ -741,7 +826,7 @@ class Parser
|
|||
// determine indentation if not specified
|
||||
if (0 === $indentation) {
|
||||
if (self::preg_match('/^ +/', $this->currentLine, $matches)) {
|
||||
$indentation = strlen($matches[0]);
|
||||
$indentation = \strlen($matches[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -754,7 +839,7 @@ class Parser
|
|||
self::preg_match($pattern, $this->currentLine, $matches)
|
||||
)
|
||||
) {
|
||||
if ($isCurrentLineBlank && strlen($this->currentLine) > $indentation) {
|
||||
if ($isCurrentLineBlank && \strlen($this->currentLine) > $indentation) {
|
||||
$blockLines[] = substr($this->currentLine, $indentation);
|
||||
} elseif ($isCurrentLineBlank) {
|
||||
$blockLines[] = '';
|
||||
|
|
@ -784,7 +869,7 @@ class Parser
|
|||
$previousLineIndented = false;
|
||||
$previousLineBlank = false;
|
||||
|
||||
for ($i = 0, $blockLinesCount = count($blockLines); $i < $blockLinesCount; ++$i) {
|
||||
for ($i = 0, $blockLinesCount = \count($blockLines); $i < $blockLinesCount; ++$i) {
|
||||
if ('' === $blockLines[$i]) {
|
||||
$text .= "\n";
|
||||
$previousLineIndented = false;
|
||||
|
|
@ -829,11 +914,15 @@ class Parser
|
|||
private function isNextLineIndented()
|
||||
{
|
||||
$currentIndentation = $this->getCurrentLineIndentation();
|
||||
$EOF = !$this->moveToNextLine();
|
||||
$movements = 0;
|
||||
|
||||
while (!$EOF && $this->isCurrentLineEmpty()) {
|
||||
do {
|
||||
$EOF = !$this->moveToNextLine();
|
||||
}
|
||||
|
||||
if (!$EOF) {
|
||||
++$movements;
|
||||
}
|
||||
} while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()));
|
||||
|
||||
if ($EOF) {
|
||||
return false;
|
||||
|
|
@ -841,7 +930,9 @@ class Parser
|
|||
|
||||
$ret = $this->getCurrentLineIndentation() > $currentIndentation;
|
||||
|
||||
$this->moveToPreviousLine();
|
||||
for ($i = 0; $i < $movements; ++$i) {
|
||||
$this->moveToPreviousLine();
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
|
@ -876,7 +967,7 @@ class Parser
|
|||
//checking explicitly the first char of the trim is faster than loops or strpos
|
||||
$ltrimmedLine = ltrim($this->currentLine, ' ');
|
||||
|
||||
return '' !== $ltrimmedLine && $ltrimmedLine[0] === '#';
|
||||
return '' !== $ltrimmedLine && '#' === $ltrimmedLine[0];
|
||||
}
|
||||
|
||||
private function isCurrentLineLastLineInDocument()
|
||||
|
|
@ -902,7 +993,7 @@ class Parser
|
|||
|
||||
// remove leading comments
|
||||
$trimmedValue = preg_replace('#^(\#.*?\n)+#s', '', $value, -1, $count);
|
||||
if ($count == 1) {
|
||||
if (1 === $count) {
|
||||
// items have been removed, update the offset
|
||||
$this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n");
|
||||
$value = $trimmedValue;
|
||||
|
|
@ -910,7 +1001,7 @@ class Parser
|
|||
|
||||
// remove start of the document marker (---)
|
||||
$trimmedValue = preg_replace('#^\-\-\-.*?\n#s', '', $value, -1, $count);
|
||||
if ($count == 1) {
|
||||
if (1 === $count) {
|
||||
// items have been removed, update the offset
|
||||
$this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n");
|
||||
$value = $trimmedValue;
|
||||
|
|
@ -930,19 +1021,25 @@ class Parser
|
|||
private function isNextLineUnIndentedCollection()
|
||||
{
|
||||
$currentIndentation = $this->getCurrentLineIndentation();
|
||||
$notEOF = $this->moveToNextLine();
|
||||
$movements = 0;
|
||||
|
||||
while ($notEOF && $this->isCurrentLineEmpty()) {
|
||||
$notEOF = $this->moveToNextLine();
|
||||
}
|
||||
do {
|
||||
$EOF = !$this->moveToNextLine();
|
||||
|
||||
if (false === $notEOF) {
|
||||
if (!$EOF) {
|
||||
++$movements;
|
||||
}
|
||||
} while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()));
|
||||
|
||||
if ($EOF) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ret = $this->getCurrentLineIndentation() === $currentIndentation && $this->isStringUnIndentedCollectionItem();
|
||||
|
||||
$this->moveToPreviousLine();
|
||||
for ($i = 0; $i < $movements; ++$i) {
|
||||
$this->moveToPreviousLine();
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
|
@ -1038,13 +1135,26 @@ class Parser
|
|||
|
||||
// Built-in tags
|
||||
if ($tag && '!' === $tag[0]) {
|
||||
throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag));
|
||||
throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), $this->getRealCurrentLineNb() + 1, $value, $this->filename);
|
||||
}
|
||||
|
||||
if (Yaml::PARSE_CUSTOM_TAGS & $flags) {
|
||||
return $tag;
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('Tags support is not enabled. You must use the flag `Yaml::PARSE_CUSTOM_TAGS` to use "%s".', $matches['tag']));
|
||||
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 getDeprecationMessage($message)
|
||||
{
|
||||
$message = rtrim($message, '.');
|
||||
|
||||
if (null !== $this->filename) {
|
||||
$message .= ' in '.$this->filename;
|
||||
}
|
||||
|
||||
$message .= ' on line '.($this->getRealCurrentLineNb() + 1);
|
||||
|
||||
return $message.'.';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/yaml/README.md
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/README.md
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tag/TaggedValue.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tag/TaggedValue.php
vendored
Executable file → Normal file
34
pfosten/vendor/symfony/yaml/Tests/Command/LintCommandTest.php
vendored
Executable file → Normal file
34
pfosten/vendor/symfony/yaml/Tests/Command/LintCommandTest.php
vendored
Executable file → Normal file
|
|
@ -12,10 +12,10 @@
|
|||
namespace Symfony\Component\Yaml\Tests\Command;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Command\LintCommand;
|
||||
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.
|
||||
|
|
@ -51,6 +51,33 @@ bar';
|
|||
$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
|
||||
*/
|
||||
|
|
@ -105,3 +132,8 @@ bar';
|
|||
rmdir(sys_get_temp_dir().'/framework-yml-lint-test');
|
||||
}
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
const TEST = 'foo';
|
||||
}
|
||||
|
|
|
|||
27
pfosten/vendor/symfony/yaml/Tests/DumperTest.php
vendored
Executable file → Normal file
27
pfosten/vendor/symfony/yaml/Tests/DumperTest.php
vendored
Executable file → Normal file
|
|
@ -12,8 +12,8 @@
|
|||
namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
use Symfony\Component\Yaml\Dumper;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class DumperTest extends TestCase
|
||||
|
|
@ -125,7 +125,7 @@ EOF;
|
|||
// TODO
|
||||
} else {
|
||||
eval('$expected = '.trim($test['php']).';');
|
||||
$this->assertSame($expected, $this->parser->parse($this->dumper->dump($expected, 10), Yaml::PARSE_KEYS_AS_STRINGS), $test['test']);
|
||||
$this->assertSame($expected, $this->parser->parse($this->dumper->dump($expected, 10)), $test['test']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ EOF;
|
|||
{
|
||||
$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');
|
||||
$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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -220,7 +220,7 @@ EOF;
|
|||
{
|
||||
$dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true);
|
||||
|
||||
$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');
|
||||
$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()
|
||||
|
|
@ -443,7 +443,8 @@ YAML;
|
|||
$data = array(
|
||||
'data' => array(
|
||||
'single_line' => 'foo bar baz',
|
||||
'multi_line' => "foo\nline with trailing spaces:\n \nbar\r\ninteger like line:\n123456789\nempty line:\n\nbaz",
|
||||
'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",
|
||||
),
|
||||
|
|
@ -453,6 +454,22 @@ YAML;
|
|||
$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
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsAnchorAlias.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsAnchorAlias.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsBasicTests.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsBasicTests.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsBlockMapping.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsBlockMapping.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsDocumentSeparator.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsDocumentSeparator.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsErrorTests.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsErrorTests.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsFlowCollections.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsFlowCollections.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsFoldedScalars.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsFoldedScalars.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsNullsAndEmpties.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsNullsAndEmpties.yml
vendored
Executable file → Normal file
11
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsSpecificationExamples.yml
vendored
Executable file → Normal file
11
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsSpecificationExamples.yml
vendored
Executable file → Normal file
|
|
@ -592,7 +592,7 @@ test: Various explicit families
|
|||
todo: true
|
||||
spec: 2.23
|
||||
yaml: |
|
||||
not-date: !str 2002-04-28
|
||||
not-date: !!str 2002-04-28
|
||||
picture: !binary |
|
||||
R0lGODlhDAAMAIQAAP//9/X
|
||||
17unp5WZmZgAAAOfn515eXv
|
||||
|
|
@ -928,10 +928,11 @@ documents: 2
|
|||
|
||||
---
|
||||
test: Explicit typing
|
||||
deprecated: Using the non-specific tag "!" is deprecated since Symfony 3.4 as its behavior will change in 4.0.
|
||||
yaml: |
|
||||
integer: 12
|
||||
also int: ! "12"
|
||||
string: !str 12
|
||||
string: !!str 12
|
||||
php: |
|
||||
array( 'integer' => 12, 'also int' => 12, 'string' => '12' )
|
||||
---
|
||||
|
|
@ -963,7 +964,7 @@ documents: 2
|
|||
test: Type family under yaml.org
|
||||
yaml: |
|
||||
# The URI is 'tag:yaml.org,2002:str'
|
||||
- !str a Unicode string
|
||||
- !!str a Unicode string
|
||||
php: |
|
||||
array( 'a Unicode string' )
|
||||
---
|
||||
|
|
@ -1350,7 +1351,7 @@ yaml: |
|
|||
|
||||
second: 12 ## This is an integer.
|
||||
|
||||
third: !str 12 ## This is a string.
|
||||
third: !!str 12 ## This is a string.
|
||||
|
||||
span: this contains
|
||||
six spaces
|
||||
|
|
@ -1419,7 +1420,7 @@ yaml: |
|
|||
# The following scalars
|
||||
# are loaded to the
|
||||
# string value '1' '2'.
|
||||
- !str 12
|
||||
- !!str 12
|
||||
- '12'
|
||||
- "12"
|
||||
- "\
|
||||
|
|
|
|||
6
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsTypeTransfers.yml
vendored
Executable file → Normal file
6
pfosten/vendor/symfony/yaml/Tests/Fixtures/YtsTypeTransfers.yml
vendored
Executable file → Normal file
|
|
@ -52,10 +52,10 @@ php: |
|
|||
test: Forcing Strings
|
||||
brief: >
|
||||
Any YAML type can be forced into a string using the
|
||||
explicit !str method.
|
||||
explicit !!str method.
|
||||
yaml: |
|
||||
date string: !str 2001-08-01
|
||||
number string: !str 192
|
||||
date string: !!str 2001-08-01
|
||||
number string: !!str 192
|
||||
php: |
|
||||
array(
|
||||
'date string' => '2001-08-01',
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/arrow.gif
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/arrow.gif
vendored
Executable file → Normal file
|
Before Width: | Height: | Size: 185 B After Width: | Height: | Size: 185 B |
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/booleanMappingKeys.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/booleanMappingKeys.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/embededPhp.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/embededPhp.yml
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/yaml/Tests/Fixtures/escapedCharacters.yml
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/yaml/Tests/Fixtures/escapedCharacters.yml
vendored
Executable file → Normal file
|
|
@ -4,7 +4,7 @@ yaml: |
|
|||
php: |
|
||||
"\\0 \\ \\a \\b \\n"
|
||||
---
|
||||
test: null
|
||||
test: 'null'
|
||||
yaml: |
|
||||
"\0"
|
||||
php: |
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/index.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/index.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/legacyBooleanMappingKeys.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/legacyBooleanMappingKeys.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/legacyNonStringKeys.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/legacyNonStringKeys.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/legacyNullMappingKey.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/legacyNullMappingKey.yml
vendored
Executable file → Normal file
1
pfosten/vendor/symfony/yaml/Tests/Fixtures/multiple_lines_as_literal_block.yml
vendored
Executable file → Normal file
1
pfosten/vendor/symfony/yaml/Tests/Fixtures/multiple_lines_as_literal_block.yml
vendored
Executable file → Normal file
|
|
@ -10,4 +10,5 @@ data:
|
|||
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" }
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/nonStringKeys.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/nonStringKeys.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/nullMappingKey.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/nullMappingKey.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/numericMappingKeys.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/numericMappingKeys.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/sfComments.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/sfComments.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/sfCompact.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/sfCompact.yml
vendored
Executable file → Normal file
8
pfosten/vendor/symfony/yaml/Tests/Fixtures/sfMergeKey.yml
vendored
Executable file → Normal file
8
pfosten/vendor/symfony/yaml/Tests/Fixtures/sfMergeKey.yml
vendored
Executable file → Normal file
|
|
@ -21,6 +21,7 @@ yaml: |
|
|||
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]
|
||||
|
|
@ -42,14 +43,19 @@ yaml: |
|
|||
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))
|
||||
'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'),
|
||||
)
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/sfObjects.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/sfObjects.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/sfQuotes.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/sfQuotes.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/sfTests.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/sfTests.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/unindentedCollections.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/Fixtures/unindentedCollections.yml
vendored
Executable file → Normal file
108
pfosten/vendor/symfony/yaml/Tests/InlineTest.php
vendored
Executable file → Normal file
108
pfosten/vendor/symfony/yaml/Tests/InlineTest.php
vendored
Executable file → Normal file
|
|
@ -18,6 +18,11 @@ use Symfony\Component\Yaml\Yaml;
|
|||
|
||||
class InlineTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
Inline::initialize(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestsForParse
|
||||
*/
|
||||
|
|
@ -49,10 +54,11 @@ class InlineTest extends TestCase
|
|||
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 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),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -62,16 +68,37 @@ class InlineTest extends TestCase
|
|||
*/
|
||||
public function testParsePhpConstantThrowsExceptionWhenUndefined()
|
||||
{
|
||||
Inline::parse('!php/const:WRONG_CONSTANT', Yaml::PARSE_CONSTANT);
|
||||
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.*#
|
||||
* @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);
|
||||
Inline::parse('!php/const PHP_INT_MAX', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The !php/const: tag to indicate dumped PHP constants is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead on line 1.
|
||||
* @dataProvider getTestsForParseLegacyPhpConstants
|
||||
*/
|
||||
public function testDeprecatedConstantTag($yaml, $expectedValue)
|
||||
{
|
||||
$this->assertSame($expectedValue, Inline::parse($yaml, Yaml::PARSE_CONSTANT));
|
||||
}
|
||||
|
||||
public function getTestsForParseLegacyPhpConstants()
|
||||
{
|
||||
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),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -168,7 +195,7 @@ class InlineTest extends TestCase
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since version 3.2 and will throw a ParseException in 4.0.
|
||||
* @expectedDeprecation Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since Symfony 3.2 and will throw a ParseException in 4.0 on line 1.
|
||||
* throws \Symfony\Component\Yaml\Exception\ParseException in 4.0
|
||||
*/
|
||||
public function testParseMappingKeyWithColonNotFollowedBySpace()
|
||||
|
|
@ -256,7 +283,7 @@ class InlineTest extends TestCase
|
|||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage A reference must contain at least one character.
|
||||
* @expectedExceptionMessage A reference must contain at least one character at line 1.
|
||||
*/
|
||||
public function testParseUnquotedAsterisk()
|
||||
{
|
||||
|
|
@ -265,7 +292,7 @@ class InlineTest extends TestCase
|
|||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage A reference must contain at least one character.
|
||||
* @expectedExceptionMessage A reference must contain at least one character at line 1.
|
||||
*/
|
||||
public function testParseUnquotedAsteriskFollowedByAComment()
|
||||
{
|
||||
|
|
@ -274,11 +301,16 @@ class InlineTest extends TestCase
|
|||
|
||||
/**
|
||||
* @dataProvider getReservedIndicators
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage cannot start a plain scalar; you need to quote the scalar.
|
||||
*/
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
@ -289,11 +321,16 @@ class InlineTest extends TestCase
|
|||
|
||||
/**
|
||||
* @dataProvider getScalarIndicators
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage cannot start a plain scalar; you need to quote the scalar.
|
||||
*/
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
@ -304,7 +341,7 @@ class InlineTest extends TestCase
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Not quoting the scalar "%bar " starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.
|
||||
* @expectedDeprecation Not quoting the scalar "%bar " starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0 on line 1.
|
||||
* throws \Symfony\Component\Yaml\Exception\ParseException in 4.0
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithPercentCharacter()
|
||||
|
|
@ -385,8 +422,8 @@ class InlineTest extends TestCase
|
|||
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), Yaml::PARSE_KEYS_AS_STRINGS),
|
||||
array('{ foo : bar, bar : foo, false : false, null : null, integer : 12 }', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), Yaml::PARSE_KEYS_AS_STRINGS),
|
||||
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')),
|
||||
|
|
@ -456,8 +493,8 @@ class InlineTest extends TestCase
|
|||
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 | Yaml::PARSE_KEYS_AS_STRINGS),
|
||||
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 | Yaml::PARSE_KEYS_AS_STRINGS),
|
||||
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')),
|
||||
|
|
@ -538,7 +575,7 @@ class InlineTest extends TestCase
|
|||
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), Yaml::PARSE_KEYS_AS_STRINGS),
|
||||
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
|
||||
|
|
@ -554,7 +591,7 @@ class InlineTest extends TestCase
|
|||
|
||||
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))), Yaml::PARSE_KEYS_AS_STRINGS),
|
||||
array('{ foo: { bar: { 1: 2, baz: 3 } } }', array('foo' => array('bar' => array(1 => 2, 'baz' => 3)))),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -681,7 +718,7 @@ class InlineTest extends TestCase
|
|||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported}.
|
||||
* @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported} at line 1.
|
||||
*/
|
||||
public function testNotSupportedMissingValue()
|
||||
{
|
||||
|
|
@ -700,7 +737,7 @@ class InlineTest extends TestCase
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Omitting the key of a mapping is deprecated and will throw a ParseException in 4.0.
|
||||
* @expectedDeprecation Omitting the key of a mapping is deprecated and will throw a ParseException in 4.0 on line 1.
|
||||
*/
|
||||
public function testOmittedMappingKeyIsParsedAsColon()
|
||||
{
|
||||
|
|
@ -730,7 +767,7 @@ class InlineTest extends TestCase
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Implicit casting of incompatible mapping keys to strings is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Pass the PARSE_KEYS_AS_STRING flag to explicitly enable the type casts.
|
||||
* @expectedDeprecation Implicit casting of incompatible mapping keys to strings is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead on line 1.
|
||||
* @dataProvider getNotPhpCompatibleMappingKeyData
|
||||
*/
|
||||
public function testImplicitStringCastingOfMappingKeysIsDeprecated($yaml, $expected)
|
||||
|
|
@ -739,11 +776,14 @@ class InlineTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Using the Yaml::PARSE_KEYS_AS_STRINGS flag is deprecated since Symfony 3.4 as it will be removed in 4.0. Quote your keys when they are evaluable instead.
|
||||
* @expectedDeprecation Implicit casting of incompatible mapping keys to strings is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead on line 1.
|
||||
* @dataProvider getNotPhpCompatibleMappingKeyData
|
||||
*/
|
||||
public function testExplicitStringCastingOfMappingKeys($yaml, $expected)
|
||||
{
|
||||
$this->assertSame($expected, Inline::parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS));
|
||||
$this->assertSame($expected, Yaml::parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS));
|
||||
}
|
||||
|
||||
public function getNotPhpCompatibleMappingKeyData()
|
||||
|
|
@ -755,4 +795,22 @@ class InlineTest extends TestCase
|
|||
'float' => array('{0.25: "foo"}', array('0.25' => 'foo')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Support for the !str tag is deprecated since Symfony 3.4. Use the !!str tag instead on line 1.
|
||||
*/
|
||||
public function testDeprecatedStrTag()
|
||||
{
|
||||
$this->assertSame(array('foo' => 'bar'), Inline::parse('{ foo: !str bar }'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @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'");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/yaml/Tests/ParseExceptionTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/ParseExceptionTest.php
vendored
Executable file → Normal file
487
pfosten/vendor/symfony/yaml/Tests/ParserTest.php
vendored
Executable file → Normal file
487
pfosten/vendor/symfony/yaml/Tests/ParserTest.php
vendored
Executable file → Normal file
|
|
@ -13,9 +13,9 @@ namespace Symfony\Component\Yaml\Tests;
|
|||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
use Symfony\Component\Yaml\Tag\TaggedValue;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class ParserTest extends TestCase
|
||||
{
|
||||
|
|
@ -30,6 +30,8 @@ class ParserTest extends TestCase
|
|||
protected function tearDown()
|
||||
{
|
||||
$this->parser = null;
|
||||
|
||||
chmod(__DIR__.'/Fixtures/not_readable.yml', 0644);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -45,10 +47,10 @@ class ParserTest extends TestCase
|
|||
restore_error_handler();
|
||||
|
||||
if (class_exists('PHPUnit_Util_ErrorHandler')) {
|
||||
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
|
||||
return \call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', \func_get_args());
|
||||
}
|
||||
|
||||
return call_user_func_array('PHPUnit\Util\ErrorHandler::handleError', func_get_args());
|
||||
return \call_user_func_array('PHPUnit\Util\ErrorHandler::handleError', \func_get_args());
|
||||
}
|
||||
|
||||
$deprecations[] = $msg;
|
||||
|
|
@ -61,7 +63,7 @@ class ParserTest extends TestCase
|
|||
restore_error_handler();
|
||||
|
||||
$this->assertCount(1, $deprecations);
|
||||
$this->assertContains('Using the comma as a group separator for floats is deprecated since version 3.2 and will be removed in 4.0.', $deprecations[0]);
|
||||
$this->assertContains(true !== $deprecated ? $deprecated : 'Using the comma as a group separator for floats is deprecated since Symfony 3.2 and will be removed in 4.0 on line 1.', $deprecations[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -71,6 +73,8 @@ class ParserTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecationMessage Using the Yaml::PARSE_KEYS_AS_STRINGS flag is deprecated since Symfony 3.4 as it will be removed in 4.0. Quote your keys when they are evaluable
|
||||
* @dataProvider getNonStringMappingKeysData
|
||||
*/
|
||||
public function testNonStringMappingKeys($expected, $yaml, $comment)
|
||||
|
|
@ -469,7 +473,7 @@ EOF;
|
|||
public function testObjectSupportEnabled()
|
||||
{
|
||||
$input = <<<'EOF'
|
||||
foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
|
||||
foo: !php/object O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
|
||||
bar: 1
|
||||
EOF;
|
||||
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, Yaml::PARSE_OBJECT), '->parse() is able to parse objects');
|
||||
|
|
@ -489,14 +493,29 @@ EOF;
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider deprecatedObjectValueProvider
|
||||
*/
|
||||
public function testObjectSupportEnabledWithDeprecatedTag()
|
||||
public function testObjectSupportEnabledWithDeprecatedTag($yaml)
|
||||
{
|
||||
$input = <<<'EOF'
|
||||
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($yaml, Yaml::PARSE_OBJECT), '->parse() is able to parse objects');
|
||||
}
|
||||
|
||||
public function deprecatedObjectValueProvider()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
<<<YAML
|
||||
foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
|
||||
bar: 1
|
||||
EOF;
|
||||
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, Yaml::PARSE_OBJECT), '->parse() is able to parse objects');
|
||||
YAML
|
||||
),
|
||||
array(
|
||||
<<<YAML
|
||||
foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
|
||||
bar: 1
|
||||
YAML
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -510,14 +529,10 @@ EOF;
|
|||
/**
|
||||
* @dataProvider getObjectForMapTests
|
||||
*/
|
||||
public function testObjectForMap($yaml, $expected, $explicitlyParseKeysAsStrings = false)
|
||||
public function testObjectForMap($yaml, $expected)
|
||||
{
|
||||
$flags = Yaml::PARSE_OBJECT_FOR_MAP;
|
||||
|
||||
if ($explicitlyParseKeysAsStrings) {
|
||||
$flags |= Yaml::PARSE_KEYS_AS_STRINGS;
|
||||
}
|
||||
|
||||
$this->assertEquals($expected, $this->parser->parse($yaml, $flags));
|
||||
}
|
||||
|
||||
|
|
@ -577,18 +592,18 @@ YAML;
|
|||
$expected->map = new \stdClass();
|
||||
$expected->map->{1} = 'one';
|
||||
$expected->map->{2} = 'two';
|
||||
$tests['numeric-keys'] = array($yaml, $expected, true);
|
||||
$tests['numeric-keys'] = array($yaml, $expected);
|
||||
|
||||
$yaml = <<<'YAML'
|
||||
map:
|
||||
0: one
|
||||
1: two
|
||||
'0': one
|
||||
'1': two
|
||||
YAML;
|
||||
$expected = new \stdClass();
|
||||
$expected->map = new \stdClass();
|
||||
$expected->map->{0} = 'one';
|
||||
$expected->map->{1} = 'two';
|
||||
$tests['zero-indexed-numeric-keys'] = array($yaml, $expected, true);
|
||||
$tests['zero-indexed-numeric-keys'] = array($yaml, $expected);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
|
@ -776,6 +791,88 @@ EOT;
|
|||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testNonStringFollowedByCommentEmbeddedInMapping()
|
||||
{
|
||||
$yaml = <<<'EOT'
|
||||
a:
|
||||
b:
|
||||
{}
|
||||
# comment
|
||||
d:
|
||||
1.1
|
||||
# another comment
|
||||
EOT;
|
||||
$expected = array(
|
||||
'a' => array(
|
||||
'b' => array(),
|
||||
'd' => 1.1,
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function getParseExceptionNotAffectedMultiLineStringLastResortParsing()
|
||||
{
|
||||
$tests = array();
|
||||
|
||||
$yaml = <<<'EOT'
|
||||
a
|
||||
b:
|
||||
EOT;
|
||||
$tests['parse error on first line'] = array($yaml);
|
||||
|
||||
$yaml = <<<'EOT'
|
||||
a
|
||||
|
||||
b
|
||||
c:
|
||||
EOT;
|
||||
$tests['parse error due to inconsistent indentation'] = array($yaml);
|
||||
|
||||
$yaml = <<<'EOT'
|
||||
& * ! | > ' " % @ ` #, { asd a;sdasd }-@^qw3
|
||||
EOT;
|
||||
$tests['symfony/symfony/issues/22967#issuecomment-322067742'] = array($yaml);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getParseExceptionNotAffectedMultiLineStringLastResortParsing
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseExceptionNotAffectedByMultiLineStringLastResortParsing($yaml)
|
||||
{
|
||||
$this->parser->parse($yaml);
|
||||
}
|
||||
|
||||
public function testMultiLineStringLastResortParsing()
|
||||
{
|
||||
$yaml = <<<'EOT'
|
||||
test:
|
||||
You can have things that don't look like strings here
|
||||
true
|
||||
yes you can
|
||||
EOT;
|
||||
$expected = array(
|
||||
'test' => 'You can have things that don\'t look like strings here true yes you can',
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
|
||||
$yaml = <<<'EOT'
|
||||
a:
|
||||
b
|
||||
c
|
||||
EOT;
|
||||
$expected = array(
|
||||
'a' => 'b c',
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
|
|
@ -853,7 +950,7 @@ EOD;
|
|||
/**
|
||||
* @group legacy
|
||||
* @dataProvider getParseExceptionOnDuplicateData
|
||||
* @expectedDeprecation Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated %s.
|
||||
* @expectedDeprecation Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated %s and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line %d.
|
||||
* throws \Symfony\Component\Yaml\Exception\ParseException in 4.0
|
||||
*/
|
||||
public function testParseExceptionOnDuplicate($input, $duplicateKey, $lineNumber)
|
||||
|
|
@ -1081,7 +1178,7 @@ EOF;
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Implicit casting of numeric key to string on line 1 is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Pass the PARSE_KEYS_AS_STRING flag to explicitly enable the type casts.
|
||||
* @expectedDeprecation Implicit casting of numeric key to string is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead on line 2.
|
||||
*/
|
||||
public function testFloatKeys()
|
||||
{
|
||||
|
|
@ -1103,7 +1200,7 @@ EOF;
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Implicit casting of incompatible key type to string on line 1 is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Pass the PARSE_KEYS_AS_STRING flag to explicitly enable the type casts.
|
||||
* @expectedDeprecation Implicit casting of non-string key to string is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead on line 1.
|
||||
*/
|
||||
public function testBooleanKeys()
|
||||
{
|
||||
|
|
@ -1120,37 +1217,29 @@ EOF;
|
|||
$this->assertEquals($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testExplicitStringCastingOfFloatKeys()
|
||||
public function testExplicitStringCasting()
|
||||
{
|
||||
$yaml = <<<'EOF'
|
||||
foo:
|
||||
1.2: "bar"
|
||||
1.3: "baz"
|
||||
EOF;
|
||||
|
||||
$expected = array(
|
||||
'foo' => array(
|
||||
'1.2' => 'bar',
|
||||
'1.3' => 'baz',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $this->parser->parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS));
|
||||
}
|
||||
|
||||
public function testExplicitStringCastingOfBooleanKeys()
|
||||
{
|
||||
$yaml = <<<'EOF'
|
||||
true: foo
|
||||
false: bar
|
||||
'1.2': "bar"
|
||||
!!str 1.3: "baz"
|
||||
|
||||
'true': foo
|
||||
!!str false: bar
|
||||
|
||||
!!str null: 'null'
|
||||
'~': 'null'
|
||||
EOF;
|
||||
|
||||
$expected = array(
|
||||
'1.2' => 'bar',
|
||||
'1.3' => 'baz',
|
||||
'true' => 'foo',
|
||||
'false' => 'bar',
|
||||
'null' => 'null',
|
||||
'~' => 'null',
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $this->parser->parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS));
|
||||
$this->assertEquals($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1543,6 +1632,49 @@ EOT;
|
|||
$this->assertSame(array('foo' => 'bar baz foobar foo', 'bar' => 'baz'), $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testMultiLineQuotedStringWithTrailingBackslash()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
foobar:
|
||||
"foo\
|
||||
bar"
|
||||
YAML;
|
||||
|
||||
$this->assertSame(array('foobar' => 'foobar'), $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testCommentCharactersInMultiLineQuotedStrings()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
foo:
|
||||
foobar: 'foo
|
||||
#bar'
|
||||
bar: baz
|
||||
YAML;
|
||||
$expected = array(
|
||||
'foo' => array(
|
||||
'foobar' => 'foo #bar',
|
||||
'bar' => 'baz',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testBlankLinesInQuotedMultiLineString()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
foobar: 'foo
|
||||
|
||||
bar'
|
||||
YAML;
|
||||
$expected = array(
|
||||
'foobar' => "foo\nbar",
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testParseMultiLineUnquotedString()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
|
|
@ -1682,7 +1814,7 @@ YAML
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Using the unquoted scalar value "!iterator foo" is deprecated since version 3.3 and will be considered as a tagged value in 4.0. You must quote it.
|
||||
* @expectedDeprecation Using the unquoted scalar value "!iterator foo" is deprecated since Symfony 3.3 and will be considered as a tagged value in 4.0. You must quote it on line 1.
|
||||
*/
|
||||
public function testUnsupportedTagWithScalar()
|
||||
{
|
||||
|
|
@ -1691,7 +1823,7 @@ YAML
|
|||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage The built-in tag "!!foo" is not implemented.
|
||||
* @expectedExceptionMessage The built-in tag "!!foo" is not implemented at line 1 (near "!!foo").
|
||||
*/
|
||||
public function testExceptionWhenUsingUnsuportedBuiltInTags()
|
||||
{
|
||||
|
|
@ -1700,7 +1832,7 @@ YAML
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Starting an unquoted string with a question mark followed by a space is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.
|
||||
* @expectedDeprecation Starting an unquoted string with a question mark followed by a space is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line 1.
|
||||
*/
|
||||
public function testComplexMappingThrowsParseException()
|
||||
{
|
||||
|
|
@ -1715,7 +1847,7 @@ YAML;
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Starting an unquoted string with a question mark followed by a space is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.
|
||||
* @expectedDeprecation Starting an unquoted string with a question mark followed by a space is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line 2.
|
||||
*/
|
||||
public function testComplexMappingNestedInMappingThrowsParseException()
|
||||
{
|
||||
|
|
@ -1731,7 +1863,7 @@ YAML;
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Starting an unquoted string with a question mark followed by a space is deprecated since version 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.
|
||||
* @expectedDeprecation Starting an unquoted string with a question mark followed by a space is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line 1.
|
||||
*/
|
||||
public function testComplexMappingNestedInSequenceThrowsParseException()
|
||||
{
|
||||
|
|
@ -1764,7 +1896,7 @@ INI;
|
|||
$parser = new Parser();
|
||||
|
||||
$tests = array();
|
||||
$files = $parser->parse(file_get_contents(__DIR__.'/Fixtures/'.$testsFile));
|
||||
$files = $parser->parseFile(__DIR__.'/Fixtures/'.$testsFile);
|
||||
foreach ($files as $file) {
|
||||
$yamls = file_get_contents(__DIR__.'/Fixtures/'.$file.'.yml');
|
||||
|
||||
|
|
@ -1824,10 +1956,10 @@ YAML;
|
|||
{
|
||||
$yaml = <<<YAML
|
||||
transitions:
|
||||
!php/const:Symfony\Component\Yaml\Tests\B::FOO:
|
||||
!php/const 'Symfony\Component\Yaml\Tests\B::FOO':
|
||||
from:
|
||||
- !php/const:Symfony\Component\Yaml\Tests\B::BAR
|
||||
to: !php/const:Symfony\Component\Yaml\Tests\B::BAZ
|
||||
- !php/const 'Symfony\Component\Yaml\Tests\B::BAR'
|
||||
to: !php/const 'Symfony\Component\Yaml\Tests\B::BAZ'
|
||||
YAML;
|
||||
$expected = array(
|
||||
'transitions' => array(
|
||||
|
|
@ -1843,7 +1975,13 @@ YAML;
|
|||
$this->assertSame($expected, $this->parser->parse($yaml, Yaml::PARSE_CONSTANT));
|
||||
}
|
||||
|
||||
public function testPhpConstantTagMappingKeyWithKeysCastToStrings()
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The !php/const: tag to indicate dumped PHP constants is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead on line 2.
|
||||
* @expectedDeprecation The !php/const: tag to indicate dumped PHP constants is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead on line 4.
|
||||
* @expectedDeprecation The !php/const: tag to indicate dumped PHP constants is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead on line 5.
|
||||
*/
|
||||
public function testDeprecatedPhpConstantTagMappingKey()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
transitions:
|
||||
|
|
@ -1863,8 +2001,251 @@ YAML;
|
|||
),
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml, Yaml::PARSE_CONSTANT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Using the Yaml::PARSE_KEYS_AS_STRINGS flag is deprecated since Symfony 3.4 as it will be removed in 4.0. Quote your keys when they are evaluable instead.
|
||||
*/
|
||||
public function testPhpConstantTagMappingKeyWithKeysCastToStrings()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
transitions:
|
||||
!php/const 'Symfony\Component\Yaml\Tests\B::FOO':
|
||||
from:
|
||||
- !php/const 'Symfony\Component\Yaml\Tests\B::BAR'
|
||||
to: !php/const 'Symfony\Component\Yaml\Tests\B::BAZ'
|
||||
YAML;
|
||||
$expected = array(
|
||||
'transitions' => array(
|
||||
'foo' => array(
|
||||
'from' => array(
|
||||
'bar',
|
||||
),
|
||||
'to' => 'baz',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml, Yaml::PARSE_CONSTANT | Yaml::PARSE_KEYS_AS_STRINGS));
|
||||
}
|
||||
|
||||
public function testMergeKeysWhenMappingsAreParsedAsObjects()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
foo: &FOO
|
||||
bar: 1
|
||||
bar: &BAR
|
||||
baz: 2
|
||||
<<: *FOO
|
||||
baz:
|
||||
baz_foo: 3
|
||||
<<:
|
||||
baz_bar: 4
|
||||
foobar:
|
||||
bar: ~
|
||||
<<: [*FOO, *BAR]
|
||||
YAML;
|
||||
$expected = (object) array(
|
||||
'foo' => (object) array(
|
||||
'bar' => 1,
|
||||
),
|
||||
'bar' => (object) array(
|
||||
'baz' => 2,
|
||||
'bar' => 1,
|
||||
),
|
||||
'baz' => (object) array(
|
||||
'baz_foo' => 3,
|
||||
'baz_bar' => 4,
|
||||
),
|
||||
'foobar' => (object) array(
|
||||
'bar' => null,
|
||||
'baz' => 2,
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $this->parser->parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP));
|
||||
}
|
||||
|
||||
public function testFilenamesAreParsedAsStringsWithoutFlag()
|
||||
{
|
||||
$file = __DIR__.'/Fixtures/index.yml';
|
||||
|
||||
$this->assertSame($file, $this->parser->parse($file));
|
||||
}
|
||||
|
||||
public function testParseFile()
|
||||
{
|
||||
$this->assertInternalType('array', $this->parser->parseFile(__DIR__.'/Fixtures/index.yml'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessageRegExp #^File ".+/Fixtures/nonexistent.yml" does not exist\.$#
|
||||
*/
|
||||
public function testParsingNonExistentFilesThrowsException()
|
||||
{
|
||||
$this->parser->parseFile(__DIR__.'/Fixtures/nonexistent.yml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessageRegExp #^File ".+/Fixtures/not_readable.yml" cannot be read\.$#
|
||||
*/
|
||||
public function testParsingNotReadableFilesThrowsException()
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('chmod is not supported on Windows');
|
||||
}
|
||||
|
||||
$file = __DIR__.'/Fixtures/not_readable.yml';
|
||||
chmod($file, 0200);
|
||||
|
||||
$this->parser->parseFile($file);
|
||||
}
|
||||
|
||||
public function testParseReferencesOnMergeKeys()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
mergekeyrefdef:
|
||||
a: foo
|
||||
<<: &quux
|
||||
b: bar
|
||||
c: baz
|
||||
mergekeyderef:
|
||||
d: quux
|
||||
<<: *quux
|
||||
YAML;
|
||||
$expected = array(
|
||||
'mergekeyrefdef' => array(
|
||||
'a' => 'foo',
|
||||
'b' => 'bar',
|
||||
'c' => 'baz',
|
||||
),
|
||||
'mergekeyderef' => array(
|
||||
'd' => 'quux',
|
||||
'b' => 'bar',
|
||||
'c' => 'baz',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testParseReferencesOnMergeKeysWithMappingsParsedAsObjects()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
mergekeyrefdef:
|
||||
a: foo
|
||||
<<: &quux
|
||||
b: bar
|
||||
c: baz
|
||||
mergekeyderef:
|
||||
d: quux
|
||||
<<: *quux
|
||||
YAML;
|
||||
$expected = (object) array(
|
||||
'mergekeyrefdef' => (object) array(
|
||||
'a' => 'foo',
|
||||
'b' => 'bar',
|
||||
'c' => 'baz',
|
||||
),
|
||||
'mergekeyderef' => (object) array(
|
||||
'd' => 'quux',
|
||||
'b' => 'bar',
|
||||
'c' => 'baz',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $this->parser->parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage Reference "foo" does not exist
|
||||
*/
|
||||
public function testEvalRefException()
|
||||
{
|
||||
$yaml = <<<EOE
|
||||
foo: { &foo { a: Steve, <<: *foo} }
|
||||
EOE;
|
||||
$this->parser->parse($yaml);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider indentedMappingData
|
||||
*/
|
||||
public function testParseIndentedMappings($yaml, $expected)
|
||||
{
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function indentedMappingData()
|
||||
{
|
||||
$tests = array();
|
||||
|
||||
$yaml = <<<YAML
|
||||
foo:
|
||||
- bar: "foobar"
|
||||
# A comment
|
||||
baz: "foobaz"
|
||||
YAML;
|
||||
$expected = array(
|
||||
'foo' => array(
|
||||
array(
|
||||
'bar' => 'foobar',
|
||||
'baz' => 'foobaz',
|
||||
),
|
||||
),
|
||||
);
|
||||
$tests['comment line is first line in indented block'] = array($yaml, $expected);
|
||||
|
||||
$yaml = <<<YAML
|
||||
foo:
|
||||
- bar:
|
||||
# comment
|
||||
baz: [1, 2, 3]
|
||||
YAML;
|
||||
$expected = array(
|
||||
'foo' => array(
|
||||
array(
|
||||
'bar' => array(
|
||||
'baz' => array(1, 2, 3),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
$tests['mapping value on new line starting with a comment line'] = array($yaml, $expected);
|
||||
|
||||
$yaml = <<<YAML
|
||||
foo:
|
||||
-
|
||||
bar: foobar
|
||||
YAML;
|
||||
$expected = array(
|
||||
'foo' => array(
|
||||
array(
|
||||
'bar' => 'foobar',
|
||||
),
|
||||
),
|
||||
);
|
||||
$tests['mapping in sequence starting on a new line'] = array($yaml, $expected);
|
||||
|
||||
$yaml = <<<YAML
|
||||
foo:
|
||||
|
||||
bar: baz
|
||||
YAML;
|
||||
$expected = array(
|
||||
'foo' => array(
|
||||
'bar' => 'baz',
|
||||
),
|
||||
);
|
||||
$tests['blank line at the beginning of an indented mapping value'] = array($yaml, $expected);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
}
|
||||
|
||||
class B
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/yaml/Tests/YamlTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/Tests/YamlTest.php
vendored
Executable file → Normal file
8
pfosten/vendor/symfony/yaml/Unescaper.php
vendored
Executable file → Normal file
8
pfosten/vendor/symfony/yaml/Unescaper.php
vendored
Executable file → Normal file
|
|
@ -128,15 +128,15 @@ class Unescaper
|
|||
private static function utf8chr($c)
|
||||
{
|
||||
if (0x80 > $c %= 0x200000) {
|
||||
return chr($c);
|
||||
return \chr($c);
|
||||
}
|
||||
if (0x800 > $c) {
|
||||
return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
|
||||
return \chr(0xC0 | $c >> 6).\chr(0x80 | $c & 0x3F);
|
||||
}
|
||||
if (0x10000 > $c) {
|
||||
return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
|
||||
return \chr(0xE0 | $c >> 12).\chr(0x80 | $c >> 6 & 0x3F).\chr(0x80 | $c & 0x3F);
|
||||
}
|
||||
|
||||
return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
|
||||
return \chr(0xF0 | $c >> 18).\chr(0x80 | $c >> 12 & 0x3F).\chr(0x80 | $c >> 6 & 0x3F).\chr(0x80 | $c & 0x3F);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
49
pfosten/vendor/symfony/yaml/Yaml.php
vendored
Executable file → Normal file
49
pfosten/vendor/symfony/yaml/Yaml.php
vendored
Executable file → Normal file
|
|
@ -17,6 +17,8 @@ use Symfony\Component\Yaml\Exception\ParseException;
|
|||
* Yaml offers convenience methods to load and dump YAML.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since version 3.4
|
||||
*/
|
||||
class Yaml
|
||||
{
|
||||
|
|
@ -31,8 +33,35 @@ class Yaml
|
|||
const PARSE_CONSTANT = 256;
|
||||
const PARSE_CUSTOM_TAGS = 512;
|
||||
const DUMP_EMPTY_ARRAY_AS_SEQUENCE = 1024;
|
||||
|
||||
/**
|
||||
* @deprecated since version 3.4, to be removed in 4.0. Quote your evaluable keys instead.
|
||||
*/
|
||||
const PARSE_KEYS_AS_STRINGS = 2048;
|
||||
|
||||
/**
|
||||
* Parses a YAML file into a PHP value.
|
||||
*
|
||||
* Usage:
|
||||
* <code>
|
||||
* $array = Yaml::parseFile('config.yml');
|
||||
* print_r($array);
|
||||
* </code>
|
||||
*
|
||||
* @param string $filename The path to the YAML file to be parsed
|
||||
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
|
||||
*
|
||||
* @return mixed The YAML converted to a PHP value
|
||||
*
|
||||
* @throws ParseException If the file could not be read or the YAML is not valid
|
||||
*/
|
||||
public static function parseFile($filename, $flags = 0)
|
||||
{
|
||||
$yaml = new Parser();
|
||||
|
||||
return $yaml->parseFile($filename, $flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses YAML into a PHP value.
|
||||
*
|
||||
|
|
@ -51,8 +80,8 @@ class Yaml
|
|||
*/
|
||||
public static function parse($input, $flags = 0)
|
||||
{
|
||||
if (is_bool($flags)) {
|
||||
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
|
||||
if (\is_bool($flags)) {
|
||||
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if ($flags) {
|
||||
$flags = self::PARSE_EXCEPTION_ON_INVALID_TYPE;
|
||||
|
|
@ -61,16 +90,16 @@ class Yaml
|
|||
}
|
||||
}
|
||||
|
||||
if (func_num_args() >= 3) {
|
||||
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
|
||||
if (\func_num_args() >= 3) {
|
||||
@trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (func_get_arg(2)) {
|
||||
$flags |= self::PARSE_OBJECT;
|
||||
}
|
||||
}
|
||||
|
||||
if (func_num_args() >= 4) {
|
||||
@trigger_error('Passing a boolean flag to toggle object for map support is deprecated since version 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
|
||||
if (\func_num_args() >= 4) {
|
||||
@trigger_error('Passing a boolean flag to toggle object for map support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (func_get_arg(3)) {
|
||||
$flags |= self::PARSE_OBJECT_FOR_MAP;
|
||||
|
|
@ -97,8 +126,8 @@ class Yaml
|
|||
*/
|
||||
public static function dump($input, $inline = 2, $indent = 4, $flags = 0)
|
||||
{
|
||||
if (is_bool($flags)) {
|
||||
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
|
||||
if (\is_bool($flags)) {
|
||||
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if ($flags) {
|
||||
$flags = self::DUMP_EXCEPTION_ON_INVALID_TYPE;
|
||||
|
|
@ -107,8 +136,8 @@ class Yaml
|
|||
}
|
||||
}
|
||||
|
||||
if (func_num_args() >= 5) {
|
||||
@trigger_error('Passing a boolean flag to toggle object support is deprecated since version 3.1 and will be removed in 4.0. Use the DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
|
||||
if (\func_num_args() >= 5) {
|
||||
@trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (func_get_arg(4)) {
|
||||
$flags |= self::DUMP_OBJECT;
|
||||
|
|
|
|||
10
pfosten/vendor/symfony/yaml/composer.json
vendored
Executable file → Normal file
10
pfosten/vendor/symfony/yaml/composer.json
vendored
Executable file → Normal file
|
|
@ -16,10 +16,14 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.5.9"
|
||||
"php": "^5.5.9|>=7.0.8",
|
||||
"symfony/polyfill-ctype": "~1.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/console": "~2.8|~3.0"
|
||||
"symfony/console": "~3.4|~4.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/console": "<3.4"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/console": "For validating YAML files using the lint command"
|
||||
|
|
@ -33,7 +37,7 @@
|
|||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.3-dev"
|
||||
"dev-master": "3.4-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/yaml/phpunit.xml.dist
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/yaml/phpunit.xml.dist
vendored
Executable file → Normal file
Loading…
Add table
Add a link
Reference in a new issue