Skip to content

Commit

Permalink
bug swiftmailer#1227 bugfix and code refactor: $response var might be…
Browse files Browse the repository at this point in the history
… initialized fixed; nested condition is converted to guard clause in to improve code readability (sergey.lebedev)

This PR was merged into the 6.3-dev branch.

Discussion
----------

bugfix and code refactor: $response var might be initialized fixed; nested condition is converted to guard clause in to improve code readability

<!-- Please fill in this template according to the PR you're about to submit. -->

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | yes/no
| Doc update?   | yes/no
| BC breaks?    | yes/no
| Deprecations? | yes/no
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT

$response var might be initialized - added its initialization to null
also nested condition is converted to guard clause in order to improve code readability

Commits
-------

04a4b4a code refactor: nested condition -> guard clause; $response var initialization to null
  • Loading branch information
fabpot committed Feb 11, 2020
2 parents 67b4684 04a4b4a commit 6c9dfa9
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions lib/classes/Swift/Transport/AbstractSmtpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,20 331,23 @@ public function executeCommand($command, $codes = [], &$failures = null, $pipeli
}

$this->pipeline[] = [$command, $seq, $codes, $address];

if ($pipeline && $this->pipelining) {
$response = null;
} else {
while ($this->pipeline) {
list($command, $seq, $codes, $address) = array_shift($this->pipeline);
$response = $this->getFullResponse($seq);
try {
$this->assertResponseCode($response, $codes);
} catch (Swift_TransportException $e) {
if ($this->pipeline && $address) {
$failures[] = $address;
} else {
$this->throwException($e);
}
return null;
}

$response = null;

while ($this->pipeline) {
list($command, $seq, $codes, $address) = array_shift($this->pipeline);
$response = $this->getFullResponse($seq);
try {
$this->assertResponseCode($response, $codes);
} catch (Swift_TransportException $e) {
if ($this->pipeline && $address) {
$failures[] = $address;
} else {
$this->throwException($e);
}
}
}
Expand Down

0 comments on commit 6c9dfa9

Please sign in to comment.