-
Notifications
You must be signed in to change notification settings - Fork 37
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
Adding Rector: Dead Code, Code quality, Coding Style, Type Declarations, Early return #107
base: master
Are you sure you want to change the base?
Conversation
Introducting Rector and updating code for the configurarion: ``` ->withPhpSets(php73: true) ->withPreparedSets( deadCode: true, codeQuality: true, codingStyle: true, typeDeclarations: true, earlyReturn: true ); ```
$data = (string) $responseObj->getBody(); | ||
$jsonResponseData = (array) json_decode($data, true); | ||
|
||
// return response data as json if possible, raw if not | ||
$result->httpResponseBody = $data && empty($jsonResponseData) ? $data : $jsonResponseData; | ||
$result->httpResponseBody = $data && [] === $jsonResponseData ? $data : $jsonResponseData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$data && $jsonResponseData === []
@@ -377,39 +362,30 @@ protected function getResponseExceptionMessage(ResponseInterface $responseObj) | |||
{ | |||
$body = (string) $responseObj->getBody(); | |||
$response = json_decode($body); | |||
if (JSON_ERROR_NONE !== json_last_error()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (json_last_error() !== JSON_ERROR_NONE) {
@@ -32,7 +32,7 @@ public function setBodyFromStreamInterface(StreamInterface $body): self | |||
$data = (string) $body; | |||
$jsonResponseData = (array) json_decode($data, true); | |||
// return response data as json if possible, raw if not | |||
$this->httpResponseBody = $data && empty($jsonResponseData) ? $data : $jsonResponseData; | |||
$this->httpResponseBody = $data && [] === $jsonResponseData ? $data : $jsonResponseData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->httpResponseBody = $data && $jsonResponseData === [] ? $data : $jsonResponseData;
Hi @RicLeP i see your comments, thank you!
What do you think ? |
It’s a code style choice so not essential, however I think it’s usually recommended, but go with what you feel it best. :) |
Since PSR-12 its not recommended to use yoda style due to less readability of the code. However i prefer yoda style as well :) |
Introducing Rector and updating the code for:
The configurarion:
Running all tests are still green