I'm using phpcs
When using code very similar to this(slightly altered for legal reasons):
function methodNameHere($desiredParameter){
$client = new Client([
'base_uri' => 'confidential uri',
]);
$headers = [
'important-header' => 'confidential value'
];
$request = new Request('GET', $desiredParameter, $headers);
$response = $client->send($request, ['timeout' => 2]);
if ($response->getStatusCode() != 200) {
throw new BadResponseException('Oops! Bad request.', $request, $response);
}
$responseBody = $response->getBody()->getContents(); // String with the response body
$paramInfo = json_decode($responseBody, true); // Associative array from response body
return $paramInfo;
}
I get the following error:
ERROR | [x] Useless variable $paramInfo.
pointing to the line where the variable $paramInfo is declared and initialized.
What am I doing wrong?
I tried reading the documentation for phpcs and slevomat but both are infuriatingly vague on this error. They just say something like "This means that this variable is useless" and don't actually explain what a useless variable is.