Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4243335

Browse filesBrowse files
committed
Fix redundant type casts
1 parent c143be5 commit 4243335
Copy full SHA for 4243335

File tree

13 files changed

+33
-36
lines changed
Filter options

13 files changed

+33
-36
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php
+9-9Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php
+9-9Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Question/Question.php
+4-7Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Definition.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/AbstractRendererEngine.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/FormFactory.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php
+1-1Lines 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
}

‎src/Symfony/Component/Translation/Translator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Translator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ protected function computeFallbackLocales(string $locale)
455455
*/
456456
protected function assertValidLocale(string $locale)
457457
{
458-
if (!preg_match('/^[a-z0-9@_\\.\\-]*$/i', (string) $locale)) {
458+
if (!preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) {
459459
throw new InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale));
460460
}
461461
}

‎src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function addNamespaceAlias(string $alias, string $namespace)
6767
protected function newConstraint(string $name, $options = null)
6868
{
6969
if (str_contains($name, '\\') && class_exists($name)) {
70-
$className = (string) $name;
70+
$className = $name;
7171
} elseif (str_contains($name, ':')) {
7272
[$prefix, $className] = explode(':', $name, 2);
7373

‎src/Symfony/Component/VarDumper/Cloner/Data.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/Data.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public function __toString()
207207
public function withMaxDepth(int $maxDepth)
208208
{
209209
$data = clone $this;
210-
$data->maxDepth = (int) $maxDepth;
210+
$data->maxDepth = $maxDepth;
211211

212212
return $data;
213213
}
@@ -220,7 +220,7 @@ public function withMaxDepth(int $maxDepth)
220220
public function withMaxItemsPerDepth(int $maxItemsPerDepth)
221221
{
222222
$data = clone $this;
223-
$data->maxItemsPerDepth = (int) $maxItemsPerDepth;
223+
$data->maxItemsPerDepth = $maxItemsPerDepth;
224224

225225
return $data;
226226
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.