upgraded dependencies
This commit is contained in:
41
vendor/symfony/yaml/CHANGELOG.md
vendored
41
vendor/symfony/yaml/CHANGELOG.md
vendored
@@ -1,6 +1,47 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
5.4
|
||||
---
|
||||
|
||||
* Add new `lint:yaml dirname --exclude=/dirname/foo.yaml --exclude=/dirname/bar.yaml`
|
||||
option to exclude one or more specific files from multiple file list
|
||||
* Allow negatable for the parse tags option with `--no-parse-tags`
|
||||
|
||||
5.3
|
||||
---
|
||||
|
||||
* Added `github` format support & autodetection to render errors as annotations
|
||||
when running the YAML linter command in a Github Action environment.
|
||||
|
||||
5.1.0
|
||||
-----
|
||||
|
||||
* Added support for parsing numbers prefixed with `0o` as octal numbers.
|
||||
* Deprecated support for parsing numbers starting with `0` as octal numbers. They will be parsed as strings as of Symfony 6.0. Prefix numbers with `0o`
|
||||
so that they are parsed as octal numbers.
|
||||
|
||||
Before:
|
||||
|
||||
```yaml
|
||||
Yaml::parse('072');
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```yaml
|
||||
Yaml::parse('0o72');
|
||||
```
|
||||
|
||||
* Added `yaml-lint` binary.
|
||||
* Deprecated using the `!php/object` and `!php/const` tags without a value.
|
||||
|
||||
5.0.0
|
||||
-----
|
||||
|
||||
* Removed support for mappings inside multi-line strings.
|
||||
* removed support for implicit STDIN usage in the `lint:yaml` command, use `lint:yaml -` (append a dash) instead to make it explicit.
|
||||
|
||||
4.4.0
|
||||
-----
|
||||
|
||||
|
60
vendor/symfony/yaml/Command/LintCommand.php
vendored
60
vendor/symfony/yaml/Command/LintCommand.php
vendored
@@ -11,7 +11,10 @@
|
||||
|
||||
namespace Symfony\Component\Yaml\Command;
|
||||
|
||||
use Symfony\Component\Console\CI\GithubActionReporter;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Completion\CompletionInput;
|
||||
use Symfony\Component\Console\Completion\CompletionSuggestions;
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
@@ -32,6 +35,7 @@ use Symfony\Component\Yaml\Yaml;
|
||||
class LintCommand extends Command
|
||||
{
|
||||
protected static $defaultName = 'lint:yaml';
|
||||
protected static $defaultDescription = 'Lint a YAML file and outputs encountered errors';
|
||||
|
||||
private $parser;
|
||||
private $format;
|
||||
@@ -53,10 +57,11 @@ class LintCommand extends Command
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setDescription('Lint a file and outputs encountered errors')
|
||||
->setDescription(self::$defaultDescription)
|
||||
->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN')
|
||||
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
||||
->addOption('parse-tags', null, InputOption::VALUE_NONE, 'Parse custom tags')
|
||||
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format')
|
||||
->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
|
||||
The <info>%command.name%</info> command lints a YAML file and outputs to STDOUT
|
||||
the first encountered syntax error.
|
||||
@@ -74,6 +79,10 @@ Or of a whole directory:
|
||||
<info>php %command.full_name% dirname</info>
|
||||
<info>php %command.full_name% dirname --format=json</info>
|
||||
|
||||
You can also exclude one or more specific files:
|
||||
|
||||
<info>php %command.full_name% dirname --exclude="dirname/foo.yaml" --exclude="dirname/bar.yaml"</info>
|
||||
|
||||
EOF
|
||||
)
|
||||
;
|
||||
@@ -83,22 +92,28 @@ EOF
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$filenames = (array) $input->getArgument('filename');
|
||||
$excludes = $input->getOption('exclude');
|
||||
$this->format = $input->getOption('format');
|
||||
$flags = $input->getOption('parse-tags');
|
||||
|
||||
if ('github' === $this->format && !class_exists(GithubActionReporter::class)) {
|
||||
throw new \InvalidArgumentException('The "github" format is only available since "symfony/console" >= 5.3.');
|
||||
}
|
||||
|
||||
if (null === $this->format) {
|
||||
// Autodetect format according to CI environment
|
||||
$this->format = class_exists(GithubActionReporter::class) && GithubActionReporter::isGithubActionEnvironment() ? 'github' : 'txt';
|
||||
}
|
||||
|
||||
$flags = $flags ? Yaml::PARSE_CUSTOM_TAGS : 0;
|
||||
|
||||
$this->displayCorrectFiles = $output->isVerbose();
|
||||
$flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0;
|
||||
|
||||
if (['-'] === $filenames) {
|
||||
return $this->display($io, [$this->validate(file_get_contents('php://stdin'), $flags)]);
|
||||
}
|
||||
|
||||
// @deprecated to be removed in 5.0
|
||||
if (!$filenames) {
|
||||
if (0 === ftell(\STDIN)) {
|
||||
@trigger_error('Piping content from STDIN to the "lint:yaml" command without passing the dash symbol "-" as argument is deprecated since Symfony 4.4.', \E_USER_DEPRECATED);
|
||||
|
||||
return $this->display($io, [$this->validate(file_get_contents('php://stdin'), $flags)]);
|
||||
}
|
||||
|
||||
throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
|
||||
}
|
||||
|
||||
@@ -109,7 +124,9 @@ EOF
|
||||
}
|
||||
|
||||
foreach ($this->getFiles($filename) as $file) {
|
||||
$filesInfo[] = $this->validate(file_get_contents($file), $flags, $file);
|
||||
if (!\in_array($file->getPathname(), $excludes, true)) {
|
||||
$filesInfo[] = $this->validate(file_get_contents($file), $flags, $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,17 +161,23 @@ EOF
|
||||
return $this->displayTxt($io, $files);
|
||||
case 'json':
|
||||
return $this->displayJson($io, $files);
|
||||
case 'github':
|
||||
return $this->displayTxt($io, $files, true);
|
||||
default:
|
||||
throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $this->format));
|
||||
}
|
||||
}
|
||||
|
||||
private function displayTxt(SymfonyStyle $io, array $filesInfo): int
|
||||
private function displayTxt(SymfonyStyle $io, array $filesInfo, bool $errorAsGithubAnnotations = false): int
|
||||
{
|
||||
$countFiles = \count($filesInfo);
|
||||
$erroredFiles = 0;
|
||||
$suggestTagOption = false;
|
||||
|
||||
if ($errorAsGithubAnnotations) {
|
||||
$githubReporter = new GithubActionReporter($io);
|
||||
}
|
||||
|
||||
foreach ($filesInfo as $info) {
|
||||
if ($info['valid'] && $this->displayCorrectFiles) {
|
||||
$io->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
|
||||
@@ -166,6 +189,10 @@ EOF
|
||||
if (false !== strpos($info['message'], 'PARSE_CUSTOM_TAGS')) {
|
||||
$suggestTagOption = true;
|
||||
}
|
||||
|
||||
if ($errorAsGithubAnnotations) {
|
||||
$githubReporter->error($info['message'], $info['file'] ?? 'php://stdin', $info['line']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,4 +279,11 @@ EOF
|
||||
|
||||
return $default($fileOrDirectory);
|
||||
}
|
||||
|
||||
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
|
||||
{
|
||||
if ($input->mustSuggestOptionValuesFor('format')) {
|
||||
$suggestions->suggestValues(['txt', 'json', 'github']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
28
vendor/symfony/yaml/Dumper.php
vendored
28
vendor/symfony/yaml/Dumper.php
vendored
@@ -45,8 +45,6 @@ class Dumper
|
||||
* @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
|
||||
*
|
||||
* @return string The YAML representation of the PHP value
|
||||
*/
|
||||
public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0): string
|
||||
{
|
||||
@@ -60,6 +58,8 @@ class Dumper
|
||||
|
||||
if ($inline <= 0 || (!\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap) || empty($input)) {
|
||||
$output .= $prefix.Inline::dump($input, $flags);
|
||||
} elseif ($input instanceof TaggedValue) {
|
||||
$output .= $this->dumpTaggedValue($input, $inline, $indent, $flags, $prefix);
|
||||
} else {
|
||||
$dumpAsMap = Inline::isHash($input);
|
||||
|
||||
@@ -139,4 +139,28 @@ class Dumper
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
private function dumpTaggedValue(TaggedValue $value, int $inline, int $indent, int $flags, string $prefix): string
|
||||
{
|
||||
$output = sprintf('%s!%s', $prefix ? $prefix.' ' : '', $value->getTag());
|
||||
|
||||
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && false !== strpos($value->getValue(), "\n") && false === strpos($value->getValue(), "\r\n")) {
|
||||
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
|
||||
// http://www.yaml.org/spec/1.2/spec.html#id2793979
|
||||
$blockIndentationIndicator = (' ' === substr($value->getValue(), 0, 1)) ? (string) $this->indentation : '';
|
||||
$output .= sprintf(' |%s', $blockIndentationIndicator);
|
||||
|
||||
foreach (explode("\n", $value->getValue()) as $row) {
|
||||
$output .= sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
|
||||
}
|
||||
|
||||
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."\n".$this->dump($value->getValue(), $inline - 1, $indent, $flags);
|
||||
}
|
||||
}
|
||||
|
8
vendor/symfony/yaml/Escaper.php
vendored
8
vendor/symfony/yaml/Escaper.php
vendored
@@ -49,8 +49,6 @@ class Escaper
|
||||
* Determines if a PHP value would require double quoting in YAML.
|
||||
*
|
||||
* @param string $value A PHP value
|
||||
*
|
||||
* @return bool True if the value would require double quotes
|
||||
*/
|
||||
public static function requiresDoubleQuoting(string $value): bool
|
||||
{
|
||||
@@ -61,8 +59,6 @@ class Escaper
|
||||
* Escapes and surrounds a PHP value with double quotes.
|
||||
*
|
||||
* @param string $value A PHP value
|
||||
*
|
||||
* @return string The quoted, escaped string
|
||||
*/
|
||||
public static function escapeWithDoubleQuotes(string $value): string
|
||||
{
|
||||
@@ -73,8 +69,6 @@ class Escaper
|
||||
* Determines if a PHP value would require single quoting in YAML.
|
||||
*
|
||||
* @param string $value A PHP value
|
||||
*
|
||||
* @return bool True if the value would require single quotes
|
||||
*/
|
||||
public static function requiresSingleQuoting(string $value): bool
|
||||
{
|
||||
@@ -93,8 +87,6 @@ class Escaper
|
||||
* Escapes and surrounds a PHP value with single quotes.
|
||||
*
|
||||
* @param string $value A PHP value
|
||||
*
|
||||
* @return string The quoted, escaped string
|
||||
*/
|
||||
public static function escapeWithSingleQuotes(string $value): string
|
||||
{
|
||||
|
18
vendor/symfony/yaml/Exception/ParseException.php
vendored
18
vendor/symfony/yaml/Exception/ParseException.php
vendored
@@ -44,7 +44,7 @@ class ParseException extends RuntimeException
|
||||
/**
|
||||
* Gets the snippet of code near the error.
|
||||
*
|
||||
* @return string The snippet of code
|
||||
* @return string
|
||||
*/
|
||||
public function getSnippet()
|
||||
{
|
||||
@@ -53,10 +53,8 @@ class ParseException extends RuntimeException
|
||||
|
||||
/**
|
||||
* Sets the snippet of code near the error.
|
||||
*
|
||||
* @param string $snippet The code snippet
|
||||
*/
|
||||
public function setSnippet($snippet)
|
||||
public function setSnippet(string $snippet)
|
||||
{
|
||||
$this->snippet = $snippet;
|
||||
|
||||
@@ -68,7 +66,7 @@ class ParseException extends RuntimeException
|
||||
*
|
||||
* This method returns null if a string is parsed.
|
||||
*
|
||||
* @return string The filename
|
||||
* @return string
|
||||
*/
|
||||
public function getParsedFile()
|
||||
{
|
||||
@@ -77,10 +75,8 @@ class ParseException extends RuntimeException
|
||||
|
||||
/**
|
||||
* Sets the filename where the error occurred.
|
||||
*
|
||||
* @param string $parsedFile The filename
|
||||
*/
|
||||
public function setParsedFile($parsedFile)
|
||||
public function setParsedFile(string $parsedFile)
|
||||
{
|
||||
$this->parsedFile = $parsedFile;
|
||||
|
||||
@@ -90,7 +86,7 @@ class ParseException extends RuntimeException
|
||||
/**
|
||||
* Gets the line where the error occurred.
|
||||
*
|
||||
* @return int The file line
|
||||
* @return int
|
||||
*/
|
||||
public function getParsedLine()
|
||||
{
|
||||
@@ -99,10 +95,8 @@ class ParseException extends RuntimeException
|
||||
|
||||
/**
|
||||
* Sets the line where the error occurred.
|
||||
*
|
||||
* @param int $parsedLine The file line
|
||||
*/
|
||||
public function setParsedLine($parsedLine)
|
||||
public function setParsedLine(int $parsedLine)
|
||||
{
|
||||
$this->parsedLine = $parsedLine;
|
||||
|
||||
|
50
vendor/symfony/yaml/Inline.php
vendored
50
vendor/symfony/yaml/Inline.php
vendored
@@ -54,7 +54,7 @@ class Inline
|
||||
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
|
||||
* @param array $references Mapping of variable names to values
|
||||
*
|
||||
* @return mixed A PHP value
|
||||
* @return mixed
|
||||
*
|
||||
* @throws ParseException
|
||||
*/
|
||||
@@ -86,7 +86,7 @@ class Inline
|
||||
++$i;
|
||||
break;
|
||||
default:
|
||||
$result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
|
||||
$result = self::parseScalar($value, $flags, null, $i, true, $references);
|
||||
}
|
||||
|
||||
// some comments are allowed at the end
|
||||
@@ -112,8 +112,6 @@ class Inline
|
||||
* @param mixed $value The PHP variable to convert
|
||||
* @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
|
||||
*
|
||||
* @return string The YAML string representing the PHP value
|
||||
*
|
||||
* @throws DumpException When trying to dump PHP resource
|
||||
*/
|
||||
public static function dump($value, int $flags = 0): string
|
||||
@@ -174,7 +172,9 @@ class Inline
|
||||
$repr = str_ireplace('INF', '.Inf', $repr);
|
||||
} elseif (floor($value) == $value && $repr == $value) {
|
||||
// Preserve float data type since storing a whole number will result in integer value.
|
||||
$repr = '!!float '.$repr;
|
||||
if (false === strpos($repr, 'E')) {
|
||||
$repr = $repr.'.0';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$repr = \is_string($value) ? "'$value'" : (string) $value;
|
||||
@@ -204,8 +204,6 @@ class Inline
|
||||
* Check if given array is hash or just normal indexed array.
|
||||
*
|
||||
* @param array|\ArrayObject|\stdClass $value The PHP array or array-like object to check
|
||||
*
|
||||
* @return bool true if value is hash array, false otherwise
|
||||
*/
|
||||
public static function isHash($value): bool
|
||||
{
|
||||
@@ -229,8 +227,6 @@ class Inline
|
||||
*
|
||||
* @param array $value The PHP array to dump
|
||||
* @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
|
||||
*
|
||||
* @return string The YAML string representing the PHP array
|
||||
*/
|
||||
private static function dumpArray(array $value, int $flags): string
|
||||
{
|
||||
@@ -271,7 +267,7 @@ class Inline
|
||||
*/
|
||||
public static function parseScalar(string $scalar, int $flags = 0, array $delimiters = null, int &$i = 0, bool $evaluate = true, array &$references = [], bool &$isQuoted = null)
|
||||
{
|
||||
if (\in_array($scalar[$i], ['"', "'"])) {
|
||||
if (\in_array($scalar[$i], ['"', "'"], true)) {
|
||||
// quoted scalar
|
||||
$isQuoted = true;
|
||||
$output = self::parseQuotedScalar($scalar, $i);
|
||||
@@ -329,7 +325,7 @@ class Inline
|
||||
throw new ParseException(sprintf('Malformed inline YAML string: "%s".', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
|
||||
}
|
||||
|
||||
$output = substr($match[0], 1, \strlen($match[0]) - 2);
|
||||
$output = substr($match[0], 1, -1);
|
||||
|
||||
$unescaper = new Unescaper();
|
||||
if ('"' == $scalar[$i]) {
|
||||
@@ -558,7 +554,7 @@ class Inline
|
||||
/**
|
||||
* Evaluates scalars and replaces magic values.
|
||||
*
|
||||
* @return mixed The evaluated YAML string
|
||||
* @return mixed
|
||||
*
|
||||
* @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved
|
||||
*/
|
||||
@@ -566,7 +562,6 @@ class Inline
|
||||
{
|
||||
$isQuotedString = false;
|
||||
$scalar = trim($scalar);
|
||||
$scalarLower = strtolower($scalar);
|
||||
|
||||
if (0 === strpos($scalar, '*')) {
|
||||
if (false !== $pos = strpos($scalar, '#')) {
|
||||
@@ -587,6 +582,8 @@ class Inline
|
||||
return $references[$value];
|
||||
}
|
||||
|
||||
$scalarLower = strtolower($scalar);
|
||||
|
||||
switch (true) {
|
||||
case 'null' === $scalarLower:
|
||||
case '' === $scalar:
|
||||
@@ -612,6 +609,8 @@ class Inline
|
||||
case 0 === strpos($scalar, '!php/object'):
|
||||
if (self::$objectSupport) {
|
||||
if (!isset($scalar[12])) {
|
||||
trigger_deprecation('symfony/yaml', '5.1', 'Using the !php/object tag without a value is deprecated.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -626,6 +625,8 @@ class Inline
|
||||
case 0 === strpos($scalar, '!php/const'):
|
||||
if (self::$constantSupport) {
|
||||
if (!isset($scalar[11])) {
|
||||
trigger_deprecation('symfony/yaml', '5.1', 'Using the !php/const tag without a value is deprecated.');
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -645,13 +646,18 @@ class Inline
|
||||
return (float) substr($scalar, 8);
|
||||
case 0 === strpos($scalar, '!!binary '):
|
||||
return self::evaluateBinaryScalar(substr($scalar, 9));
|
||||
default:
|
||||
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);
|
||||
}
|
||||
|
||||
// Optimize for returning strings.
|
||||
// no break
|
||||
case '+' === $scalar[0] || '-' === $scalar[0] || '.' === $scalar[0] || is_numeric($scalar[0]):
|
||||
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']);
|
||||
|
||||
if ('-' === $scalar[0]) {
|
||||
return -octdec($value);
|
||||
}
|
||||
|
||||
return octdec($value);
|
||||
case \in_array($scalar[0], ['+', '-', '.'], true) || is_numeric($scalar[0]):
|
||||
if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar)) {
|
||||
$scalar = str_replace('_', '', $scalar);
|
||||
}
|
||||
@@ -659,6 +665,8 @@ class Inline
|
||||
switch (true) {
|
||||
case ctype_digit($scalar):
|
||||
if (preg_match('/^0[0-7]+$/', $scalar)) {
|
||||
trigger_deprecation('symfony/yaml', '5.1', 'Support for parsing numbers prefixed with 0 as octal numbers. They will be parsed as strings as of 6.0. Use "%s" to represent the octal number.', '0o'.substr($scalar, 1));
|
||||
|
||||
return octdec($scalar);
|
||||
}
|
||||
|
||||
@@ -667,6 +675,8 @@ class Inline
|
||||
return ($scalar === (string) $cast) ? $cast : $scalar;
|
||||
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
|
||||
if (preg_match('/^-0[0-7]+$/', $scalar)) {
|
||||
trigger_deprecation('symfony/yaml', '5.1', 'Support for parsing numbers prefixed with 0 as octal numbers. They will be parsed as strings as of 6.0. Use "%s" to represent the octal number.', '-0o'.substr($scalar, 2));
|
||||
|
||||
return -octdec(substr($scalar, 1));
|
||||
}
|
||||
|
||||
@@ -763,7 +773,7 @@ class Inline
|
||||
return base64_decode($parsedBinaryData, true);
|
||||
}
|
||||
|
||||
private static function isBinaryString(string $value)
|
||||
private static function isBinaryString(string $value): bool
|
||||
{
|
||||
return !preg_match('//u', $value) || preg_match('/[^\x00\x07-\x0d\x1B\x20-\xff]/', $value);
|
||||
}
|
||||
@@ -771,8 +781,6 @@ class Inline
|
||||
/**
|
||||
* Gets a regex that matches a YAML date.
|
||||
*
|
||||
* @return string The regular expression
|
||||
*
|
||||
* @see http://www.yaml.org/spec/1.2/spec.html#id2761573
|
||||
*/
|
||||
private static function getTimestampRegex(): string
|
||||
|
58
vendor/symfony/yaml/Parser.php
vendored
58
vendor/symfony/yaml/Parser.php
vendored
@@ -29,6 +29,7 @@ class Parser
|
||||
|
||||
private $filename;
|
||||
private $offset = 0;
|
||||
private $numberOfParsedLines = 0;
|
||||
private $totalNumberOfLines;
|
||||
private $lines = [];
|
||||
private $currentLineNb = -1;
|
||||
@@ -44,7 +45,7 @@ class Parser
|
||||
* @param string $filename The path to the YAML file to be parsed
|
||||
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
|
||||
*
|
||||
* @return mixed The YAML converted to a PHP value
|
||||
* @return mixed
|
||||
*
|
||||
* @throws ParseException If the file could not be read or the YAML is not valid
|
||||
*/
|
||||
@@ -73,7 +74,7 @@ class Parser
|
||||
* @param string $value A YAML string
|
||||
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
|
||||
*
|
||||
* @return mixed A PHP value
|
||||
* @return mixed
|
||||
*
|
||||
* @throws ParseException If the YAML is not valid
|
||||
*/
|
||||
@@ -102,6 +103,7 @@ class Parser
|
||||
$this->offset = 0;
|
||||
$this->lines = [];
|
||||
$this->currentLine = '';
|
||||
$this->numberOfParsedLines = 0;
|
||||
$this->refs = [];
|
||||
$this->skippedLineNumbers = [];
|
||||
$this->locallySkippedLineNumbers = [];
|
||||
@@ -117,10 +119,11 @@ class Parser
|
||||
$this->currentLine = '';
|
||||
$value = $this->cleanup($value);
|
||||
$this->lines = explode("\n", $value);
|
||||
$this->numberOfParsedLines = \count($this->lines);
|
||||
$this->locallySkippedLineNumbers = [];
|
||||
|
||||
if (null === $this->totalNumberOfLines) {
|
||||
$this->totalNumberOfLines = \count($this->lines);
|
||||
$this->totalNumberOfLines = $this->numberOfParsedLines;
|
||||
}
|
||||
|
||||
if (!$this->moveToNextLine()) {
|
||||
@@ -447,7 +450,8 @@ class Parser
|
||||
$value = '';
|
||||
|
||||
foreach ($this->lines as $line) {
|
||||
if ('' !== ltrim($line) && '#' === ltrim($line)[0]) {
|
||||
$trimmedLine = trim($line);
|
||||
if ('#' === ($trimmedLine[0] ?? '')) {
|
||||
continue;
|
||||
}
|
||||
// If the indentation is not consistent at offset 0, it is to be considered as a ParseError
|
||||
@@ -456,22 +460,22 @@ class Parser
|
||||
}
|
||||
|
||||
if (false !== strpos($line, ': ')) {
|
||||
@trigger_error('Support for mapping keys in multi-line blocks is deprecated since Symfony 4.3 and will throw a ParseException in 5.0.', \E_USER_DEPRECATED);
|
||||
throw new ParseException('Mapping values are not allowed in multi-line blocks.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
|
||||
}
|
||||
|
||||
if ('' === trim($line)) {
|
||||
if ('' === $trimmedLine) {
|
||||
$value .= "\n";
|
||||
} elseif (!$previousLineWasNewline && !$previousLineWasTerminatedWithBackslash) {
|
||||
$value .= ' ';
|
||||
}
|
||||
|
||||
if ('' !== trim($line) && '\\' === substr($line, -1)) {
|
||||
if ('' !== $trimmedLine && '\\' === substr($line, -1)) {
|
||||
$value .= ltrim(substr($line, 0, -1));
|
||||
} elseif ('' !== trim($line)) {
|
||||
$value .= trim($line);
|
||||
} elseif ('' !== $trimmedLine) {
|
||||
$value .= $trimmedLine;
|
||||
}
|
||||
|
||||
if ('' === trim($line)) {
|
||||
if ('' === $trimmedLine) {
|
||||
$previousLineWasNewline = true;
|
||||
$previousLineWasTerminatedWithBackslash = false;
|
||||
} elseif ('\\' === substr($line, -1)) {
|
||||
@@ -498,7 +502,7 @@ class Parser
|
||||
$data = new TaggedValue($tag, $data);
|
||||
}
|
||||
|
||||
if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && !\is_object($data) && 'mapping' === $context) {
|
||||
if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && 'mapping' === $context && !\is_object($data)) {
|
||||
$object = new \stdClass();
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
@@ -537,8 +541,6 @@ class Parser
|
||||
* Returns the current line number (takes the offset into account).
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @return int The current line number
|
||||
*/
|
||||
public function getRealCurrentLineNb(): int
|
||||
{
|
||||
@@ -557,11 +559,13 @@ class Parser
|
||||
|
||||
/**
|
||||
* Returns the current line indentation.
|
||||
*
|
||||
* @return int The current line indentation
|
||||
*/
|
||||
private function getCurrentLineIndentation(): int
|
||||
{
|
||||
if (' ' !== ($this->currentLine[0] ?? '')) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return \strlen($this->currentLine) - \strlen(ltrim($this->currentLine, ' '));
|
||||
}
|
||||
|
||||
@@ -571,8 +575,6 @@ class Parser
|
||||
* @param int|null $indentation The indent level at which the block is to be read, or null for default
|
||||
* @param bool $inSequence True if the enclosing data structure is a sequence
|
||||
*
|
||||
* @return string A YAML string
|
||||
*
|
||||
* @throws ParseException When indentation problem are detected
|
||||
*/
|
||||
private function getNextEmbedBlock(int $indentation = null, bool $inSequence = false): string
|
||||
@@ -682,7 +684,7 @@ class Parser
|
||||
*/
|
||||
private function moveToNextLine(): bool
|
||||
{
|
||||
if ($this->currentLineNb >= \count($this->lines) - 1) {
|
||||
if ($this->currentLineNb >= $this->numberOfParsedLines - 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -712,7 +714,7 @@ class Parser
|
||||
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
|
||||
* @param string $context The parser context (either sequence or mapping)
|
||||
*
|
||||
* @return mixed A PHP value
|
||||
* @return mixed
|
||||
*
|
||||
* @throws ParseException When reference does not exist
|
||||
*/
|
||||
@@ -932,8 +934,6 @@ class Parser
|
||||
|
||||
/**
|
||||
* Returns true if the next line is indented.
|
||||
*
|
||||
* @return bool Returns true if the next line is indented, false otherwise
|
||||
*/
|
||||
private function isNextLineIndented(): bool
|
||||
{
|
||||
@@ -963,8 +963,6 @@ class Parser
|
||||
|
||||
/**
|
||||
* Returns true if the current line is blank or if it is a comment line.
|
||||
*
|
||||
* @return bool Returns true if the current line is empty or if it is a comment line, false otherwise
|
||||
*/
|
||||
private function isCurrentLineEmpty(): bool
|
||||
{
|
||||
@@ -973,23 +971,19 @@ class Parser
|
||||
|
||||
/**
|
||||
* Returns true if the current line is blank.
|
||||
*
|
||||
* @return bool Returns true if the current line is blank, false otherwise
|
||||
*/
|
||||
private function isCurrentLineBlank(): bool
|
||||
{
|
||||
return '' == trim($this->currentLine, ' ');
|
||||
return '' === $this->currentLine || '' === trim($this->currentLine, ' ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current line is a comment line.
|
||||
*
|
||||
* @return bool Returns true if the current line is a comment line, false otherwise
|
||||
*/
|
||||
private function isCurrentLineComment(): bool
|
||||
{
|
||||
// checking explicitly the first char of the trim is faster than loops or strpos
|
||||
$ltrimmedLine = ltrim($this->currentLine, ' ');
|
||||
$ltrimmedLine = '' !== $this->currentLine && ' ' === $this->currentLine[0] ? ltrim($this->currentLine, ' ') : $this->currentLine;
|
||||
|
||||
return '' !== $ltrimmedLine && '#' === $ltrimmedLine[0];
|
||||
}
|
||||
@@ -1003,8 +997,6 @@ class Parser
|
||||
* Cleanups a YAML string to be parsed.
|
||||
*
|
||||
* @param string $value The input YAML string
|
||||
*
|
||||
* @return string A cleaned up YAML string
|
||||
*/
|
||||
private function cleanup(string $value): string
|
||||
{
|
||||
@@ -1039,8 +1031,6 @@ class Parser
|
||||
|
||||
/**
|
||||
* Returns true if the next line starts unindented collection.
|
||||
*
|
||||
* @return bool Returns true if the next line starts unindented collection, false otherwise
|
||||
*/
|
||||
private function isNextLineUnIndentedCollection(): bool
|
||||
{
|
||||
@@ -1070,8 +1060,6 @@ class Parser
|
||||
|
||||
/**
|
||||
* Returns true if the string is un-indented collection item.
|
||||
*
|
||||
* @return bool Returns true if the string is un-indented collection item, false otherwise
|
||||
*/
|
||||
private function isStringUnIndentedCollectionItem(): bool
|
||||
{
|
||||
|
49
vendor/symfony/yaml/Resources/bin/yaml-lint
vendored
Executable file
49
vendor/symfony/yaml/Resources/bin/yaml-lint
vendored
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
if ('cli' !== \PHP_SAPI) {
|
||||
throw new Exception('This script must be run from the command line.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the Yaml lint command.
|
||||
*
|
||||
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
|
||||
*/
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Yaml\Command\LintCommand;
|
||||
|
||||
function includeIfExists(string $file): bool
|
||||
{
|
||||
return file_exists($file) && include $file;
|
||||
}
|
||||
|
||||
if (
|
||||
!includeIfExists(__DIR__ . '/../../../../autoload.php') &&
|
||||
!includeIfExists(__DIR__ . '/../../vendor/autoload.php') &&
|
||||
!includeIfExists(__DIR__ . '/../../../../../../vendor/autoload.php')
|
||||
) {
|
||||
fwrite(STDERR, 'Install dependencies using Composer.'.PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!class_exists(Application::class)) {
|
||||
fwrite(STDERR, 'You need the "symfony/console" component in order to run the Yaml linter.'.PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
(new Application())->add($command = new LintCommand())
|
||||
->getApplication()
|
||||
->setDefaultCommand($command->getName(), true)
|
||||
->run()
|
||||
;
|
6
vendor/symfony/yaml/Unescaper.php
vendored
6
vendor/symfony/yaml/Unescaper.php
vendored
@@ -32,8 +32,6 @@ class Unescaper
|
||||
* Unescapes a single quoted string.
|
||||
*
|
||||
* @param string $value A single quoted string
|
||||
*
|
||||
* @return string The unescaped string
|
||||
*/
|
||||
public function unescapeSingleQuotedString(string $value): string
|
||||
{
|
||||
@@ -44,8 +42,6 @@ class Unescaper
|
||||
* Unescapes a double quoted string.
|
||||
*
|
||||
* @param string $value A double quoted string
|
||||
*
|
||||
* @return string The unescaped string
|
||||
*/
|
||||
public function unescapeDoubleQuotedString(string $value): string
|
||||
{
|
||||
@@ -61,8 +57,6 @@ class Unescaper
|
||||
* Unescapes a character that was found in a double-quoted string.
|
||||
*
|
||||
* @param string $value An escaped character
|
||||
*
|
||||
* @return string The unescaped character
|
||||
*/
|
||||
private function unescapeCharacter(string $value): string
|
||||
{
|
||||
|
6
vendor/symfony/yaml/Yaml.php
vendored
6
vendor/symfony/yaml/Yaml.php
vendored
@@ -46,7 +46,7 @@ class Yaml
|
||||
* @param string $filename The path to the YAML file to be parsed
|
||||
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
|
||||
*
|
||||
* @return mixed The YAML converted to a PHP value
|
||||
* @return mixed
|
||||
*
|
||||
* @throws ParseException If the file could not be read or the YAML is not valid
|
||||
*/
|
||||
@@ -69,7 +69,7 @@ class Yaml
|
||||
* @param string $input A string containing YAML
|
||||
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
|
||||
*
|
||||
* @return mixed The YAML converted to a PHP value
|
||||
* @return mixed
|
||||
*
|
||||
* @throws ParseException If the YAML is not valid
|
||||
*/
|
||||
@@ -90,8 +90,6 @@ class Yaml
|
||||
* @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
|
||||
*
|
||||
* @return string A YAML string representing the original PHP value
|
||||
*/
|
||||
public static function dump($input, int $inline = 2, int $indent = 4, int $flags = 0): string
|
||||
{
|
||||
|
12
vendor/symfony/yaml/composer.json
vendored
12
vendor/symfony/yaml/composer.json
vendored
@@ -16,14 +16,15 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1.3",
|
||||
"symfony/polyfill-ctype": "~1.8"
|
||||
"php": ">=7.2.5",
|
||||
"symfony/deprecation-contracts": "^2.1|^3",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/console": "^3.4|^4.0|^5.0"
|
||||
"symfony/console": "^5.3|^6.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/console": "<3.4"
|
||||
"symfony/console": "<5.3"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/console": "For validating YAML files using the lint command"
|
||||
@@ -34,5 +35,8 @@
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"bin": [
|
||||
"Resources/bin/yaml-lint"
|
||||
],
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
|
Reference in New Issue
Block a user