[6.2] [Yaml] Dumper fix and refactor

by @donquixote

Some issues have been detected in this pull request

Issues that can be fixed by applying a patch

Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:

curl https://fabbot.io/patch/symfony/symfony/46731/84cb847fc036ec0b1484b713cc0cc4e5b19f3f5b/cs.diff | patch -p0
diff -ru src/Symfony/Component/Yaml/Dumper.php src/Symfony/Component/Yaml/Dumper.php
--- src/Symfony/Component/Yaml/Dumper.php	2022-08-03 11:20:10.151981666 +0000
+++ src/Symfony/Component/Yaml/Dumper.php	2022-08-03 11:20:11.302023387 +0000
@@ -39,7 +39,7 @@
         }
 
         $this->indentation = $indentation;
-        $this->indentStr = \str_repeat(' ', $indentation);
+        $this->indentStr = str_repeat(' ', $indentation);
     }
 
     /**
@@ -65,8 +65,8 @@
 
         if ($this->shouldDumpAsInline($inline, $input, $flags)) {
             return $prefix
-                . ($tag !== null ? '!' . $tag . ' ' : '')
-                . Inline::dump($input, $flags)
+                .(null !== $tag ? '!'.$tag.' ' : '')
+                .Inline::dump($input, $flags)
             ;
         }
 
@@ -82,7 +82,7 @@
 
             $tagged = false;
             if ($value instanceof TaggedValue) {
-                $output .= ' !' . $value->getTag();
+                $output .= ' !'.$value->getTag();
                 $value = $value->getValue();
                 if ($value instanceof TaggedValue) {
                     throw new \InvalidArgumentException('Nested tags are not supported.');
@@ -107,7 +107,7 @@
                 foreach (explode("\n", $value) as $row) {
                     $output .= "\n";
                     if ('' !== $row) {
-                        $output .= $prefix . $this->indentStr . $row;
+                        $output .= $prefix.$this->indentStr.$row;
                     }
                 }
 
@@ -117,7 +117,7 @@
             $willBeInlined = $this->shouldDumpAsInline($inline - 1, $value, $flags);
 
             $output .= ($willBeInlined ? ' ' : "\n")
-                . $this->dump(
+                .$this->dump(
                     $value,
                     $inline - 1,
                     $willBeInlined
@@ -125,12 +125,12 @@
                         : $indent + ($tagged && !$dumpAsMap ? 2 : $this->indentation),
                     $flags,
                 )
-                . ($willBeInlined ? "\n" : '')
+                .($willBeInlined ? "\n" : '')
             ;
         }
 
-        if ($tag !== null) {
-            $output = '!' . $tag . "\n" . $output;
+        if (null !== $tag) {
+            $output = '!'.$tag."\n".$output;
         }
 
         return $output;
@@ -148,7 +148,7 @@
 
         if (Yaml::DUMP_OBJECT_AS_MAP & $flags
             && ($value instanceof \ArrayObject || $value instanceof \stdClass)
-            && !empty((array)$value)
+            && !empty((array) $value)
         ) {
             return false;
         }

0
Common Typos

0
License Headers

0
Pull Request Contributor Headers

0
File Permissions

0
Merge Commits

0
Exception Messages Formatting

0
Usage of void in test files

0
Use ::class whenever possible

0
Deprecation Messages