diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index 324d5d26d4b06..3dc87f5af0a35 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -75,7 +75,7 @@ public static function createChoiceLabel(object $choice): string */ public static function createChoiceName(object $choice, $key, string $value): string { - return str_replace('-', '_', (string) $value); + return str_replace('-', '_', $value); } /** diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php index 99248c508ccab..4420ef3d0e46c 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php @@ -107,7 +107,7 @@ private function __construct(array $thresholds = [], $regex = '', $verboseOutput if (!isset($this->verboseOutput[$group])) { throw new \InvalidArgumentException(sprintf('Unsupported verbosity group "%s", expected one of "%s".', $group, implode('", "', array_keys($this->verboseOutput)))); } - $this->verboseOutput[$group] = (bool) $status; + $this->verboseOutput[$group] = $status; } if ($generateBaseline && !$baselineFile) { diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php index 042cbf0e40a7e..ef924884a4751 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php @@ -59,7 +59,7 @@ protected function setUp(): void protected function renderForm(FormView $view, array $vars = []): string { - return (string) $this->renderer->renderBlock($view, 'form', $vars); + return $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = []): string @@ -68,42 +68,42 @@ protected function renderLabel(FormView $view, $label = null, array $vars = []): $vars += ['label' => $label]; } - return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); + return $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderHelp(FormView $view): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'help'); + return $this->renderer->searchAndRenderBlock($view, 'help'); } protected function renderErrors(FormView $view): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); + return $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = []): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); + return $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = []): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); + return $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = []): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); + return $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = []): string { - return (string) $this->renderer->renderBlock($view, 'form_start', $vars); + return $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = []): string { - return (string) $this->renderer->renderBlock($view, 'form_end', $vars); + return $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true): void diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php index 1bf4a315fab0b..8c0e54744f964 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php @@ -111,7 +111,7 @@ public function testMoneyWidgetInIso() protected function renderForm(FormView $view, array $vars = []): string { - return (string) $this->renderer->renderBlock($view, 'form', $vars); + return $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = []): string @@ -120,42 +120,42 @@ protected function renderLabel(FormView $view, $label = null, array $vars = []): $vars += ['label' => $label]; } - return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); + return $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderHelp(FormView $view): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'help'); + return $this->renderer->searchAndRenderBlock($view, 'help'); } protected function renderErrors(FormView $view): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); + return $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = []): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); + return $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = []): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); + return $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = []): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); + return $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = []): string { - return (string) $this->renderer->renderBlock($view, 'form_start', $vars); + return $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = []): string { - return (string) $this->renderer->renderBlock($view, 'form_end', $vars); + return $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true): void diff --git a/src/Symfony/Component/Console/Question/Question.php b/src/Symfony/Component/Console/Question/Question.php index 04d2d411d6e5a..553be3404e03e 100644 --- a/src/Symfony/Component/Console/Question/Question.php +++ b/src/Symfony/Component/Console/Question/Question.php @@ -105,7 +105,7 @@ public function setHidden(bool $hidden) throw new LogicException('A hidden question cannot use the autocompleter.'); } - $this->hidden = (bool) $hidden; + $this->hidden = $hidden; return $this; } @@ -127,7 +127,7 @@ public function isHiddenFallback() */ public function setHiddenFallback(bool $fallback) { - $this->hiddenFallback = (bool) $fallback; + $this->hiddenFallback = $fallback; return $this; } @@ -230,11 +230,8 @@ public function getValidator() */ public function setMaxAttempts(?int $attempts) { - if (null !== $attempts) { - $attempts = (int) $attempts; - if ($attempts < 1) { - throw new InvalidArgumentException('Maximum number of attempts must be a positive value.'); - } + if (null !== $attempts && $attempts < 1) { + throw new InvalidArgumentException('Maximum number of attempts must be a positive value.'); } $this->attempts = $attempts; diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 90f8f886cd942..9d711f8982f46 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -146,7 +146,7 @@ public function setDecoratedService(?string $id, string $renamedId = null, int $ if (null === $id) { $this->decoratedService = null; } else { - $this->decoratedService = [$id, $renamedId, (int) $priority]; + $this->decoratedService = [$id, $renamedId, $priority]; if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { $this->decoratedService[] = $invalidBehavior; diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index fad04fc6df08f..41da2c7267a40 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -109,7 +109,7 @@ public function set(string $name, $value) */ public function has(string $name) { - return \array_key_exists((string) $name, $this->parameters); + return \array_key_exists($name, $this->parameters); } /** diff --git a/src/Symfony/Component/Form/AbstractRendererEngine.php b/src/Symfony/Component/Form/AbstractRendererEngine.php index b4437471234a3..33e66f84fc62c 100644 --- a/src/Symfony/Component/Form/AbstractRendererEngine.php +++ b/src/Symfony/Component/Form/AbstractRendererEngine.php @@ -68,7 +68,7 @@ public function setTheme(FormView $view, $themes, bool $useDefaultThemes = true) // Do not cast, as casting turns objects into arrays of properties $this->themes[$cacheKey] = \is_array($themes) ? $themes : [$themes]; - $this->useDefaultThemes[$cacheKey] = (bool) $useDefaultThemes; + $this->useDefaultThemes[$cacheKey] = $useDefaultThemes; // Unset instead of resetting to an empty array, in order to allow // implementations (like TwigRendererEngine) to check whether $cacheKey diff --git a/src/Symfony/Component/Form/FormFactory.php b/src/Symfony/Component/Form/FormFactory.php index 959f6bcf782a8..b3185d1a376c6 100644 --- a/src/Symfony/Component/Form/FormFactory.php +++ b/src/Symfony/Component/Form/FormFactory.php @@ -66,7 +66,7 @@ public function createNamedBuilder(string $name, string $type = FormType::class, $type = $this->registry->getType($type); - $builder = $type->createBuilder($this, (string) $name, $options); + $builder = $type->createBuilder($this, $name, $options); // Explicitly call buildForm() in order to be able to override either // createBuilder() or buildForm() in the resolved form type diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php index 3106ba3ce4aa0..ff6d4d9f6a023 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php @@ -72,7 +72,7 @@ public function escape(string $subject, string $ignore = '', int $flags = 0) $value = ldap_escape($subject, $ignore, $flags); // Per RFC 4514, leading/trailing spaces should be encoded in DNs, as well as carriage returns. - if ((int) $flags & \LDAP_ESCAPE_DN) { + if ($flags & \LDAP_ESCAPE_DN) { if (!empty($value) && ' ' === $value[0]) { $value = '\\20'.substr($value, 1); } diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index c432b8867fd02..ccdf88f11d11d 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -455,7 +455,7 @@ protected function computeFallbackLocales(string $locale) */ protected function assertValidLocale(string $locale) { - if (!preg_match('/^[a-z0-9@_\\.\\-]*$/i', (string) $locale)) { + if (!preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) { throw new InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale)); } } diff --git a/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php index 74f445085e47d..9f6667f836f9d 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php @@ -67,7 +67,7 @@ protected function addNamespaceAlias(string $alias, string $namespace) protected function newConstraint(string $name, $options = null) { if (str_contains($name, '\\') && class_exists($name)) { - $className = (string) $name; + $className = $name; } elseif (str_contains($name, ':')) { [$prefix, $className] = explode(':', $name, 2); diff --git a/src/Symfony/Component/VarDumper/Cloner/Data.php b/src/Symfony/Component/VarDumper/Cloner/Data.php index b17dc55e27dba..b8238c6e071e7 100644 --- a/src/Symfony/Component/VarDumper/Cloner/Data.php +++ b/src/Symfony/Component/VarDumper/Cloner/Data.php @@ -207,7 +207,7 @@ public function __toString() public function withMaxDepth(int $maxDepth) { $data = clone $this; - $data->maxDepth = (int) $maxDepth; + $data->maxDepth = $maxDepth; return $data; } @@ -220,7 +220,7 @@ public function withMaxDepth(int $maxDepth) public function withMaxItemsPerDepth(int $maxItemsPerDepth) { $data = clone $this; - $data->maxItemsPerDepth = (int) $maxItemsPerDepth; + $data->maxItemsPerDepth = $maxItemsPerDepth; return $data; }