Update to Kirby 5
This commit is contained in:
parent
5d9979fca8
commit
0fefc5e2e1
472 changed files with 30853 additions and 10301 deletions
|
@ -50,14 +50,11 @@ class LintCommand extends Command
|
|||
$this->isReadableProvider = null === $isReadableProvider ? null : $isReadableProvider(...);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
protected function configure(): void
|
||||
{
|
||||
$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
|
||||
|
@ -75,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:
|
||||
|
@ -114,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) {
|
||||
|
@ -154,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()))),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -170,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;
|
||||
|
@ -187,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);
|
||||
|
@ -269,6 +269,7 @@ EOF
|
|||
}
|
||||
}
|
||||
|
||||
/** @return string[] */
|
||||
private function getAvailableFormatOptions(): array
|
||||
{
|
||||
return ['txt', 'json', 'github'];
|
||||
|
|
72
kirby/vendor/symfony/yaml/Dumper.php
vendored
72
kirby/vendor/symfony/yaml/Dumper.php
vendored
|
@ -23,43 +23,49 @@ 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
|
||||
{
|
||||
if ($flags & Yaml::DUMP_NULL_AS_EMPTY && $flags & Yaml::DUMP_NULL_AS_TILDE) {
|
||||
throw new \InvalidArgumentException('The Yaml::DUMP_NULL_AS_EMPTY and Yaml::DUMP_NULL_AS_TILDE flags cannot be used together.');
|
||||
}
|
||||
|
||||
return $this->doDump($input, $inline, $indent, $flags);
|
||||
}
|
||||
|
||||
private function doDump(mixed $input, int $inline = 0, int $indent = 0, int $flags = 0, int $nestingLevel = 0): string
|
||||
{
|
||||
$output = '';
|
||||
$prefix = $indent ? str_repeat(' ', $indent) : '';
|
||||
$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)) {
|
||||
$output .= $prefix.Inline::dump($input, $flags);
|
||||
if ($inline <= 0 || (!\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap) || !$input) {
|
||||
$output .= $prefix.Inline::dump($input, $flags, 0 === $nestingLevel);
|
||||
} elseif ($input instanceof TaggedValue) {
|
||||
$output .= $this->dumpTaggedValue($input, $inline, $indent, $flags, $prefix);
|
||||
$output .= $this->dumpTaggedValue($input, $inline, $indent, $flags, $prefix, $nestingLevel);
|
||||
} else {
|
||||
$dumpAsMap = Inline::isHash($input);
|
||||
$compactNestedMapping = Yaml::DUMP_COMPACT_NESTED_MAPPING & $flags && !$dumpAsMap;
|
||||
|
||||
foreach ($input as $key => $value) {
|
||||
if ('' !== $output && "\n" !== $output[-1]) {
|
||||
|
@ -81,13 +87,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,24 +101,24 @@ 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;
|
||||
}
|
||||
|
||||
if ($inline - 1 <= 0 || null === $value->getValue() || \is_scalar($value->getValue())) {
|
||||
$output .= ' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n";
|
||||
$output .= ' '.$this->doDump($value->getValue(), $inline - 1, 0, $flags, $nestingLevel + 1)."\n";
|
||||
} else {
|
||||
$output .= "\n";
|
||||
$output .= $this->dump($value->getValue(), $inline - 1, $dumpAsMap ? $indent + $this->indentation : $indent + 2, $flags);
|
||||
$output .= $this->doDump($value->getValue(), $inline - 1, $dumpAsMap ? $indent + $this->indentation : $indent + 2, $flags, $nestingLevel + 1);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
@ -121,16 +127,16 @@ 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",
|
||||
$this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $flags)
|
||||
$willBeInlined || ($compactNestedMapping && \is_array($value) && Inline::isHash($value)) ? ' ' : "\n",
|
||||
$compactNestedMapping && \is_array($value) && Inline::isHash($value) ? substr($this->doDump($value, $inline - 1, $indent + 2, $flags, $nestingLevel + 1), $indent + 2) : $this->doDump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $flags, $nestingLevel + 1)
|
||||
).($willBeInlined ? "\n" : '');
|
||||
}
|
||||
}
|
||||
|
@ -138,26 +144,26 @@ class Dumper
|
|||
return $output;
|
||||
}
|
||||
|
||||
private function dumpTaggedValue(TaggedValue $value, int $inline, int $indent, int $flags, string $prefix): string
|
||||
private function dumpTaggedValue(TaggedValue $value, int $inline, int $indent, int $flags, string $prefix, int $nestingLevel): 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;
|
||||
}
|
||||
|
||||
if ($inline - 1 <= 0 || null === $value->getValue() || \is_scalar($value->getValue())) {
|
||||
return $output.' '.$this->dump($value->getValue(), $inline - 1, 0, $flags)."\n";
|
||||
return $output.' '.$this->doDump($value->getValue(), $inline - 1, 0, $flags, $nestingLevel + 1)."\n";
|
||||
}
|
||||
|
||||
return $output."\n".$this->dump($value->getValue(), $inline - 1, $indent, $flags);
|
||||
return $output."\n".$this->doDump($value->getValue(), $inline - 1, $indent, $flags, $nestingLevel + 1);
|
||||
}
|
||||
|
||||
private function getBlockIndentationIndicator(string $value): string
|
||||
|
@ -169,7 +175,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 : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
40
kirby/vendor/symfony/yaml/Escaper.php
vendored
40
kirby/vendor/symfony/yaml/Escaper.php
vendored
|
@ -28,22 +28,24 @@ class Escaper
|
|||
// first to ensure proper escaping because str_replace operates iteratively
|
||||
// on the input arrays. This ordering of the characters avoids the use of strtr,
|
||||
// which performs more slowly.
|
||||
private const ESCAPEES = ['\\', '\\\\', '\\"', '"',
|
||||
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
|
||||
"\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
|
||||
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
|
||||
"\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
|
||||
"\x7f",
|
||||
"\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",
|
||||
];
|
||||
private const ESCAPED = ['\\\\', '\\"', '\\\\', '\\"',
|
||||
'\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a',
|
||||
'\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f',
|
||||
'\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17',
|
||||
'\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f',
|
||||
'\\x7f',
|
||||
'\\N', '\\_', '\\L', '\\P',
|
||||
];
|
||||
private const ESCAPEES = [
|
||||
'\\', '\\\\', '\\"', '"',
|
||||
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
|
||||
"\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
|
||||
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
|
||||
"\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
|
||||
"\x7f",
|
||||
"\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",
|
||||
];
|
||||
private const ESCAPED = [
|
||||
'\\\\', '\\"', '\\\\', '\\"',
|
||||
'\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a',
|
||||
'\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f',
|
||||
'\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17',
|
||||
'\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f',
|
||||
'\\x7f',
|
||||
'\\N', '\\_', '\\L', '\\P',
|
||||
];
|
||||
|
||||
/**
|
||||
* Determines if a PHP value would require double quoting in YAML.
|
||||
|
@ -62,7 +64,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 +82,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 +92,6 @@ class Escaper
|
|||
*/
|
||||
public static function escapeWithSingleQuotes(string $value): string
|
||||
{
|
||||
return sprintf("'%s'", str_replace('\'', '\'\'', $value));
|
||||
return \sprintf("'%s'", str_replace('\'', '\'\'', $value));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
@ -51,10 +46,8 @@ class ParseException extends RuntimeException
|
|||
|
||||
/**
|
||||
* Sets the snippet of code near the error.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setSnippet(string $snippet)
|
||||
public function setSnippet(string $snippet): void
|
||||
{
|
||||
$this->snippet = $snippet;
|
||||
|
||||
|
@ -73,10 +66,8 @@ class ParseException extends RuntimeException
|
|||
|
||||
/**
|
||||
* Sets the filename where the error occurred.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setParsedFile(string $parsedFile)
|
||||
public function setParsedFile(string $parsedFile): void
|
||||
{
|
||||
$this->parsedFile = $parsedFile;
|
||||
|
||||
|
@ -93,10 +84,8 @@ class ParseException extends RuntimeException
|
|||
|
||||
/**
|
||||
* Sets the line where the error occurred.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setParsedLine(int $parsedLine)
|
||||
public function setParsedLine(int $parsedLine): void
|
||||
{
|
||||
$this->parsedLine = $parsedLine;
|
||||
|
||||
|
@ -114,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) {
|
||||
|
|
97
kirby/vendor/symfony/yaml/Inline.php
vendored
97
kirby/vendor/symfony/yaml/Inline.php
vendored
|
@ -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) {
|
||||
|
@ -100,12 +100,12 @@ class Inline
|
|||
*
|
||||
* @throws DumpException When trying to dump PHP resource
|
||||
*/
|
||||
public static function dump(mixed $value, int $flags = 0): string
|
||||
public static function dump(mixed $value, int $flags = 0, bool $rootLevel = false): string
|
||||
{
|
||||
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);
|
||||
|
@ -138,7 +138,7 @@ class Inline
|
|||
case \is_array($value):
|
||||
return self::dumpArray($value, $flags);
|
||||
case null === $value:
|
||||
return self::dumpNull($flags);
|
||||
return self::dumpNull($flags, $rootLevel);
|
||||
case true === $value:
|
||||
return 'true';
|
||||
case false === $value:
|
||||
|
@ -173,6 +173,7 @@ class Inline
|
|||
case self::isBinaryString($value):
|
||||
return '!!binary '.base64_encode($value);
|
||||
case Escaper::requiresDoubleQuoting($value):
|
||||
case Yaml::DUMP_FORCE_DOUBLE_QUOTES_ON_VALUES & $flags:
|
||||
return Escaper::escapeWithDoubleQuotes($value);
|
||||
case Escaper::requiresSingleQuoting($value):
|
||||
$singleQuoted = Escaper::escapeWithSingleQuotes($value);
|
||||
|
@ -227,7 +228,7 @@ class Inline
|
|||
$output[] = self::dump($val, $flags);
|
||||
}
|
||||
|
||||
return sprintf('[%s]', implode(', ', $output));
|
||||
return \sprintf('[%s]', implode(', ', $output));
|
||||
}
|
||||
|
||||
return self::dumpHashArray($value, $flags);
|
||||
|
@ -242,23 +243,28 @@ class Inline
|
|||
private static function dumpHashArray(array|\ArrayObject|\stdClass $value, int $flags): string
|
||||
{
|
||||
$output = [];
|
||||
$keyFlags = $flags &~ Yaml::DUMP_FORCE_DOUBLE_QUOTES_ON_VALUES;
|
||||
foreach ($value as $key => $val) {
|
||||
if (\is_int($key) && Yaml::DUMP_NUMERIC_KEY_AS_STRING & $flags) {
|
||||
$key = (string) $key;
|
||||
}
|
||||
|
||||
$output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
|
||||
$output[] = \sprintf('%s: %s', self::dump($key, $keyFlags), self::dump($val, $flags));
|
||||
}
|
||||
|
||||
return sprintf('{ %s }', implode(', ', $output));
|
||||
return \sprintf('{ %s }', implode(', ', $output));
|
||||
}
|
||||
|
||||
private static function dumpNull(int $flags): string
|
||||
private static function dumpNull(int $flags, bool $rootLevel = false): string
|
||||
{
|
||||
if (Yaml::DUMP_NULL_AS_TILDE & $flags) {
|
||||
return '~';
|
||||
}
|
||||
|
||||
if (Yaml::DUMP_NULL_AS_EMPTY & $flags && !$rootLevel) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return 'null';
|
||||
}
|
||||
|
||||
|
@ -277,10 +283,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 +306,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 +330,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);
|
||||
|
@ -412,7 +418,7 @@ class Inline
|
|||
++$i;
|
||||
}
|
||||
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
throw new ParseException(\sprintf('Malformed inline YAML string: "%s".', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -504,7 +510,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 '{':
|
||||
|
@ -523,7 +529,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:
|
||||
|
@ -546,7 +552,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;
|
||||
}
|
||||
|
@ -556,7 +562,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -577,12 +583,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];
|
||||
|
@ -602,7 +608,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;
|
||||
|
@ -637,10 +643,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;
|
||||
|
@ -651,30 +657,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;
|
||||
|
@ -684,7 +697,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']);
|
||||
|
||||
|
@ -737,7 +750,7 @@ class Inline
|
|||
if (false !== $scalar = $time->getTimestamp()) {
|
||||
return $scalar;
|
||||
}
|
||||
} catch (\ValueError) {
|
||||
} catch (\DateRangeError|\ValueError) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
|
@ -774,18 +787,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
|
||||
|
@ -793,11 +806,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);
|
||||
|
|
69
kirby/vendor/symfony/yaml/Parser.php
vendored
69
kirby/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
|
||||
*/
|
||||
|
@ -197,14 +197,9 @@ class Parser
|
|||
array_pop($this->refsBeingParsed);
|
||||
}
|
||||
} elseif (
|
||||
// @todo in 7.0 remove legacy "(?:!?!php/const:)?"
|
||||
self::preg_match('#^(?P<key>(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(( |\t)++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
|
||||
self::preg_match('#^(?P<key>(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{!].*?)) *\:(( |\t)++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
|
||||
&& (!str_contains($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"]))
|
||||
) {
|
||||
if (str_starts_with($values['key'], '!php/const:')) {
|
||||
trigger_deprecation('symfony/yaml', '6.2', 'YAML syntax for key "%s" is deprecated and replaced by "!php/const %s".', $values['key'], substr($values['key'], 11));
|
||||
}
|
||||
|
||||
if ($context && 'sequence' == $context) {
|
||||
throw new ParseException('You cannot define a mapping item when in a sequence.', $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
@ -235,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];
|
||||
|
@ -305,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
|
||||
|
@ -326,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) {
|
||||
|
@ -334,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 {
|
||||
|
@ -342,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) {
|
||||
|
@ -412,7 +419,7 @@ class Parser
|
|||
throw new ParseException('Multiple documents are not supported.', $this->currentLineNb + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
if ($deprecatedUsage = (isset($this->currentLine[1]) && '?' === $this->currentLine[0] && ' ' === $this->currentLine[1])) {
|
||||
if (isset($this->currentLine[1]) && '?' === $this->currentLine[0] && ' ' === $this->currentLine[1]) {
|
||||
throw new ParseException('Complex mappings are not supported.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
}
|
||||
|
||||
|
@ -442,7 +449,7 @@ class Parser
|
|||
continue;
|
||||
}
|
||||
// If the indentation is not consistent at offset 0, it is to be considered as a ParseError
|
||||
if (0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0]) {
|
||||
if (0 === $this->offset && isset($line[0]) && ' ' === $line[0]) {
|
||||
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
|
@ -499,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
|
||||
|
@ -711,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];
|
||||
|
@ -754,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;
|
||||
|
@ -839,7 +846,7 @@ class Parser
|
|||
}
|
||||
|
||||
if ($indentation > 0) {
|
||||
$pattern = sprintf('/^ {%d}(.*)$/', $indentation);
|
||||
$pattern = \sprintf('/^ {%d}(.*)$/', $indentation);
|
||||
|
||||
while (
|
||||
$notEOF && (
|
||||
|
@ -867,7 +874,7 @@ class Parser
|
|||
if ($notEOF) {
|
||||
$blockLines[] = '';
|
||||
$this->moveToPreviousLine();
|
||||
} elseif (!$notEOF && !$this->isCurrentLineLastLineInDocument()) {
|
||||
} elseif (!$this->isCurrentLineLastLineInDocument()) {
|
||||
$blockLines[] = '';
|
||||
}
|
||||
|
||||
|
@ -1081,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
|
||||
|
@ -1159,8 +1166,8 @@ class Parser
|
|||
{
|
||||
$offset = $cursor;
|
||||
|
||||
while ($cursor < strlen($this->currentLine)) {
|
||||
if (in_array($this->currentLine[$cursor], ['[', ']', '{', '}', ',', ':'], true)) {
|
||||
while ($cursor < \strlen($this->currentLine)) {
|
||||
if (\in_array($this->currentLine[$cursor], ['[', ']', '{', '}', ',', ':'], true)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1217,8 +1224,8 @@ class Parser
|
|||
$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))));
|
||||
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;
|
||||
|
|
11
kirby/vendor/symfony/yaml/Tag/TaggedValue.php
vendored
11
kirby/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
kirby/vendor/symfony/yaml/Unescaper.php
vendored
2
kirby/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)),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
19
kirby/vendor/symfony/yaml/Yaml.php
vendored
19
kirby/vendor/symfony/yaml/Yaml.php
vendored
|
@ -35,6 +35,9 @@ class Yaml
|
|||
public const DUMP_EMPTY_ARRAY_AS_SEQUENCE = 1024;
|
||||
public const DUMP_NULL_AS_TILDE = 2048;
|
||||
public const DUMP_NUMERIC_KEY_AS_STRING = 4096;
|
||||
public const DUMP_NULL_AS_EMPTY = 8192;
|
||||
public const DUMP_COMPACT_NESTED_MAPPING = 16384;
|
||||
public const DUMP_FORCE_DOUBLE_QUOTES_ON_VALUES = 32768;
|
||||
|
||||
/**
|
||||
* Parses a YAML file into a PHP value.
|
||||
|
@ -44,8 +47,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 +68,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 +86,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
|
||||
{
|
||||
|
|
8
kirby/vendor/symfony/yaml/composer.json
vendored
8
kirby/vendor/symfony/yaml/composer.json
vendored
|
@ -16,15 +16,15 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"symfony/deprecation-contracts": "^2.5|^3",
|
||||
"php": ">=8.2",
|
||||
"symfony/deprecation-contracts": "^2.5|^3.0",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/console": "^5.4|^6.0|^7.0"
|
||||
"symfony/console": "^6.4|^7.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/console": "<5.4"
|
||||
"symfony/console": "<6.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\Yaml\\": "" },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue