🔧
This commit is contained in:
10
vendor/symfony/yaml/CHANGELOG.md
vendored
10
vendor/symfony/yaml/CHANGELOG.md
vendored
@@ -1,6 +1,16 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
7.2
|
||||
---
|
||||
|
||||
* Deprecate parsing duplicate mapping keys whose value is `null`
|
||||
|
||||
7.1
|
||||
---
|
||||
|
||||
* Add support for getting all the enum cases with `!php/enum Foo`
|
||||
|
||||
7.0
|
||||
---
|
||||
|
||||
|
||||
24
vendor/symfony/yaml/Command/LintCommand.php
vendored
24
vendor/symfony/yaml/Command/LintCommand.php
vendored
@@ -42,7 +42,7 @@ class LintCommand extends Command
|
||||
private ?\Closure $directoryIteratorProvider;
|
||||
private ?\Closure $isReadableProvider;
|
||||
|
||||
public function __construct(string $name = null, callable $directoryIteratorProvider = null, callable $isReadableProvider = null)
|
||||
public function __construct(?string $name = null, ?callable $directoryIteratorProvider = null, ?callable $isReadableProvider = null)
|
||||
{
|
||||
parent::__construct($name);
|
||||
|
||||
@@ -54,7 +54,7 @@ class LintCommand extends Command
|
||||
{
|
||||
$this
|
||||
->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN')
|
||||
->addOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())))
|
||||
->addOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())))
|
||||
->addOption('exclude', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Path(s) to exclude')
|
||||
->addOption('parse-tags', null, InputOption::VALUE_NEGATABLE, 'Parse custom tags', null)
|
||||
->setHelp(<<<EOF
|
||||
@@ -72,6 +72,9 @@ You can also validate the syntax of a file:
|
||||
Or of a whole directory:
|
||||
|
||||
<info>php %command.full_name% dirname</info>
|
||||
|
||||
The <info>--format</info> option specifies the format of the command output:
|
||||
|
||||
<info>php %command.full_name% dirname --format=json</info>
|
||||
|
||||
You can also exclude one or more specific files:
|
||||
@@ -111,7 +114,7 @@ EOF
|
||||
$filesInfo = [];
|
||||
foreach ($filenames as $filename) {
|
||||
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));
|
||||
}
|
||||
|
||||
foreach ($this->getFiles($filename) as $file) {
|
||||
@@ -124,7 +127,7 @@ EOF
|
||||
return $this->display($io, $filesInfo);
|
||||
}
|
||||
|
||||
private function validate(string $content, int $flags, string $file = null): array
|
||||
private function validate(string $content, int $flags, ?string $file = null): array
|
||||
{
|
||||
$prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) {
|
||||
if (\E_USER_DEPRECATED === $level) {
|
||||
@@ -151,7 +154,7 @@ EOF
|
||||
'txt' => $this->displayTxt($io, $files),
|
||||
'json' => $this->displayJson($io, $files),
|
||||
'github' => $this->displayTxt($io, $files, true),
|
||||
default => throw new InvalidArgumentException(sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
|
||||
default => throw new InvalidArgumentException(\sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -167,11 +170,11 @@ EOF
|
||||
|
||||
foreach ($filesInfo as $info) {
|
||||
if ($info['valid'] && $this->displayCorrectFiles) {
|
||||
$io->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
|
||||
$io->comment('<info>OK</info>'.($info['file'] ? \sprintf(' in %s', $info['file']) : ''));
|
||||
} elseif (!$info['valid']) {
|
||||
++$erroredFiles;
|
||||
$io->text('<error> ERROR </error>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
|
||||
$io->text(sprintf('<error> >> %s</error>', $info['message']));
|
||||
$io->text('<error> ERROR </error>'.($info['file'] ? \sprintf(' in %s', $info['file']) : ''));
|
||||
$io->text(\sprintf('<error> >> %s</error>', $info['message']));
|
||||
|
||||
if (str_contains($info['message'], 'PARSE_CUSTOM_TAGS')) {
|
||||
$suggestTagOption = true;
|
||||
@@ -184,9 +187,9 @@ EOF
|
||||
}
|
||||
|
||||
if (0 === $erroredFiles) {
|
||||
$io->success(sprintf('All %d YAML files contain valid syntax.', $countFiles));
|
||||
$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.%s', $countFiles - $erroredFiles, $erroredFiles, $suggestTagOption ? ' Use the --parse-tags option if you want parse custom tags.' : ''));
|
||||
$io->warning(\sprintf('%d YAML files have valid syntax and %d contain errors.%s', $countFiles - $erroredFiles, $erroredFiles, $suggestTagOption ? ' Use the --parse-tags option if you want parse custom tags.' : ''));
|
||||
}
|
||||
|
||||
return min($erroredFiles, 1);
|
||||
@@ -266,6 +269,7 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
/** @return string[] */
|
||||
private function getAvailableFormatOptions(): array
|
||||
{
|
||||
return ['txt', 'json', 'github'];
|
||||
|
||||
44
vendor/symfony/yaml/Dumper.php
vendored
44
vendor/symfony/yaml/Dumper.php
vendored
@@ -23,26 +23,22 @@ use Symfony\Component\Yaml\Tag\TaggedValue;
|
||||
class Dumper
|
||||
{
|
||||
/**
|
||||
* The amount of spaces to use for indentation of nested nodes.
|
||||
* @param int $indentation The amount of spaces to use for indentation of nested nodes
|
||||
*/
|
||||
private int $indentation;
|
||||
|
||||
public function __construct(int $indentation = 4)
|
||||
public function __construct(private int $indentation = 4)
|
||||
{
|
||||
if ($indentation < 1) {
|
||||
throw new \InvalidArgumentException('The indentation must be greater than zero.');
|
||||
}
|
||||
|
||||
$this->indentation = $indentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps a PHP value to YAML.
|
||||
*
|
||||
* @param mixed $input The PHP value
|
||||
* @param int $inline The level where you switch to inline YAML
|
||||
* @param int $indent The level of indentation (used internally)
|
||||
* @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
|
||||
* @param mixed $input The PHP value
|
||||
* @param int $inline The level where you switch to inline YAML
|
||||
* @param int $indent The level of indentation (used internally)
|
||||
* @param int-mask-of<Yaml::DUMP_*> $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
|
||||
*/
|
||||
public function dump(mixed $input, int $inline = 0, int $indent = 0, int $flags = 0): string
|
||||
{
|
||||
@@ -51,10 +47,10 @@ class Dumper
|
||||
$dumpObjectAsInlineMap = true;
|
||||
|
||||
if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($input instanceof \ArrayObject || $input instanceof \stdClass)) {
|
||||
$dumpObjectAsInlineMap = empty((array) $input);
|
||||
$dumpObjectAsInlineMap = !(array) $input;
|
||||
}
|
||||
|
||||
if ($inline <= 0 || (!\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap) || empty($input)) {
|
||||
if ($inline <= 0 || (!\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap) || !$input) {
|
||||
$output .= $prefix.Inline::dump($input, $flags);
|
||||
} elseif ($input instanceof TaggedValue) {
|
||||
$output .= $this->dumpTaggedValue($input, $inline, $indent, $flags, $prefix);
|
||||
@@ -81,13 +77,13 @@ class Dumper
|
||||
$blockChompingIndicator = '-';
|
||||
}
|
||||
|
||||
$output .= sprintf('%s%s%s |%s%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator, $blockChompingIndicator);
|
||||
$output .= \sprintf('%s%s%s |%s%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator, $blockChompingIndicator);
|
||||
|
||||
foreach (explode("\n", $value) as $row) {
|
||||
if ('' === $row) {
|
||||
$output .= "\n";
|
||||
} else {
|
||||
$output .= sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
|
||||
$output .= \sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,14 +91,14 @@ class Dumper
|
||||
}
|
||||
|
||||
if ($value instanceof TaggedValue) {
|
||||
$output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag());
|
||||
$output .= \sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag());
|
||||
|
||||
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && str_contains($value->getValue(), "\n") && !str_contains($value->getValue(), "\r\n")) {
|
||||
$blockIndentationIndicator = $this->getBlockIndentationIndicator($value->getValue());
|
||||
$output .= sprintf(' |%s', $blockIndentationIndicator);
|
||||
$output .= \sprintf(' |%s', $blockIndentationIndicator);
|
||||
|
||||
foreach (explode("\n", $value->getValue()) as $row) {
|
||||
$output .= sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
|
||||
$output .= \sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -121,12 +117,12 @@ class Dumper
|
||||
$dumpObjectAsInlineMap = true;
|
||||
|
||||
if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) {
|
||||
$dumpObjectAsInlineMap = empty((array) $value);
|
||||
$dumpObjectAsInlineMap = !(array) $value;
|
||||
}
|
||||
|
||||
$willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || empty($value);
|
||||
$willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || !$value;
|
||||
|
||||
$output .= sprintf('%s%s%s%s',
|
||||
$output .= \sprintf('%s%s%s%s',
|
||||
$prefix,
|
||||
$dumpAsMap ? Inline::dump($key, $flags).':' : '-',
|
||||
$willBeInlined ? ' ' : "\n",
|
||||
@@ -140,14 +136,14 @@ class Dumper
|
||||
|
||||
private function dumpTaggedValue(TaggedValue $value, int $inline, int $indent, int $flags, string $prefix): string
|
||||
{
|
||||
$output = sprintf('%s!%s', $prefix ? $prefix.' ' : '', $value->getTag());
|
||||
$output = \sprintf('%s!%s', $prefix ? $prefix.' ' : '', $value->getTag());
|
||||
|
||||
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && str_contains($value->getValue(), "\n") && !str_contains($value->getValue(), "\r\n")) {
|
||||
$blockIndentationIndicator = $this->getBlockIndentationIndicator($value->getValue());
|
||||
$output .= sprintf(' |%s', $blockIndentationIndicator);
|
||||
$output .= \sprintf(' |%s', $blockIndentationIndicator);
|
||||
|
||||
foreach (explode("\n", $value->getValue()) as $row) {
|
||||
$output .= sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
|
||||
$output .= \sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
|
||||
}
|
||||
|
||||
return $output;
|
||||
@@ -169,7 +165,7 @@ class Dumper
|
||||
// http://www.yaml.org/spec/1.2/spec.html#id2793979
|
||||
foreach ($lines as $line) {
|
||||
if ('' !== trim($line, ' ')) {
|
||||
return (' ' === substr($line, 0, 1)) ? (string) $this->indentation : '';
|
||||
return str_starts_with($line, ' ') ? (string) $this->indentation : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
6
vendor/symfony/yaml/Escaper.php
vendored
6
vendor/symfony/yaml/Escaper.php
vendored
@@ -62,7 +62,7 @@ class Escaper
|
||||
*/
|
||||
public static function escapeWithDoubleQuotes(string $value): string
|
||||
{
|
||||
return sprintf('"%s"', str_replace(self::ESCAPEES, self::ESCAPED, $value));
|
||||
return \sprintf('"%s"', str_replace(self::ESCAPEES, self::ESCAPED, $value));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ class Escaper
|
||||
|
||||
// Determines if the PHP value contains any single characters that would
|
||||
// cause it to require single quoting in YAML.
|
||||
return 0 < preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` \p{Zs}]/xu', $value);
|
||||
return 0 < preg_match('/[\s\'"\:\{\}\[\],&\*\#\?] | \A[\-?|<>=!%@`\p{Zs}]/xu', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,6 +90,6 @@ class Escaper
|
||||
*/
|
||||
public static function escapeWithSingleQuotes(string $value): string
|
||||
{
|
||||
return sprintf("'%s'", str_replace('\'', '\'\'', $value));
|
||||
return \sprintf("'%s'", str_replace('\'', '\'\'', $value));
|
||||
}
|
||||
}
|
||||
|
||||
27
vendor/symfony/yaml/Exception/ParseException.php
vendored
27
vendor/symfony/yaml/Exception/ParseException.php
vendored
@@ -18,24 +18,19 @@ namespace Symfony\Component\Yaml\Exception;
|
||||
*/
|
||||
class ParseException extends RuntimeException
|
||||
{
|
||||
private ?string $parsedFile;
|
||||
private int $parsedLine;
|
||||
private ?string $snippet;
|
||||
private string $rawMessage;
|
||||
|
||||
/**
|
||||
* @param string $message The error message
|
||||
* @param string $rawMessage The error message
|
||||
* @param int $parsedLine The line where the error occurred
|
||||
* @param string|null $snippet The snippet of code near the problem
|
||||
* @param string|null $parsedFile The file name where the error occurred
|
||||
*/
|
||||
public function __construct(string $message, int $parsedLine = -1, string $snippet = null, string $parsedFile = null, \Throwable $previous = null)
|
||||
{
|
||||
$this->parsedFile = $parsedFile;
|
||||
$this->parsedLine = $parsedLine;
|
||||
$this->snippet = $snippet;
|
||||
$this->rawMessage = $message;
|
||||
|
||||
public function __construct(
|
||||
private string $rawMessage,
|
||||
private int $parsedLine = -1,
|
||||
private ?string $snippet = null,
|
||||
private ?string $parsedFile = null,
|
||||
?\Throwable $previous = null,
|
||||
) {
|
||||
$this->updateRepr();
|
||||
|
||||
parent::__construct($this->message, 0, $previous);
|
||||
@@ -108,15 +103,15 @@ class ParseException extends RuntimeException
|
||||
}
|
||||
|
||||
if (null !== $this->parsedFile) {
|
||||
$this->message .= sprintf(' in %s', json_encode($this->parsedFile, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE));
|
||||
$this->message .= \sprintf(' in %s', json_encode($this->parsedFile, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
if ($this->parsedLine >= 0) {
|
||||
$this->message .= sprintf(' at line %d', $this->parsedLine);
|
||||
$this->message .= \sprintf(' at line %d', $this->parsedLine);
|
||||
}
|
||||
|
||||
if ($this->snippet) {
|
||||
$this->message .= sprintf(' (near "%s")', $this->snippet);
|
||||
$this->message .= \sprintf(' (near "%s")', $this->snippet);
|
||||
}
|
||||
|
||||
if ($dot) {
|
||||
|
||||
106
vendor/symfony/yaml/Inline.php
vendored
106
vendor/symfony/yaml/Inline.php
vendored
@@ -34,7 +34,7 @@ class Inline
|
||||
private static bool $objectForMap = false;
|
||||
private static bool $constantSupport = false;
|
||||
|
||||
public static function initialize(int $flags, int $parsedLineNumber = null, string $parsedFilename = null): void
|
||||
public static function initialize(int $flags, ?int $parsedLineNumber = null, ?string $parsedFilename = null): void
|
||||
{
|
||||
self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags);
|
||||
self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags);
|
||||
@@ -82,7 +82,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)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
if (null !== $tag && '' !== $tag) {
|
||||
@@ -105,7 +105,7 @@ class Inline
|
||||
switch (true) {
|
||||
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)));
|
||||
throw new DumpException(\sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value)));
|
||||
}
|
||||
|
||||
return self::dumpNull($flags);
|
||||
@@ -116,7 +116,7 @@ class Inline
|
||||
default => 'Y-m-d\TH:i:s.uP',
|
||||
});
|
||||
case $value instanceof \UnitEnum:
|
||||
return sprintf('!php/const %s::%s', $value::class, $value->name);
|
||||
return \sprintf('!php/enum %s::%s', $value::class, $value->name);
|
||||
case \is_object($value):
|
||||
if ($value instanceof TaggedValue) {
|
||||
return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags);
|
||||
@@ -227,7 +227,7 @@ class Inline
|
||||
$output[] = self::dump($val, $flags);
|
||||
}
|
||||
|
||||
return sprintf('[%s]', implode(', ', $output));
|
||||
return \sprintf('[%s]', implode(', ', $output));
|
||||
}
|
||||
|
||||
return self::dumpHashArray($value, $flags);
|
||||
@@ -247,10 +247,10 @@ class Inline
|
||||
$key = (string) $key;
|
||||
}
|
||||
|
||||
$output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
|
||||
$output[] = \sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
|
||||
}
|
||||
|
||||
return sprintf('{ %s }', implode(', ', $output));
|
||||
return \sprintf('{ %s }', implode(', ', $output));
|
||||
}
|
||||
|
||||
private static function dumpNull(int $flags): string
|
||||
@@ -267,7 +267,7 @@ class Inline
|
||||
*
|
||||
* @throws ParseException When malformed inline YAML string is parsed
|
||||
*/
|
||||
public static function parseScalar(string $scalar, int $flags = 0, array $delimiters = null, int &$i = 0, bool $evaluate = true, array &$references = [], bool &$isQuoted = null): mixed
|
||||
public static function parseScalar(string $scalar, int $flags = 0, ?array $delimiters = null, int &$i = 0, bool $evaluate = true, array &$references = [], ?bool &$isQuoted = null): mixed
|
||||
{
|
||||
if (\in_array($scalar[$i], ['"', "'"], true)) {
|
||||
// quoted scalar
|
||||
@@ -277,10 +277,10 @@ class Inline
|
||||
if (null !== $delimiters) {
|
||||
$tmp = ltrim(substr($scalar, $i), " \n");
|
||||
if ('' === $tmp) {
|
||||
throw new ParseException(sprintf('Unexpected end of line, expected one of "%s".', implode('', $delimiters)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
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);
|
||||
throw new ParseException(\sprintf('Unexpected characters (%s).', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -300,12 +300,12 @@ class Inline
|
||||
$i += \strlen($output);
|
||||
$output = trim($output);
|
||||
} else {
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', $scalar), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('Malformed inline YAML string: "%s".', $scalar), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
}
|
||||
|
||||
// a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >)
|
||||
if ($output && ('@' === $output[0] || '`' === $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]), self::$parsedLineNumber + 1, $output, self::$parsedFilename);
|
||||
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 ($evaluate) {
|
||||
@@ -324,7 +324,7 @@ class Inline
|
||||
private static function parseQuotedScalar(string $scalar, int &$i = 0): string
|
||||
{
|
||||
if (!Parser::preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('Malformed inline YAML string: "%s".', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
$output = substr($match[0], 1, -1);
|
||||
@@ -353,11 +353,18 @@ class Inline
|
||||
++$i;
|
||||
|
||||
// [foo, bar, ...]
|
||||
$lastToken = null;
|
||||
while ($i < $len) {
|
||||
if (']' === $sequence[$i]) {
|
||||
return $output;
|
||||
}
|
||||
if (',' === $sequence[$i] || ' ' === $sequence[$i]) {
|
||||
if (',' === $sequence[$i] && (null === $lastToken || 'separator' === $lastToken)) {
|
||||
$output[] = null;
|
||||
} elseif (',' === $sequence[$i]) {
|
||||
$lastToken = 'separator';
|
||||
}
|
||||
|
||||
++$i;
|
||||
|
||||
continue;
|
||||
@@ -401,10 +408,11 @@ class Inline
|
||||
|
||||
$output[] = $value;
|
||||
|
||||
$lastToken = 'value';
|
||||
++$i;
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('Malformed inline YAML string: "%s".', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -496,7 +504,7 @@ class Inline
|
||||
$output[$key] = $value;
|
||||
}
|
||||
} elseif (isset($output[$key])) {
|
||||
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
|
||||
throw new ParseException(\sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
|
||||
}
|
||||
break;
|
||||
case '{':
|
||||
@@ -515,7 +523,7 @@ class Inline
|
||||
$output[$key] = $value;
|
||||
}
|
||||
} elseif (isset($output[$key])) {
|
||||
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
|
||||
throw new ParseException(\sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -538,7 +546,7 @@ class Inline
|
||||
$output[$key] = $value;
|
||||
}
|
||||
} elseif (isset($output[$key])) {
|
||||
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
|
||||
throw new ParseException(\sprintf('Duplicate key "%s" detected.', $key), self::$parsedLineNumber + 1, $mapping);
|
||||
}
|
||||
--$i;
|
||||
}
|
||||
@@ -548,7 +556,7 @@ class Inline
|
||||
}
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', $mapping), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('Malformed inline YAML string: "%s".', $mapping), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -556,7 +564,7 @@ class Inline
|
||||
*
|
||||
* @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved
|
||||
*/
|
||||
private static function evaluateScalar(string $scalar, int $flags, array &$references = [], bool &$isQuotedString = null): mixed
|
||||
private static function evaluateScalar(string $scalar, int $flags, array &$references = [], ?bool &$isQuotedString = null): mixed
|
||||
{
|
||||
$isQuotedString = false;
|
||||
$scalar = trim($scalar);
|
||||
@@ -569,12 +577,12 @@ class Inline
|
||||
}
|
||||
|
||||
// an unquoted *
|
||||
if (false === $value || '' === $value) {
|
||||
if ('' === $value) {
|
||||
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), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('Reference "%s" does not exist.', $value), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
return $references[$value];
|
||||
@@ -594,7 +602,7 @@ class Inline
|
||||
case '!' === $scalar[0]:
|
||||
switch (true) {
|
||||
case str_starts_with($scalar, '!!str '):
|
||||
$s = (string) substr($scalar, 6);
|
||||
$s = substr($scalar, 6);
|
||||
|
||||
if (\in_array($s[0] ?? '', ['"', "'"], true)) {
|
||||
$isQuotedString = true;
|
||||
@@ -629,10 +637,10 @@ class Inline
|
||||
return \constant($const);
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('The constant "%s" is not defined.', $const), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
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. Did you forget to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('The string "%s" could not be parsed as a constant. Did you forget to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -643,30 +651,37 @@ class Inline
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$enum = self::parseScalar(substr($scalar, 10), 0, null, $i, false);
|
||||
if ($useValue = str_ends_with($enum, '->value')) {
|
||||
$enum = substr($enum, 0, -7);
|
||||
$enumName = self::parseScalar(substr($scalar, 10), 0, null, $i, false);
|
||||
$useName = str_contains($enumName, '::');
|
||||
$enum = $useName ? strstr($enumName, '::', true) : $enumName;
|
||||
|
||||
if (!enum_exists($enum)) {
|
||||
throw new ParseException(\sprintf('The enum "%s" is not defined.', $enum), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
if (!\defined($enum)) {
|
||||
throw new ParseException(sprintf('The enum "%s" is not defined.', $enum), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
if (!$useName) {
|
||||
return $enum::cases();
|
||||
}
|
||||
if ($useValue = str_ends_with($enumName, '->value')) {
|
||||
$enumName = substr($enumName, 0, -7);
|
||||
}
|
||||
|
||||
$value = \constant($enum);
|
||||
|
||||
if (!$value instanceof \UnitEnum) {
|
||||
throw new ParseException(sprintf('The string "%s" is not the name of a valid enum.', $enum), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
if (!\defined($enumName)) {
|
||||
throw new ParseException(\sprintf('The string "%s" is not the name of a valid enum.', $enumName), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
$value = \constant($enumName);
|
||||
|
||||
if (!$useValue) {
|
||||
return $value;
|
||||
}
|
||||
if (!$value instanceof \BackedEnum) {
|
||||
throw new ParseException(sprintf('The enum "%s" defines no value next to its name.', $enum), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('The enum "%s" defines no value next to its name.', $enumName), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
return $value->value;
|
||||
}
|
||||
if (self::$exceptionOnInvalidType) {
|
||||
throw new ParseException(sprintf('The string "%s" could not be parsed as an enum. Did you forget to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('The string "%s" could not be parsed as an enum. Did you forget to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -676,7 +691,7 @@ class Inline
|
||||
return self::evaluateBinaryScalar(substr($scalar, 9));
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('The string "%s" could not be parsed as it uses an unsupported built-in tag.', $scalar), self::$parsedLineNumber, $scalar, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('The string "%s" could not be parsed as it uses an unsupported built-in tag.', $scalar), self::$parsedLineNumber, $scalar, self::$parsedFilename);
|
||||
case preg_match('/^(?:\+|-)?0o(?P<value>[0-7_]++)$/', $scalar, $matches):
|
||||
$value = str_replace('_', '', $matches['value']);
|
||||
|
||||
@@ -709,8 +724,13 @@ class Inline
|
||||
case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar):
|
||||
return (float) str_replace('_', '', $scalar);
|
||||
case Parser::preg_match(self::getTimestampRegex(), $scalar):
|
||||
// When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
|
||||
$time = new \DateTimeImmutable($scalar, new \DateTimeZone('UTC'));
|
||||
try {
|
||||
// When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
|
||||
$time = new \DateTimeImmutable($scalar, new \DateTimeZone('UTC'));
|
||||
} catch (\Exception $e) {
|
||||
// Some dates accepted by the regex are not valid dates.
|
||||
throw new ParseException(\sprintf('The date "%s" could not be parsed as it is an invalid date.', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename, $e);
|
||||
}
|
||||
|
||||
if (Yaml::PARSE_DATETIME & $flags) {
|
||||
return $time;
|
||||
@@ -761,18 +781,18 @@ class Inline
|
||||
|
||||
// Built-in tags
|
||||
if ('' !== $tag && '!' === $tag[0]) {
|
||||
throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('The built-in tag "!%s" is not implemented.', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
if ('' !== $tag && !isset($value[$i])) {
|
||||
throw new ParseException(sprintf('Missing value for tag "%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('Missing value for tag "%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
|
||||
}
|
||||
|
||||
if ('' === $tag || Yaml::PARSE_CUSTOM_TAGS & $flags) {
|
||||
return $tag;
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
public static function evaluateBinaryScalar(string $scalar): string
|
||||
@@ -780,11 +800,11 @@ 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)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
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), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('The base64 encoded data (%s) contains invalid characters.', $parsedBinaryData), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
return base64_decode($parsedBinaryData, true);
|
||||
|
||||
91
vendor/symfony/yaml/Parser.php
vendored
91
vendor/symfony/yaml/Parser.php
vendored
@@ -42,19 +42,19 @@ class Parser
|
||||
/**
|
||||
* 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 Yaml::PARSE_* constants to customize the YAML parser behavior
|
||||
* @param string $filename The path to the YAML file to be parsed
|
||||
* @param int-mask-of<Yaml::PARSE_*> $flags A bit field of Yaml::PARSE_* constants to customize the YAML parser behavior
|
||||
*
|
||||
* @throws ParseException If the file could not be read or the YAML is not valid
|
||||
*/
|
||||
public function parseFile(string $filename, int $flags = 0): mixed
|
||||
{
|
||||
if (!is_file($filename)) {
|
||||
throw new ParseException(sprintf('File "%s" does not exist.', $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));
|
||||
throw new ParseException(\sprintf('File "%s" cannot be read.', $filename));
|
||||
}
|
||||
|
||||
$this->filename = $filename;
|
||||
@@ -69,8 +69,8 @@ class Parser
|
||||
/**
|
||||
* Parses a YAML string to a PHP value.
|
||||
*
|
||||
* @param string $value A YAML string
|
||||
* @param int $flags A bit field of Yaml::PARSE_* constants to customize the YAML parser behavior
|
||||
* @param string $value A YAML string
|
||||
* @param int-mask-of<Yaml::PARSE_*> $flags A bit field of Yaml::PARSE_* constants to customize the YAML parser behavior
|
||||
*
|
||||
* @throws ParseException If the YAML is not valid
|
||||
*/
|
||||
@@ -230,10 +230,10 @@ class Parser
|
||||
$refName = substr(rtrim($values['value']), 1);
|
||||
if (!\array_key_exists($refName, $this->refs)) {
|
||||
if (false !== $pos = array_search($refName, $this->refsBeingParsed, true)) {
|
||||
throw new ParseException(sprintf('Circular reference [%s] detected for reference "%s".', implode(', ', array_merge(\array_slice($this->refsBeingParsed, $pos), [$refName])), $refName), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
throw new ParseException(\sprintf('Circular reference [%s] detected for reference "%s".', implode(', ', array_merge(\array_slice($this->refsBeingParsed, $pos), [$refName])), $refName), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('Reference "%s" does not exist.', $refName), $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
throw new ParseException(\sprintf('Reference "%s" does not exist.', $refName), $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
$refValue = $this->refs[$refName];
|
||||
@@ -300,13 +300,17 @@ class Parser
|
||||
// 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 (!$allowOverwrite && \array_key_exists($key, $data)) {
|
||||
trigger_deprecation('symfony/yaml', '7.2', 'Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated and will throw a ParseException in 8.0.', $key, $this->getRealCurrentLineNb() + 1);
|
||||
}
|
||||
|
||||
if (null !== $subTag) {
|
||||
$data[$key] = new TaggedValue($subTag, '');
|
||||
} else {
|
||||
$data[$key] = null;
|
||||
}
|
||||
} else {
|
||||
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
throw new ParseException(\sprintf('Duplicate key "%s" detected.', $key), $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
}
|
||||
} else {
|
||||
// remember the parsed line number here in case we need it to provide some contexts in error messages below
|
||||
@@ -321,6 +325,10 @@ class Parser
|
||||
|
||||
$data += $value;
|
||||
} elseif ($allowOverwrite || !isset($data[$key])) {
|
||||
if (!$allowOverwrite && \array_key_exists($key, $data)) {
|
||||
trigger_deprecation('symfony/yaml', '7.2', 'Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated and will throw a ParseException in 8.0.', $key, $this->getRealCurrentLineNb() + 1);
|
||||
}
|
||||
|
||||
// Spec: Keys MUST be unique; first one wins.
|
||||
// But overwriting is allowed when a merge node is used in current block.
|
||||
if (null !== $subTag) {
|
||||
@@ -329,7 +337,7 @@ class Parser
|
||||
$data[$key] = $value;
|
||||
}
|
||||
} else {
|
||||
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $realCurrentLineNbKey + 1, $this->currentLine);
|
||||
throw new ParseException(\sprintf('Duplicate key "%s" detected.', $key), $realCurrentLineNbKey + 1, $this->currentLine);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -337,9 +345,13 @@ class Parser
|
||||
// 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 (!$allowOverwrite && \array_key_exists($key, $data)) {
|
||||
trigger_deprecation('symfony/yaml', '7.2', 'Duplicate key "%s" detected on line %d whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated and will throw a ParseException in 8.0.', $key, $this->getRealCurrentLineNb() + 1);
|
||||
}
|
||||
|
||||
$data[$key] = $value;
|
||||
} else {
|
||||
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
throw new ParseException(\sprintf('Duplicate key "%s" detected.', $key), $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
}
|
||||
}
|
||||
if ($isRef) {
|
||||
@@ -494,7 +506,7 @@ class Parser
|
||||
$data = $object;
|
||||
}
|
||||
|
||||
return empty($data) ? null : $data;
|
||||
return $data ?: null;
|
||||
}
|
||||
|
||||
private function parseBlock(int $offset, string $yaml, int $flags): mixed
|
||||
@@ -556,7 +568,7 @@ class Parser
|
||||
*
|
||||
* @throws ParseException When indentation problem are detected
|
||||
*/
|
||||
private function getNextEmbedBlock(int $indentation = null, bool $inSequence = false): string
|
||||
private function getNextEmbedBlock(?int $indentation = null, bool $inSequence = false): string
|
||||
{
|
||||
$oldLineIndentation = $this->getCurrentLineIndentation();
|
||||
|
||||
@@ -633,12 +645,12 @@ class Parser
|
||||
}
|
||||
|
||||
if ($this->isCurrentLineBlank()) {
|
||||
$data[] = substr($this->currentLine, $newIndent);
|
||||
$data[] = substr($this->currentLine, $newIndent ?? 0);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($indent >= $newIndent) {
|
||||
$data[] = substr($this->currentLine, $newIndent);
|
||||
$data[] = substr($this->currentLine, $newIndent ?? 0);
|
||||
} elseif ($this->isCurrentLineComment()) {
|
||||
$data[] = $this->currentLine;
|
||||
} elseif (0 == $indent) {
|
||||
@@ -706,10 +718,10 @@ class Parser
|
||||
|
||||
if (!\array_key_exists($value, $this->refs)) {
|
||||
if (false !== $pos = array_search($value, $this->refsBeingParsed, true)) {
|
||||
throw new ParseException(sprintf('Circular reference [%s] detected for reference "%s".', implode(', ', array_merge(\array_slice($this->refsBeingParsed, $pos), [$value])), $value), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
throw new ParseException(\sprintf('Circular reference [%s] detected for reference "%s".', implode(', ', array_merge(\array_slice($this->refsBeingParsed, $pos), [$value])), $value), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
throw new ParseException(\sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
return $this->refs[$value];
|
||||
@@ -749,7 +761,7 @@ class Parser
|
||||
$parsedValue = Inline::parse($this->lexInlineQuotedString($cursor), $flags, $this->refs);
|
||||
|
||||
if (isset($this->currentLine[$cursor]) && preg_replace('/\s*(#.*)?$/A', '', substr($this->currentLine, $cursor))) {
|
||||
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($this->currentLine, $cursor)));
|
||||
throw new ParseException(\sprintf('Unexpected characters near "%s".', substr($this->currentLine, $cursor)));
|
||||
}
|
||||
|
||||
return $parsedValue;
|
||||
@@ -834,7 +846,7 @@ class Parser
|
||||
}
|
||||
|
||||
if ($indentation > 0) {
|
||||
$pattern = sprintf('/^ {%d}(.*)$/', $indentation);
|
||||
$pattern = \sprintf('/^ {%d}(.*)$/', $indentation);
|
||||
|
||||
while (
|
||||
$notEOF && (
|
||||
@@ -862,7 +874,7 @@ class Parser
|
||||
if ($notEOF) {
|
||||
$blockLines[] = '';
|
||||
$this->moveToPreviousLine();
|
||||
} elseif (!$notEOF && !$this->isCurrentLineLastLineInDocument()) {
|
||||
} elseif (!$this->isCurrentLineLastLineInDocument()) {
|
||||
$blockLines[] = '';
|
||||
}
|
||||
|
||||
@@ -1038,7 +1050,7 @@ class Parser
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function preg_match(string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int
|
||||
public static function preg_match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
|
||||
{
|
||||
if (false === $ret = preg_match($pattern, $subject, $matches, $flags, $offset)) {
|
||||
throw new ParseException(preg_last_error_msg());
|
||||
@@ -1076,14 +1088,14 @@ class Parser
|
||||
|
||||
// Built-in tags
|
||||
if ($tag && '!' === $tag[0]) {
|
||||
throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), $this->getRealCurrentLineNb() + 1, $value, $this->filename);
|
||||
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']), $this->getRealCurrentLineNb() + 1, $value, $this->filename);
|
||||
throw new ParseException(\sprintf('Tags support is not enabled. You must use the flag "Yaml::PARSE_CUSTOM_TAGS" to use "%s".', $matches['tag']), $this->getRealCurrentLineNb() + 1, $value, $this->filename);
|
||||
}
|
||||
|
||||
private function lexInlineQuotedString(int &$cursor = 0): string
|
||||
@@ -1153,7 +1165,18 @@ class Parser
|
||||
private function lexUnquotedString(int &$cursor): string
|
||||
{
|
||||
$offset = $cursor;
|
||||
$cursor += strcspn($this->currentLine, '[]{},: ', $cursor);
|
||||
|
||||
while ($cursor < strlen($this->currentLine)) {
|
||||
if (in_array($this->currentLine[$cursor], ['[', ']', '{', '}', ',', ':'], true)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (\in_array($this->currentLine[$cursor], [' ', "\t"], true) && '#' === ($this->currentLine[$cursor + 1] ?? '')) {
|
||||
break;
|
||||
}
|
||||
|
||||
++$cursor;
|
||||
}
|
||||
|
||||
if ($cursor === $offset) {
|
||||
throw new ParseException('Malformed unquoted YAML string.');
|
||||
@@ -1162,17 +1185,17 @@ class Parser
|
||||
return substr($this->currentLine, $offset, $cursor - $offset);
|
||||
}
|
||||
|
||||
private function lexInlineMapping(int &$cursor = 0): string
|
||||
private function lexInlineMapping(int &$cursor = 0, bool $consumeUntilEol = true): string
|
||||
{
|
||||
return $this->lexInlineStructure($cursor, '}');
|
||||
return $this->lexInlineStructure($cursor, '}', $consumeUntilEol);
|
||||
}
|
||||
|
||||
private function lexInlineSequence(int &$cursor = 0): string
|
||||
private function lexInlineSequence(int &$cursor = 0, bool $consumeUntilEol = true): string
|
||||
{
|
||||
return $this->lexInlineStructure($cursor, ']');
|
||||
return $this->lexInlineStructure($cursor, ']', $consumeUntilEol);
|
||||
}
|
||||
|
||||
private function lexInlineStructure(int &$cursor, string $closingTag): string
|
||||
private function lexInlineStructure(int &$cursor, string $closingTag, bool $consumeUntilEol = true): string
|
||||
{
|
||||
$value = $this->currentLine[$cursor];
|
||||
++$cursor;
|
||||
@@ -1192,15 +1215,19 @@ class Parser
|
||||
++$cursor;
|
||||
break;
|
||||
case '{':
|
||||
$value .= $this->lexInlineMapping($cursor);
|
||||
$value .= $this->lexInlineMapping($cursor, false);
|
||||
break;
|
||||
case '[':
|
||||
$value .= $this->lexInlineSequence($cursor);
|
||||
$value .= $this->lexInlineSequence($cursor, false);
|
||||
break;
|
||||
case $closingTag:
|
||||
$value .= $this->currentLine[$cursor];
|
||||
++$cursor;
|
||||
|
||||
if ($consumeUntilEol && isset($this->currentLine[$cursor]) && ($whitespaces = strspn($this->currentLine, ' ', $cursor) + $cursor) < strlen($this->currentLine) && '#' !== $this->currentLine[$whitespaces]) {
|
||||
throw new ParseException(sprintf('Unexpected token "%s".', trim(substr($this->currentLine, $cursor))));
|
||||
}
|
||||
|
||||
return $value;
|
||||
case '#':
|
||||
break 2;
|
||||
@@ -1226,7 +1253,7 @@ class Parser
|
||||
$whitespacesConsumed = 0;
|
||||
|
||||
do {
|
||||
$whitespaceOnlyTokenLength = strspn($this->currentLine, ' ', $cursor);
|
||||
$whitespaceOnlyTokenLength = strspn($this->currentLine, " \t", $cursor);
|
||||
$whitespacesConsumed += $whitespaceOnlyTokenLength;
|
||||
$cursor += $whitespaceOnlyTokenLength;
|
||||
|
||||
|
||||
0
vendor/symfony/yaml/Resources/bin/yaml-lint
vendored
Normal file → Executable file
0
vendor/symfony/yaml/Resources/bin/yaml-lint
vendored
Normal file → Executable file
11
vendor/symfony/yaml/Tag/TaggedValue.php
vendored
11
vendor/symfony/yaml/Tag/TaggedValue.php
vendored
@@ -17,13 +17,10 @@ namespace Symfony\Component\Yaml\Tag;
|
||||
*/
|
||||
final class TaggedValue
|
||||
{
|
||||
private string $tag;
|
||||
private mixed $value;
|
||||
|
||||
public function __construct(string $tag, mixed $value)
|
||||
{
|
||||
$this->tag = $tag;
|
||||
$this->value = $value;
|
||||
public function __construct(
|
||||
private string $tag,
|
||||
private mixed $value,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getTag(): string
|
||||
|
||||
2
vendor/symfony/yaml/Unescaper.php
vendored
2
vendor/symfony/yaml/Unescaper.php
vendored
@@ -84,7 +84,7 @@ class Unescaper
|
||||
'x' => self::utf8chr(hexdec(substr($value, 2, 2))),
|
||||
'u' => self::utf8chr(hexdec(substr($value, 2, 4))),
|
||||
'U' => self::utf8chr(hexdec(substr($value, 2, 8))),
|
||||
default => throw new ParseException(sprintf('Found unknown escape character "%s".', $value)),
|
||||
default => throw new ParseException(\sprintf('Found unknown escape character "%s".', $value)),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
16
vendor/symfony/yaml/Yaml.php
vendored
16
vendor/symfony/yaml/Yaml.php
vendored
@@ -44,8 +44,8 @@ class Yaml
|
||||
* $array = Yaml::parseFile('config.yml');
|
||||
* print_r($array);
|
||||
*
|
||||
* @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
|
||||
* @param string $filename The path to the YAML file to be parsed
|
||||
* @param int-mask-of<self::PARSE_*> $flags A bit field of PARSE_* constants to customize the YAML parser behavior
|
||||
*
|
||||
* @throws ParseException If the file could not be read or the YAML is not valid
|
||||
*/
|
||||
@@ -65,8 +65,8 @@ class Yaml
|
||||
* print_r($array);
|
||||
* </code>
|
||||
*
|
||||
* @param string $input A string containing YAML
|
||||
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
|
||||
* @param string $input A string containing YAML
|
||||
* @param int-mask-of<self::PARSE_*> $flags A bit field of PARSE_* constants to customize the YAML parser behavior
|
||||
*
|
||||
* @throws ParseException If the YAML is not valid
|
||||
*/
|
||||
@@ -83,10 +83,10 @@ class Yaml
|
||||
* The dump method, when supplied with an array, will do its best
|
||||
* to convert the array into friendly YAML.
|
||||
*
|
||||
* @param mixed $input The PHP value
|
||||
* @param int $inline The level where you switch to inline YAML
|
||||
* @param int $indent The amount of spaces to use for indentation of nested nodes
|
||||
* @param int $flags A bit field of DUMP_* constants to customize the dumped YAML string
|
||||
* @param mixed $input The PHP value
|
||||
* @param int $inline The level where you switch to inline YAML
|
||||
* @param int $indent The amount of spaces to use for indentation of nested nodes
|
||||
* @param int-mask-of<self::DUMP_*> $flags A bit field of DUMP_* constants to customize the dumped YAML string
|
||||
*/
|
||||
public static function dump(mixed $input, int $inline = 2, int $indent = 4, int $flags = 0): string
|
||||
{
|
||||
|
||||
1
vendor/symfony/yaml/composer.json
vendored
1
vendor/symfony/yaml/composer.json
vendored
@@ -17,6 +17,7 @@
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.2",
|
||||
"symfony/deprecation-contracts": "^2.5|^3.0",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
},
|
||||
"require-dev": {
|
||||
|
||||
Reference in New Issue
Block a user