Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: symfony/yaml
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.4.35
Choose a base ref
...
head repository: symfony/yaml
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.0.0
Choose a head ref

Commits on May 19, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    efdac1e View commit details
  2. Merge branch '5.4' into 6.0

    * 5.4:
      Allow Symfony 6
    derrabus committed May 19, 2021
    Copy the full SHA
    7509aa4 View commit details

Commits on May 20, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    666c9f0 View commit details

Commits on May 21, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    23727d8 View commit details

Commits on May 24, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      [Form] fix support for years outside of the 32b range on x86 arch
      CS fix
      remove duplicate test
      Add an upgrade note about the removal of Serializable
      [SecurityBundle] Don't register deprecated listeners with authenticator manager enabled
    nicolas-grekas committed May 24, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0d357b5 View commit details

Commits on May 26, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      Fix CS in README files
      Fix markdown
      [HttpKernel] Fixes tests for PHP7.4+
      fix test
      [HttpKernel] Throw when HttpKernel is created and the env is empty
      [FrameworkBundle] Deprecate the `AdapterInterface` autowiring alias, use `CacheItemPoolInterface` instead
      [Filesystem] fix readlink for Windows
    nicolas-grekas committed May 26, 2021
    Copy the full SHA
    f7e9a51 View commit details

Commits on May 28, 2021

  1. Copy the full SHA
    3b0ac4d View commit details

Commits on Jun 2, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      [Yaml] Leverage array_is_list()
    nicolas-grekas committed Jun 2, 2021
    Copy the full SHA
    5de2cb2 View commit details
  2. Copy the full SHA
    326cf2f View commit details

Commits on Jun 6, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      Fix incompatible implicit float-to-int conversions
      [Translation] Don't pass null to strtoupper()
      cs fix
      [String] Fix implicit float-to-int casts
      [Asset] Don't pass null to strpos()
      [Messenger] Fix broken mock
      [DependencyInjection] Don't pass null to trim()
      Add return types to JsonSerializable implementations
      Fix Serializable deprecations triggered by token mocks
      Add missing security translations
      [FrameworkBundle] Deprecate the public `profiler` service to private
    derrabus committed Jun 6, 2021
    Copy the full SHA
    3d2b4f1 View commit details

Commits on Jun 24, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4: (29 commits)
      [DI] fix fixture
      [ErrorHandler] fix handling buffered SilencedErrorContext
      [HttpClient] fix Psr18Client when allow_url_fopen=0
      [DependencyInjection] Add support of PHP enumerations
      [Cache] handle prefixed redis connections when clearing pools
      [Cache] fix eventual consistency when using RedisTagAwareAdapter with a cluster
      [Uid] Prevent double validation in Uuid::fromString() with base32 values
      [Uid] Fix fromString() with low base58 values
      [Notifier] Add options to Microsoft Teams notifier
      [Notifier] Add Telnyx notifier bridge
      [Validator][Translation] Add ExpressionLanguageSyntax en and fr
      [HttpKernel] [HttpCache] Keep s-maxage=0 from ESI sub-responses
      Avoid broken action URL in text notification mail
      [FrameworkBundle] Add commented base64 version of secrets' keys
      [WebProfilerBundle] Improved the light/dark theme switching
      Fix references to CheckRememberMeConditionsListener
      [DependencyInjection] accept service locator definitions with no class
      [Cache] Disable locking on Windows by default
      [HttpClient] Add default base_uri to MockHttpClient
      [DependencyInjection] Fix binding "iterable $foo" when using the PHP-DSL
      ...
    nicolas-grekas committed Jun 24, 2021
    Copy the full SHA
    6138b3e View commit details

Commits on Jun 29, 2021

  1. Add more types

    nicolas-grekas committed Jun 29, 2021
    Copy the full SHA
    362b342 View commit details

Commits on Jun 30, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      Fix tests
      CS fix
      CS fix
      CS fix
      CS fixes
      Bump Symfony version to 5.3.4
      Update VERSION for 5.3.3
      Update CHANGELOG for 5.3.3
      Bump Symfony version to 5.2.12
      Update VERSION for 5.2.11
      Update CHANGELOG for 5.2.11
      Bump Symfony version to 4.4.27
      Update VERSION for 4.4.26
      Update CONTRIBUTORS for 4.4.26
      Update CHANGELOG for 4.4.26
    nicolas-grekas committed Jun 30, 2021
    Copy the full SHA
    7c878ab View commit details

Commits on Jul 13, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    22486cc View commit details
  2. Merge branch '5.4' into 6.0

    * 5.4:
      Use PHP_OS_FAMILY if possible
      Fix tests
      Fix typos in error messages
      Fix minor typos
      [WebProfilerBundle] Fix the values of some CSS properties
      [Messenger] Fixed an exception message
      [Yaml] Fixed an exception message
      Fix ctype_digit deprecation
      Add a Special Case for Translating Choices in en_US_POSIX
    nicolas-grekas committed Jul 13, 2021
    Copy the full SHA
    adc73d5 View commit details

Commits on Jul 14, 2021

  1. Copy the full SHA
    0e271d5 View commit details

Commits on Jul 15, 2021

  1. [Yaml] Add types to private properties

    Signed-off-by: Alexander M. Turek <me@derrabus.de>
    derrabus committed Jul 15, 2021
    Copy the full SHA
    c64b254 View commit details
  2. [Yaml] Remove compat code for MB function overloading

    Signed-off-by: Alexander M. Turek <me@derrabus.de>
    derrabus committed Jul 15, 2021
    Copy the full SHA
    44d76be View commit details
  3. minor #42118 [Yaml] Add types to private properties (derrabus)

    This PR was merged into the 6.0 branch.
    
    Discussion
    ----------
    
    [Yaml] Add types to private properties
    
    | Q             | A
    | ------------- | ---
    | Branch?       | 6.0
    | Bug fix?      | no
    | New feature?  | no
    | Deprecations? | no
    | Tickets       | N/A
    | License       | MIT
    | Doc PR        | N/A
    
    Commits
    -------
    
    40688504ac [Yaml] Add types to private properties
    nicolas-grekas committed Jul 15, 2021
    Copy the full SHA
    726e80e View commit details
  4. minor #42119 [Yaml] Remove compat code for MB function overloading (d…

    …errabus)
    
    This PR was merged into the 6.0 branch.
    
    Discussion
    ----------
    
    [Yaml] Remove compat code for MB function overloading
    
    | Q             | A
    | ------------- | ---
    | Branch?       | 6.0
    | Bug fix?      | no
    | New feature?  | no
    | Deprecations? | no
    | Tickets       | N/A
    | License       | MIT
    | Doc PR        | N/A
    
    MB string function overloading has been removed with PHP 8.0. I'd like to remove some code that was meant to handle active function overloading.
    
    Commits
    -------
    
    6028694781 [Yaml] Remove compat code for MB function overloading
    nicolas-grekas committed Jul 15, 2021
    Copy the full SHA
    ed93804 View commit details

Commits on Jul 21, 2021

  1. Copy the full SHA
    0293364 View commit details
  2. Merge branch '5.4' into 6.0

    * 5.4:
      Leverage str_contains/str_starts_with
      Leverage str_ends_with
    nicolas-grekas committed Jul 21, 2021
    Copy the full SHA
    e850002 View commit details

Commits on Jul 29, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      Remove polyfills from Yaml and Dotenv
      HtmlDumper - setDumpHeader accepts null
    fabpot committed Jul 29, 2021
    Copy the full SHA
    023b79a View commit details

Commits on Aug 13, 2021

  1. Copy the full SHA
    633ab0f View commit details

Commits on Aug 15, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      [Security] Fix token user usage in SwitchUserListenerTest
      [Security] PassportInterface deprecations fixes
      [Security] Remove faulty legacy mark from SwitchUserListenerTest
      [Yaml] Add an --exclude option to lint:yaml command
      * Deprecated calling `FormErrorIterator::children()` if the current element is not iterable
    wouterj committed Aug 15, 2021
    Copy the full SHA
    ad0c49e View commit details

Commits on Aug 17, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      [Serializer] cs fix
      Cleanup more `@return` annotations
      [Form] Fix phpdoc on FormBuilderInterface
    nicolas-grekas committed Aug 17, 2021
    Copy the full SHA
    5b4568a View commit details

Commits on Sep 7, 2021

  1. Copy the full SHA
    53cc3bd View commit details

Commits on Sep 21, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      [Serializer] Save missing arguments in MissingConstructorArgumentsException
      remove support for deprecated "threadKey" parameter
      Remove useless comment in test
      [DomCrawler] Added Crawler::innerText() method
      [Form] Add the EnumType
      Fix iterrator in ServiceConfigurator
      [Console] Add support of RGB functional notation for output colors
      Add Slovak lang translation #41081
      [Validator] Add error's uid to `Count` and `Length` constraints with "exactly" option enabled
      [Validator] Add missing thai translation
      [Yaml] Add 0 to float repr
      [Translation] Add Burmese translation
      [Notifier] Update FirebaseTransport.php
      fix: #43086 remove shortcut e for option exclude of Yaml/LintCommand - solve conflict with --env -e
      Map `multipart/form-data` as `form` Content-Type
      [Serializer] Throw NotNormalizableValueException when type is not known or not in body in discriminator map
      [Yaml] Use more concise float representation in dump
      [FrameworkBundle] Remove translation data_collector BEFORE adding it to profiler
    derrabus committed Sep 21, 2021
    Copy the full SHA
    a168d2d View commit details

Commits on Sep 30, 2021

  1. Copy the full SHA
    0cc1b71 View commit details

Commits on Oct 6, 2021

  1. Copy the full SHA
    b516d90 View commit details

Commits on Oct 25, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4: (46 commits)
      move username/password fix to non-deprecated Connection class
      cs fix
      [VarDumper] Fix dumping twig templates found in exceptions
      do not replace definition arguments that have not been configured
      fix Console tests on Windows
      [Validator] Add translations for CIDR constraint
      [Dotenv] Fix testLoadEnv() to start from a fresh context
      [Console] Add completion to server:dump command
      bug #42194 [RateLimiter] fix: sliding window policy to use microtime
      [Validator] Update validators.sr_Cyrl.xlf
      [Validator] Update validators.sr_Latn.xlf
      Add suggestions for the option 'format' of lints commands: twig, yaml and xliff
      [VarDumper] Add support for Fiber
      uzb translation
      Update validators.uz.xlf
      Fix logging of impersonator introduced in 5.3
      [Console] Add show proxified command class in completion debug
      skip command completion tests with older Symfony Console versions
      [Uid] Allow use autocompletion
      [Console] Add completion to messenger:setup-transports command
      ...
    nicolas-grekas committed Oct 25, 2021
    Copy the full SHA
    3857e0c View commit details

Commits on Oct 26, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4: (26 commits)
      [Dotenv] Fix testBootEnv() to start from a fresh context
      fix tests
      relax expected exception message for forward-compatibility with 5.4
      fix expected exception messages after changes made in Definition class
      [DependencyInjection] show class name on DI errors
      skip command completion tests with older Symfony Console versions
      Use GitHub issue form templates
      Fix CS
      add ResponseIsUnprocessable
      Add missing translations for Persian (fa)
      skip command completion tests with older Symfony Console versions
      prevent issues with timezones and DST by using only UNIX timestamps
      Add the missing translations for Bahasa Indonesia (id)
      [Finder] Fix .gitignore infinite loop
      Update README.md
      fix messenger DI dependency for registerAttributeForAutoconfiguration
      [Messenger] Autoconfigurable attributes
      Fix deprecations on PHP 8.2
      [Dotenv] Fix testLoadEnv() .env.dist isolation
      Since 5.0, throws \UnexpectedValueException has been removed.
      ...
    nicolas-grekas committed Oct 26, 2021
    Copy the full SHA
    78ba967 View commit details

Commits on Nov 7, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      [SecurityBundle] Fix compat with symfony/security-core:^6
      [DependencyInjection] Fix support for unions/intersections together with `ServiceSubscriberInterface`
      fixed leftover deprecations PHP 8.1
      [Runtime] fix defining APP_DEBUG when Dotenv is not enabled
      revert using functions provided by polyfill packages
      [FrameworkBundle] Fix logic in workflow:dump between workflow name and workflow id
      Bump Symfony version to 5.4.0
      Update VERSION for 5.4.0-BETA1
      Update CHANGELOG for 5.4.0-BETA1
      Add getters and setters for attributes property
    derrabus committed Nov 7, 2021
    Copy the full SHA
    6e88d8c View commit details

Commits on Nov 14, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      Fix nullable parameter doc
      don't try to replace references in quoted strings
    fabpot committed Nov 14, 2021
    Copy the full SHA
    640e162 View commit details

Commits on Nov 20, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      [Tests] Remove some unused fixtures
      added missing translations for portuguese [#43726]
      [HttpClient][Mime] Add correct IDN flags for IDNA2008 compliance
      Prevent installation of incompatible mailer component versions
      properly parse quoted strings tagged with !!str
      do not merge label classes into expanded choice labels
      Bump Symfony version to 5.4.0
      Update VERSION for 5.4.0-BETA3
      Update CHANGELOG for 5.4.0-BETA3
      [Serializer] PropertyNormalizer - return unique (i.e. filter duplicate ) attributes in extractAttributes function
      Allow autodetecting mapping type for any object
    derrabus committed Nov 20, 2021
    Copy the full SHA
    e40ca91 View commit details

Commits on Nov 28, 2021

  1. Merge branch '5.4' into 6.0

    * 5.4:
      [Process] intersect with getenv() in case-insensitive manner to get default envs
      [Serializer] fix support for lazy/unset properties
      Fix redundant type casts
      [Notifier] Fix AllMySms bridge body content
      Revert "[DoctrineBridge] add support for the JSON type"
    nicolas-grekas committed Nov 28, 2021
    Copy the full SHA
    f3064a2 View commit details
Showing with 118 additions and 257 deletions.
  1. +11 −17 Command/LintCommand.php
  2. +2 −6 Dumper.php
  3. +7 −13 Exception/ParseException.php
  4. +37 −86 Inline.php
  5. +14 −53 Parser.php
  6. +3 −3 Tag/TaggedValue.php
  7. +29 −51 Tests/InlineTest.php
  8. +0 −6 Unescaper.php
  9. +3 −9 Yaml.php
  10. +3 −4 composer.json
  11. +9 −9 phpunit.xml.dist
28 changes: 11 additions & 17 deletions Command/LintCommand.php
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
namespace Symfony\Component\Yaml\Command;

use Symfony\Component\Console\CI\GithubActionReporter;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Completion\CompletionInput;
use Symfony\Component\Console\Completion\CompletionSuggestions;
@@ -32,23 +33,21 @@
* @author Grégoire Pineau <lyrixx@lyrixx.info>
* @author Robin Chalas <robin.chalas@gmail.com>
*/
#[AsCommand(name: 'lint:yaml', description: 'Lint a YAML file and outputs encountered errors')]
class LintCommand extends Command
{
protected static $defaultName = 'lint:yaml';
protected static $defaultDescription = 'Lint a YAML file and outputs encountered errors';

private $parser;
private $format;
private $displayCorrectFiles;
private $directoryIteratorProvider;
private $isReadableProvider;
private Parser $parser;
private ?string $format = null;
private bool $displayCorrectFiles;
private ?\Closure $directoryIteratorProvider;
private ?\Closure $isReadableProvider;

public function __construct(string $name = null, callable $directoryIteratorProvider = null, callable $isReadableProvider = null)
{
parent::__construct($name);

$this->directoryIteratorProvider = $directoryIteratorProvider;
$this->isReadableProvider = $isReadableProvider;
$this->directoryIteratorProvider = null === $directoryIteratorProvider || $directoryIteratorProvider instanceof \Closure ? $directoryIteratorProvider : \Closure::fromCallable($directoryIteratorProvider);
$this->isReadableProvider = null === $isReadableProvider || $isReadableProvider instanceof \Closure ? $isReadableProvider : \Closure::fromCallable($isReadableProvider);
}

/**
@@ -57,7 +56,6 @@ public function __construct(string $name = null, callable $directoryIteratorProv
protected function configure()
{
$this
->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')
->addOption('exclude', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Path(s) to exclude')
@@ -88,7 +86,7 @@ protected function configure()
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$filenames = (array) $input->getArgument('filename');
@@ -244,11 +242,7 @@ private function getFiles(string $fileOrDirectory): iterable

private function getParser(): Parser
{
if (!$this->parser) {
$this->parser = new Parser();
}

return $this->parser;
return $this->parser ??= new Parser();
}

private function getDirectoryIterator(string $directory): iterable
8 changes: 2 additions & 6 deletions Dumper.php
Original file line number Diff line number Diff line change
@@ -24,10 +24,8 @@ class Dumper
{
/**
* The amount of spaces to use for indentation of nested nodes.
*
* @var int
*/
protected $indentation;
private int $indentation;

public function __construct(int $indentation = 4)
{
@@ -45,10 +43,8 @@ public function __construct(int $indentation = 4)
* @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
*/
public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0): string
public function dump(mixed $input, int $inline = 0, int $indent = 0, int $flags = 0): string
{
$output = '';
$prefix = $indent ? str_repeat(' ', $indent) : '';
20 changes: 7 additions & 13 deletions Exception/ParseException.php
Original file line number Diff line number Diff line change
@@ -18,10 +18,10 @@
*/
class ParseException extends RuntimeException
{
private $parsedFile;
private $parsedLine;
private $snippet;
private $rawMessage;
private ?string $parsedFile;
private int $parsedLine;
private ?string $snippet;
private string $rawMessage;

/**
* @param string $message The error message
@@ -43,10 +43,8 @@ public function __construct(string $message, int $parsedLine = -1, string $snipp

/**
* Gets the snippet of code near the error.
*
* @return string
*/
public function getSnippet()
public function getSnippet(): string
{
return $this->snippet;
}
@@ -65,10 +63,8 @@ public function setSnippet(string $snippet)
* Gets the filename where the error occurred.
*
* This method returns null if a string is parsed.
*
* @return string
*/
public function getParsedFile()
public function getParsedFile(): string
{
return $this->parsedFile;
}
@@ -85,10 +81,8 @@ public function setParsedFile(string $parsedFile)

/**
* Gets the line where the error occurred.
*
* @return int
*/
public function getParsedLine()
public function getParsedLine(): int
{
return $this->parsedLine;
}
123 changes: 37 additions & 86 deletions Inline.php
Original file line number Diff line number Diff line change
@@ -26,13 +26,13 @@ class Inline
{
public const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*+(?:\\\\.[^"\\\\]*+)*+)"|\'([^\']*+(?:\'\'[^\']*+)*+)\')';

public static $parsedLineNumber = -1;
public static $parsedFilename;
public static int $parsedLineNumber = -1;
public static ?string $parsedFilename = null;

private static $exceptionOnInvalidType = false;
private static $objectSupport = false;
private static $objectForMap = false;
private static $constantSupport = false;
private static bool $exceptionOnInvalidType = false;
private static bool $objectSupport = false;
private static bool $objectForMap = false;
private static bool $constantSupport = false;

public static function initialize(int $flags, int $parsedLineNumber = null, string $parsedFilename = null)
{
@@ -50,15 +50,12 @@ public static function initialize(int $flags, int $parsedLineNumber = null, stri
/**
* Converts a YAML string to a PHP value.
*
* @param string $value A YAML string
* @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
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
* @param array $references Mapping of variable names to values
*
* @throws ParseException
*/
public static function parse(string $value = null, int $flags = 0, array &$references = [])
public static function parse(string $value = null, int $flags = 0, array &$references = []): mixed
{
self::initialize($flags);

@@ -68,42 +65,31 @@ public static function parse(string $value = null, int $flags = 0, array &$refer
return '';
}

if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
$i = 0;
$tag = self::parseTag($value, $i, $flags);
switch ($value[$i]) {
case '[':
$result = self::parseSequence($value, $flags, $i, $references);
++$i;
break;
case '{':
$result = self::parseMapping($value, $flags, $i, $references);
++$i;
break;
default:
$result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
}

try {
$i = 0;
$tag = self::parseTag($value, $i, $flags);
switch ($value[$i]) {
case '[':
$result = self::parseSequence($value, $flags, $i, $references);
++$i;
break;
case '{':
$result = self::parseMapping($value, $flags, $i, $references);
++$i;
break;
default:
$result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
}

// some comments are allowed at the end
if (preg_replace('/\s*#.*$/A', '', substr($value, $i))) {
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}

if (null !== $tag && '' !== $tag) {
return new TaggedValue($tag, $result);
}
// 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);
}

return $result;
} finally {
if (isset($mbEncoding)) {
mb_internal_encoding($mbEncoding);
}
if (null !== $tag && '' !== $tag) {
return new TaggedValue($tag, $result);
}

return $result;
}

/**
@@ -112,11 +98,9 @@ public static function parse(string $value = null, int $flags = 0, array &$refer
* @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
*
* @throws DumpException When trying to dump PHP resource
*/
public static function dump($value, int $flags = 0): string
public static function dump(mixed $value, int $flags = 0): string
{
switch (true) {
case \is_resource($value):
@@ -204,12 +188,8 @@ public static function dump($value, int $flags = 0): string

/**
* 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
*/
public static function isHash($value): bool
public static function isHash(array|\ArrayObject|\stdClass $value): bool
{
if ($value instanceof \stdClass || $value instanceof \ArrayObject) {
return true;
@@ -231,8 +211,6 @@ public static function isHash($value): bool
*
* @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
*/
private static function dumpArray(array $value, int $flags): string
{
@@ -267,11 +245,9 @@ private static function dumpNull(int $flags): string
/**
* Parses a YAML scalar.
*
* @return mixed
*
* @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)
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
@@ -414,11 +390,9 @@ private static function parseSequence(string $sequence, int $flags, int &$i = 0,
/**
* Parses a YAML mapping.
*
* @return array|\stdClass
*
* @throws ParseException When malformed inline YAML string is parsed
*/
private static function parseMapping(string $mapping, int $flags, int &$i = 0, array &$references = [])
private static function parseMapping(string $mapping, int $flags, int &$i = 0, array &$references = []): array|\stdClass
{
$output = [];
$len = \strlen($mapping);
@@ -560,11 +534,9 @@ private static function parseMapping(string $mapping, int $flags, int &$i = 0, a
/**
* Evaluates scalars and replaces magic values.
*
* @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
*/
private static function evaluateScalar(string $scalar, int $flags, array &$references = [], bool &$isQuotedString = null)
private static function evaluateScalar(string $scalar, int $flags, array &$references = [], bool &$isQuotedString = null): mixed
{
$isQuotedString = false;
$scalar = trim($scalar);
@@ -615,9 +587,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
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;
throw new ParseException('Missing value for tag "!php/object".', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}

return unserialize(self::parseScalar(substr($scalar, 12)));
@@ -631,9 +601,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
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 '';
throw new ParseException('Missing value for tag "!php/const".', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}

$i = 0;
@@ -674,22 +642,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer

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.');

return octdec($scalar);
}

$cast = (int) $scalar;

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.');

return -octdec(substr($scalar, 1));
}

$cast = (int) $scalar;

return ($scalar === (string) $cast) ? $cast : $scalar;
@@ -791,8 +744,6 @@ private static function isBinaryString(string $value): bool
/**
* Gets a regex that matches a YAML date.
*
* @return string
*
* @see http://www.yaml.org/spec/1.2/spec.html#id2761573
*/
private static function getTimestampRegex(): string
Loading