[OptionsResolver] Deprecate defining nested options via `setDefault()` use `setOptions()` instead

by @yceruto

Some issues have been detected in this pull request

0
Coding Standard

0
Common Typos

0
License Headers

0
Pull Request Contributor Headers

0
JSON Files Syntax

0
File Permissions

0
Merge Commits

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/59618/b0bb9a12ccca440554dbc6e584a2e28cf3b0762d/exception_messages.diff | patch -p0
diff -ru src/Symfony/Component/OptionsResolver/OptionsResolver.php src/Symfony/Component/OptionsResolver/OptionsResolver.php
--- src/Symfony/Component/OptionsResolver/OptionsResolver.php	2025-02-20 14:18:40.575563607 +0000
+++ src/Symfony/Component/OptionsResolver/OptionsResolver.php	2025-02-20 14:18:49.979582262 +0000
@@ -1003,7 +1003,7 @@
             }
 
             if (!\is_array($value)) {
-                throw new InvalidOptionsException(\sprintf('The nested option "%s" with value %s is expected to be of type array, but is of type "%s".', $this->formatOptions([$option]), $this->formatValue($value), get_debug_type($value)));
+                throw new InvalidOptionsException(\sprintf('The nested option "%s" with value "%s" is expected to be of type array, but is of type "%s".', $this->formatOptions([$option]), $this->formatValue($value), get_debug_type($value)));
             }
 
             $this->calling[$option] = true;
@@ -1054,10 +1054,10 @@
                 $allowedContainsArrayType = \count(array_filter($this->allowedTypes[$option], static fn ($item) => str_ends_with($item, '[]'))) > 0;
 
                 if (\is_array($value) && $allowedContainsArrayType) {
-                    throw new InvalidOptionsException(\sprintf('The option "%s" with value %s is expected to be of type "%s", but one of the elements is of type "%s".', $this->formatOptions([$option]), $fmtActualValue, $fmtAllowedTypes, $fmtProvidedTypes));
+                    throw new InvalidOptionsException(\sprintf('The option "%s" with value "%s" is expected to be of type "%s", but one of the elements is of type "%s".', $this->formatOptions([$option]), $fmtActualValue, $fmtAllowedTypes, $fmtProvidedTypes));
                 }
 
-                throw new InvalidOptionsException(\sprintf('The option "%s" with value %s is expected to be of type "%s", but is of type "%s".', $this->formatOptions([$option]), $fmtActualValue, $fmtAllowedTypes, $fmtProvidedTypes));
+                throw new InvalidOptionsException(\sprintf('The option "%s" with value "%s" is expected to be of type "%s", but is of type "%s".', $this->formatOptions([$option]), $fmtActualValue, $fmtAllowedTypes, $fmtProvidedTypes));
             }
         }
 

0
Usage of void in test files

0
Use ::class whenever possible

0
Deprecation Messages