Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove unused local variables #34105

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

Conversation

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Oct 24, 2019

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

This PR removes useless assignations. There are also somes fixes in tests.

@@ -81,8 +89,10 @@ public function testConstructorThrowsExceptionIfNoRelatedForm()

$nodes = $dom->getElementsByTagName('input');

$form = new Form($nodes->item(0), 'http://example.com');
$form = new Form($nodes->item(1), 'http://example.com');
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 second one is never tested since the first one throws an exception.

@fancyweb fancyweb changed the title Remove unused local variables in tests [WIP] Remove unused local variables in tests Oct 24, 2019
@fancyweb fancyweb force-pushed the all-remove-unused-local-variables-in-tests-34 branch from 0f80fb6 to b806624 Compare October 24, 2019 15:33
@fancyweb fancyweb requested a review from xabbuh as a code owner October 24, 2019 15:33
@fancyweb fancyweb force-pushed the all-remove-unused-local-variables-in-tests-34 branch from b806624 to c07cee8 Compare October 24, 2019 15:34
@fancyweb fancyweb changed the title [WIP] Remove unused local variables in tests [WIP] Remove unused local variables Oct 24, 2019
@fancyweb fancyweb changed the title [WIP] Remove unused local variables Remove unused local variables Oct 24, 2019
@fancyweb fancyweb requested a review from yceruto October 24, 2019 15:45
@@ -130,7 +130,6 @@ public function update(Response $response)
$response->headers->set('Cache-Control', implode(', ', array_keys($flags)));

$maxAge = null;
$sMaxage = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

$sMaxage is assigned line 140 and only used in the if.

@@ -49,7 +49,6 @@ public function collect(Request $request, Response $response, \Exception $except
}
}

$content = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

$content is directly assigned in the try and in the catch and there is not check on it.

@@ -59,7 +58,6 @@ public function collect(Request $request, Response $response, \Exception $except

$sessionMetadata = [];
$sessionAttributes = [];
$session = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

$session is assigned line 63 and only used in the if.

@@ -196,7 +196,7 @@ public function testCachingWithDifferentNamesOrder()
$cacheMock = $this->getMockBuilder('Psr\Cache\CacheItemPoolInterface')->getMock();
$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
$expressionLanguage = new ExpressionLanguage($cacheMock);
$savedParsedExpressions = [];
$savedParsedExpression = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one is a fix on the test.

@@ -219,7 +219,7 @@ public function dump(array $options = [])
foreach ($ids as $id) {
$c .= ' '.$this->doExport($id)." => true,\n";
}
$files['removed-ids.php'] = $c .= "];\n";
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 resulting $c is never reused so the assignation is useless.

@@ -404,7 +404,7 @@ private function darwinRealpath($real)
}

if (isset($dirFiles[$file])) {
return $real .= $dirFiles[$file];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Returning an assignation is useless, $real is not passed by ref.

@@ -1043,8 +1043,6 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co
$container->getDefinition('assets.url_package')->setPrivate(true);
$container->getDefinition('assets.static_version_strategy')->setPrivate(true);

$defaultVersion = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

$defaultVersion is always assigned in the if else block.

@@ -425,7 +425,6 @@ private function renderEventListenerTable(EventDispatcherInterface $eventDispatc
$tableHeaders = ['Order', 'Callable', 'Priority'];
$tableRows = [];

$order = 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

$order is directly reassigned by the foreach.

@@ -28,7 +28,6 @@ public function compile(Compiler $compiler)

preg_match('/_([^_]+)$/', $this->getAttribute('name'), $matches);

$label = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

$label is assigned line 42 and only used in this code path.

@@ -132,9 +132,6 @@ public function testFindProcessInOpenBasedir()
$this->assertSamePath(PHP_BINARY, $result);
}

/**
* @requires PHP 5.4
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Min PHP version is 5.5.9.

@Tobion
Copy link
Contributor

Tobion commented Oct 25, 2019

Thank you @fancyweb.

Tobion added a commit that referenced this pull request Oct 25, 2019
This PR was merged into the 3.4 branch.

Discussion
----------

Remove unused local variables

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

This PR removes useless assignations. There are also somes fixes in tests.

Commits
-------

c07cee8 Remove unused local variables in tests
@Tobion Tobion merged commit c07cee8 into symfony:3.4 Oct 25, 2019
@fancyweb fancyweb deleted the all-remove-unused-local-variables-in-tests-34 branch October 25, 2019 07:15
nicolas-grekas added a commit that referenced this pull request Oct 30, 2019
This PR was merged into the 4.3 branch.

Discussion
----------

[4.3] Remove unused local variables

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

Follow up of #34105 on 4.3.

Commits
-------

58161b8 [4.3] Remove unused local variables
symfony-splitter pushed a commit to symfony/serializer that referenced this pull request Oct 30, 2019
This PR was merged into the 4.3 branch.

Discussion
----------

[4.3] Remove unused local variables

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

Follow up of symfony/symfony#34105 on 4.3.

Commits
-------

58161b8eec [4.3] Remove unused local variables
symfony-splitter pushed a commit to symfony/security-bundle that referenced this pull request Oct 30, 2019
This PR was merged into the 4.3 branch.

Discussion
----------

[4.3] Remove unused local variables

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

Follow up of symfony/symfony#34105 on 4.3.

Commits
-------

58161b8eec [4.3] Remove unused local variables
symfony-splitter pushed a commit to symfony/http-client that referenced this pull request Oct 30, 2019
This PR was merged into the 4.3 branch.

Discussion
----------

[4.3] Remove unused local variables

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

Follow up of symfony/symfony#34105 on 4.3.

Commits
-------

58161b8eec [4.3] Remove unused local variables
symfony-splitter pushed a commit to symfony/config that referenced this pull request Oct 30, 2019
This PR was merged into the 4.3 branch.

Discussion
----------

[4.3] Remove unused local variables

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

Follow up of symfony/symfony#34105 on 4.3.

Commits
-------

58161b8eec [4.3] Remove unused local variables
sadafrangian3 pushed a commit to sadafrangian3/Dependency-Injection-http-client that referenced this pull request Nov 2, 2022
This PR was merged into the 4.3 branch.

Discussion
----------

[4.3] Remove unused local variables

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

Follow up of symfony/symfony#34105 on 4.3.

Commits
-------

58161b8eec [4.3] Remove unused local variables
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