Skip to content

Conversation

StaffNowa
Copy link
Contributor

Q A
Branch? 5.x
Bug fix? no
New feature? no
Deprecations? no
Tickets Fix #40712, #40733
License MIT
Doc PR -

Removed duplicated variable $errorCode.

Many thanks for:
@OskarStark, @jderusse and special thanks for @chalasr for fast rebase course at night :)))

@StaffNowa StaffNowa requested a review from OskarStark as a code owner April 8, 2021 03:51
@Nyholm Nyholm added the Notifier label Apr 8, 2021
@carsonbot carsonbot changed the title LightSMS duplicated $errorCode variable fix [Notifier] LightSMS duplicated $errorCode variable fix Apr 8, 2021
@@ -124,8 +124,7 @@ protected function doSend(MessageInterface $message): SentMessage

$content = $response->toArray(false);

if (0 !== (int) ($content['error'] ?? $content['']['error'] ?? $content[$phone]['error']) ?? -1) {
$errorCode = (int) ($content['error'] ?? $content['']['error'] ?? $content[$phone]['error']) ?? -1;
if ($errorCode = (int) ($content['error'] ?? $content['']['error'] ?? $content[$phone]['error']) ?? -1) {
Copy link
Member

Choose a reason for hiding this comment

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

Im sure this code is correct. But could we make it a bit more readable?

$errorCode = (int) ($content['error'] ?? $content['']['error'] ?? $content[$phone]['error']) ?? -1
if (0 !== $errorCode) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Nyholm good question :) For now do not have any suggestions how to make it more readable :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yesterday, I created new method with if isset, but it is not good as understand @jderusse

Copy link
Member

Choose a reason for hiding this comment

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

What do you think about my suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

👍 for Tobias' suggestion. That's also what ##40733 (comment) suggested to do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chalasr is it not the same like here #40735? :) changed :) little bit confused now :D

Copy link
Member

Choose a reason for hiding this comment

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

we both suggested

$errorCode = (int) ($content['error'] ?? $content['']['error'] ?? $content[$phone]['error']) ?? -1;
if (0 !== $code) {

you implemented

if ($errorCode = (int) ($content['error'] ?? $content['']['error'] ?? $content[$phone]['error']) ?? -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.

@jderusse sorry misunderstanding :) @Nyholm show me screen 👍

@chalasr chalasr added this to the 5.x milestone Apr 8, 2021
@OskarStark OskarStark requested review from Nyholm and jderusse April 8, 2021 10:49
@Nyholm
Copy link
Member

Nyholm commented Apr 8, 2021

Thanks Vasilij.

@Nyholm Nyholm merged commit 1d8ad1d into symfony:5.x Apr 8, 2021
@StaffNowa StaffNowa deleted the lightsms-suggestion branch April 9, 2021 16:33
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