-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Fix redundant type casts #44330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix redundant type casts #44330
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
if ($generateBaseline && !$baselineFile) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,7 +105,7 @@ public function setHidden(bool $hidden) | |
throw new LogicException('A hidden question cannot use the autocompleter.'); | ||
} | ||
|
||
F438 $this->hidden = (bool) $hidden; | ||
$this->hidden = $hidden; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
return $this; | ||
} | ||
|
@@ -127,7 +127,7 @@ public function isHiddenFallback() | |
*/ | ||
public function setHiddenFallback(bool $fallback) | ||
{ | ||
$this->hiddenFallback = (bool) $fallback; | ||
$this->hiddenFallback = $fallback; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
throw new InvalidArgumentException('Maximum number of attempts must be a positive value.'); | ||
} | ||
|
||
$this->attempts = $attempts; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { | ||
$this->decoratedService[] = $invalidBehavior; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// Unset instead of resetting to an empty array, in order to allow | ||
// implementations (like TwigRendererEngine) to check whether $cacheKey | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1241
|
||
|
||
// Explicitly call buildForm() in order to be able to override either | ||
// createBuilder() or buildForm() in the resolved form type | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (!empty($value) && ' ' === $value[0]) { | ||
$value = '\\20'.substr($value, 1); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
throw new InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale)); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} elseif (str_contains($name, ':')) { | ||
[$prefix, $className] = explode(':', $name, 2); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,7 +207,7 @@ public function __toString() | |
public function withMaxDepth(int $maxDepth) | ||
{ | ||
$data = clone $this; | ||
$data->maxDepth = (int) $maxDepth; | ||
$data->maxDepth = $maxDepth; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
return $data; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string $value
in args