8000 Fix redundant type casts by fancyweb · Pull Request #44330 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 1 commit into from
Nov 29, 2021

Conversation

fancyweb
Copy link
Contributor
Q A
Branch? 5.3
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

Continuation of #44274 on 5.3

@@ -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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string $value in args

@@ -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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@param bool[] $verboseOutput in the doc + the constructor is private and only called with a $verboseOutput in fromUrlEncodedString() and inWeakMode() and we always set valid booleans values.

@@ -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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FormRendererInterface::renderBlock() returns a string

@@ -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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool $hidden in args

@@ -127,7 +127,7 @@ public function isHiddenFallback()
*/
public function setHiddenFallback(bool $fallback)
{
$this->hiddenFallback = (bool) $fallback;
$this->hiddenFallback = $fallback;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool $fallback in args

@@ -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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int $flags = 0 in args

@@ -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)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string $locale in args

@@ -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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string $name in args

@@ -207,7 +207,7 @@ public function __toString()
public function withMaxDepth(int $maxDepth)
{
$data = clone $this;
$data->maxDepth = (int) $maxDepth;
$data->maxDepth = $maxDepth;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int $maxDepth in args

@@ -220,7 +220,7 @@ public function withMaxDepth(int $maxDepth)
public function withMaxItemsPerDepth(int $maxItemsPerDepth)
{
$data = clone $this;
$data->maxItemsPerDepth = (int) $maxItemsPerDepth;
$data->maxItemsPerDepth = $maxItemsPerDepth;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int $maxItemsPerDepth in args

@nicolas-grekas
Copy link
Member

Thank you @fancyweb.

@nicolas-grekas nicolas-grekas merged commit bedd09f into symfony:5.3 Nov 29, 2021
@fancyweb fancyweb deleted the minor/type-cast-redundancy-53 branch November 29, 2021 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0