Skip to content

Conversation

@fancyweb
Copy link
Contributor

Q A
Branch? 4.4
Bug fix? no
New feature? no
Deprecations? -
Tickets -
License MIT
Doc PR -

Firstly, let's see if the CI is green as I expect it. I'll explain every change with a review comment.

@carsonbot carsonbot added this to the 4.4 milestone Nov 25, 2021
@fancyweb fancyweb force-pushed the minor/type-cast-redundancy branch from e390092 to 6158331 Compare November 25, 2021 12:16
protected function renderForm(FormView $view, array $vars = [])
{
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() retturns a string

}

return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars);
return $this->renderer->searchAndRenderBlock($view, 'label', $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::searchAndRenderBlock() retturns a string (same for the others)


private function getStorage(): StringStorage
{
return $this->getMockBuilder(StringStorage::class)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I replaced the mock with a real instance.

{
if ($methods) {
$methods = array_map('strtoupper', (array) $methods);
$methods = array_map('strtoupper', $methods);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

array $methods in the method args

*/
private function convertValueDataType($value, int $type)
{
$type = (int) $type;
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 $type in the args

['prefix1', false, '->parse() does not parse a number with a string prefix.', 0, false],
['1.4suffix', (float) 1.4, '->parse() parses a number with a string suffix.', 3],
['1.4suffix', (float) 1.4, '->parse() parses a number with a string suffix.', 3, false],
['1.4suffix', 1.4, '->parse() parses a number with a string suffix.', 3],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

1.4 is already a float

}

$score = (int) ($this->getCurrentTimeInMilliseconds() + $delayInMs);
$score = $this->getCurrentTimeInMilliseconds() + $delayInMs;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

getCurrentTimeInMilliseconds() returns an int, int $delayInMs = 0 in the args

public function __toString()
{
return (string) $this->template;
return $this->template;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The $template property is set by the constructor with the string $template arg.

case '+' === $scalar[0] || '-' === $scalar[0] || '.' === $scalar[0] || is_numeric($scalar[0]):
if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar)) {
$scalar = str_replace('_', '', (string) $scalar);
$scalar = str_replace('_', '', $scalar);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

$scalar comes from $scalar = trim($scalar);, trim returns a string.

@fancyweb fancyweb force-pushed the minor/type-cast-redundancy branch from 6158331 to e724d5a Compare November 25, 2021 16:40

/**
* @return string
* @return string|false
Copy link
Member

Choose a reason for hiding this comment

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

But, right now, we guarantee a string, so this is a BC break.

@nicolas-grekas
Copy link
Member

Thank you @fancyweb.

@nicolas-grekas nicolas-grekas merged commit 7b27c8d into symfony:4.4 Nov 28, 2021
@fancyweb fancyweb deleted the minor/type-cast-redundancy branch November 29, 2021 12:19
nicolas-grekas added a commit that referenced this pull request Nov 29, 2021
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
symfony-splitter pushed a commit to symfony/translation that referenced this pull request Nov 29, 2021
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 symfony/symfony#44274 on 5.3

Commits
-------

4243335012 Fix redundant type casts
SerhiyMytrovtsiy added a commit to SerhiyMytrovtsiy/translation that referenced this pull request Oct 19, 2022
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 symfony/symfony#44274 on 5.3

Commits
-------

4243335012 Fix redundant type casts
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.

5 participants