Skip to content

Commit bedd09f

Browse files
minor #44330 Fix redundant type casts (fancyweb)
This PR was merged into the 5.3 branch. Discussion ---------- Fix redundant type casts | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Continuation of #44274 on 5.3 Commits ------- 4243335 Fix redundant type casts
2 parents af596bf + 4243335 commit bedd09f

File tree

13 files changed

+33
-36
lines changed

13 files changed

+33
-36
lines changed

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static function createChoiceLabel(object $choice): string
7575
*/
7676
public static function createChoiceName(object $choice, $key, string $value): string
7777
{
78-
return str_replace('-', '_', (string) $value);
78+
return str_replace('-', '_', $value);
7979
}
8080

8181
/**

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private function __construct(array $thresholds = [], $regex = '', $verboseOutput
107107
if (!isset($this->verboseOutput[$group])) {
108108
throw new \InvalidArgumentException(sprintf('Unsupported verbosity group "%s", expected one of "%s".', $group, implode('", "', array_keys($this->verboseOutput))));
109109
}
110-
$this->verboseOutput[$group] = (bool) $status;
110+
$this->verboseOutput[$group] = $status;
111111
}
112112

113113
if ($generateBaseline && !$baselineFile) {

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function setUp(): void
5959

6060
protected function renderForm(FormView $view, array $vars = []): string
6161
{
62-
return (string) $this->renderer->renderBlock($view, 'form', $vars);
62+
return $this->renderer->renderBlock($view, 'form', $vars);
6363
}
6464

6565
protected function renderLabel(FormView $view, $label = null, array $vars = []): string
@@ -68,42 +68,42 @@ protected function renderLabel(FormView $view, $label = null, array $vars = []):
6868
$vars += ['label' => $label];
6969
}
7070

71-
return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars);
71+
return $this->renderer->searchAndRenderBlock($view, 'label', $vars);
7272
}
7373

7474
protected function renderHelp(FormView $view): string
7575
{
76-
return (string) $this->renderer->searchAndRenderBlock($view, 'help');
76+
return $this->renderer->searchAndRenderBlock($view, 'help');
7777
}
7878

7979
protected function renderErrors(FormView $view): string
8080
{
81-
return (string) $this->renderer->searchAndRenderBlock($view, 'errors');
81+
return $this->renderer->searchAndRenderBlock($view, 'errors');
8282
}
8383

8484
protected function renderWidget(FormView $view, array $vars = []): string
8585
{
86-
return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars);
86+
return $this->renderer->searchAndRenderBlock($view, 'widget', $vars);
8787
}
8888

8989
protected function renderRow(FormView $view, array $vars = []): string
9090
{
91-
return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars);
91+
return $this->renderer->searchAndRenderBlock($view, 'row', $vars);
9292
}
9393

9494
protected function renderRest(FormView $view, array $vars = []): string
9595
{
96-
return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars);
96+
return $this->renderer->searchAndRenderBlock($view, 'rest', $vars);
9797
}
9898

9999
protected function renderStart(FormView $view, array $vars = []): string
100100
{
101-
return (string) $this->renderer->renderBlock($view, 'form_start', $vars);
101+
return $this->renderer->renderBlock($view, 'form_start', $vars);
102102
}
103103

104104
protected function renderEnd(FormView $view, array $vars = []): string
105105
{
106-
return (string) $this->renderer->renderBlock($view, 'form_end', $vars);
106+
return $this->renderer->renderBlock($view, 'form_end', $vars);
107107
}
108108

109109
protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true): void

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function testMoneyWidgetInIso()
111111

112112
protected function renderForm(FormView $view, array $vars = []): string
113113
{
114-
return (string) $this->renderer->renderBlock($view, 'form', $vars);
114+
return $this->renderer->renderBlock($view, 'form', $vars);
115115
}
116116

117117
protected function renderLabel(FormView $view, $label = null, array $vars = []): string
@@ -120,42 +120,42 @@ protected function renderLabel(FormView $view, $label = null, array $vars = []):
120120
$vars += ['label' => $label];
121121
}
122122

123-
return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars);
123+
return $this->renderer->searchAndRenderBlock($view, 'label', $vars);
124124
}
125125

126126
protected function renderHelp(FormView $view): string
127127
{
128-
return (string) $this->renderer->searchAndRenderBlock($view, 'help');
128+
return $this->renderer->searchAndRenderBlock($view, 'help');
129129
}
130130

131131
protected function renderErrors(FormView $view): string
132132
{
133-
return (string) $this->renderer->searchAndRenderBlock($view, 'errors');
133+
return $this->renderer->searchAndRenderBlock($view, 'errors');
134134
}
135135

136136
protected function renderWidget(FormView $view, array $vars = []): string
137137
{
138-
return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars);
138+
return $this->renderer->searchAndRenderBlock($view, 'widget', $vars);
139139
}
140140

141141
protected function renderRow(FormView $view, array $vars = []): string
142142
{
143-
return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars);
143+
return $this->renderer->searchAndRenderBlock($view, 'row', $vars);
144144
}
145145

146146
protected function renderRest(FormView $view, array $vars = []): string
147147
{
148-
return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars);
148+
return $this->renderer->searchAndRenderBlock($view, 'rest', $vars);
149149
}
150150

151151
protected function renderStart(FormView $view, array $vars = []): string
152152
{
153-
return (string) $this->renderer->renderBlock($view, 'form_start', $vars);
153+
return $this->renderer->renderBlock($view, 'form_start', $vars);
154154
}
155155

156156
protected function renderEnd(FormView $view, array $vars = []): string
157157
{
158-
return (string) $this->renderer->renderBlock($view, 'form_end', $vars);
158+
return $this->renderer->renderBlock($view, 'form_end', $vars);
159159
}
160160

161161
protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true): void

src/Symfony/Component/Console/Question/Question.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function setHidden(bool $hidden)
105105
throw new LogicException('A hidden question cannot use the autocompleter.');
106106
}
107107

108-
$this->hidden = (bool) $hidden;
108+
$this->hidden = $hidden;
109109

110110
return $this;
111111
}
@@ -127,7 +127,7 @@ public function isHiddenFallback()
127127
*/
128128
public function setHiddenFallback(bool $fallback)
129129
{
130-
$this->hiddenFallback = (bool) $fallback;
130+
$this->hiddenFallback = $fallback;
131131

132132
return $this;
133133
}
@@ -230,11 +230,8 @@ public function getValidator()
230230
*/
231231
public function setMaxAttempts(?int $attempts)
232232
{
233-
if (null !== $attempts) {
234-
$attempts = (int) $attempts;
235-
if ($attempts < 1) {
236-
throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
237-
}
233+
if (null !== $attempts && $attempts < 1) {
234+
throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
238235
}
239236

240237
$this->attempts = $attempts;

src/Symfony/Component/DependencyInjection/Definition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function setDecoratedService(?string $id, string $renamedId = null, int $
146146
if (null === $id) {
147147
$this->decoratedService = null;
148148
} else {
149-
$this->decoratedService = [$id, $renamedId, (int) $priority];
149+
$this->decoratedService = [$id, $renamedId, $priority];
150150

151151
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
152152
$this->decoratedService[] = $invalidBehavior;

src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function set(string $name, $value)
109109
*/
110110
public function has(string $name)
111111
{
112-
return \array_key_exists((string) $name, $this->parameters);
112+
return \array_key_exists($name, $this->parameters);
113113
}
114114

115115
/**

src/Symfony/Component/Form/AbstractRendererEngine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function setTheme(FormView $view, $themes, bool $useDefaultThemes = true)
6868

6969
// Do not cast, as casting turns objects into arrays of properties
7070
$this->themes[$cacheKey] = \is_array($themes) ? $themes : [$themes];
71-
$this->useDefaultThemes[$cacheKey] = (bool) $useDefaultThemes;
71+
$this->useDefaultThemes[$cacheKey] = $useDefaultThemes;
7272

7373
// Unset instead of resetting to an empty array, in order to allow
7474
// implementations (like TwigRendererEngine) to check whether $cacheKey

src/Symfony/Component/Form/FormFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function createNamedBuilder(string $name, string $type = FormType::class,
6666

6767
$type = $this->registry->getType($type);
6868

69-
$builder = $type->createBuilder($this, (string) $name, $options);
69+
$builder = $type->createBuilder($this, $name, $options);
7070

7171
// Explicitly call buildForm() in order to be able to override either
7272
// createBuilder() or buildForm() in the resolved form type

src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function escape(string $subject, string $ignore = '', int $flags = 0)
7272
$value = ldap_escape($subject, $ignore, $flags);
7373

7474
// Per RFC 4514, leading/trailing spaces should be encoded in DNs, as well as carriage returns.
75-
if ((int) $flags & \LDAP_ESCAPE_DN) {
75+
if ($flags & \LDAP_ESCAPE_DN) {
7676
if (!empty($value) && ' ' === $value[0]) {
7777
$value = '\\20'.substr($value, 1);
7878
}

0 commit comments

Comments
 (0)