formatting

This commit is contained in:
Max Nuding 2024-04-10 11:52:35 +02:00
parent 7f16b67d02
commit 2f5aa63306
No known key found for this signature in database
4 changed files with 847 additions and 851 deletions

View File

@ -1,8 +1,12 @@
{
"com.thorlaksson.phpcs.formatOnSave" : true,
"com.thorlaksson.phpcs.runOnChange" : "onSave",
"com.thorlaksson.phpcs.standard" : "phpcs.xml",
"editor.default_syntax" : "php",
"php.validate" : "onSave",
"prettier.format-on-save" : "Disable",
"prettier.format-on-save.ignore-remote" : "Disable",
"prettier.format-on-save.ignore-without-config" : "Disable",
"workspace.color" : 1,
"workspace.name" : "APnutI"
}

View File

@ -18,10 +18,10 @@
<property name="eolChar" value="\n"/>
</properties>
</rule>
<arg name="tab-width" value="2"/>
<arg name="tab-width" value="4"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="2"/>
<property name="indent" value="4"/>
</properties>
</rule>

View File

@ -7,7 +7,6 @@ use APnutI\Entities\Poll;
use APnutI\Entities\User;
use APnutI\Entities\Channel;
use APnutI\Exceptions\PnutException;
use APnutI\Exceptions\NotFoundException;
use APnutI\Exceptions\NotAuthorizedException;
use APnutI\Exceptions\HttpPnutException;
use APnutI\Exceptions\HttpPnutRedirectException;
@ -212,7 +211,7 @@ class APnutI
}
if ($method === 'GET' && isset($parameters['access_token'])) {
$this->logger->info('Using provided token for auth');
$headers[] = 'Authorization: Bearer ' . $params['access_token'];
$headers[] = 'Authorization: Bearer ' . $parameters['access_token'];
} elseif (!empty($this->access_token)) {
$this->logger->info('Using access token for auth');
$headers[] = 'Authorization: Bearer ' . $this->access_token;
@ -232,7 +231,6 @@ class APnutI
$response = curl_exec($ch);
$request = curl_getinfo($ch, CURLINFO_HEADER_OUT);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$effectiveURL = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch);
$this->logger->debug(
"{$method} Request to {$url}. Received status: {$http_status}. Response: {$response}"
@ -294,9 +292,7 @@ class APnutI
throw new PnutException($response['error']);
}
// look for response migration errors
} elseif (
isset($response['meta'], $response['meta']['error_message'])
) {
} elseif (isset($response['meta'], $response['meta']['error_message'])) {
throw new PnutException(
$response['meta']['error_message'],
$response['meta']['code']
@ -316,7 +312,7 @@ class APnutI
throw new PnutException(
'No response ' .
json_encode($response) .
", http status: ${http_status}"
", http status: {$http_status}"
);
}
}
@ -484,11 +480,7 @@ class APnutI
foreach ($posts as $post) {
$post_obj[] = new Post($post, $this);
}
} while (
$this->meta != null &&
$this->meta->more &&
(count($post_obj) < $count || $count !== 0)
);
} while ($this->meta != null && $this->meta->more && (count($post_obj) < $count || $count !== 0));
return $post_obj;
}
@ -570,7 +562,7 @@ class APnutI
'include_html' => false,
'include_post_raw' => true,
];
return $this->getPollFromEndpoint('/posts/' . $post_id, $arg);
return $this->getPollFromEndpoint('/posts/' . $post_id, $args);
} else {
$this->logger->debug('Poll token seems to be an actual poll token');
return $this->getPollFromToken($poll_id, $poll_token);
@ -611,10 +603,10 @@ class APnutI
} catch (NotSupportedPollException $e) {
$this->logger->error('Poll not supported: ' . json_encode($res));
throw $e;
} catch (HttpPnutForbiddenException $fe) {
} catch (HttpPnutForbiddenException) {
$this->logger->error('Poll token required and not provided!');
throw new PollAccessRestrictedException();
} catch (NotAuthorizedException $nauth) {
} catch (NotAuthorizedException) {
$this->logger->error('Not authorized when fetching poll');
throw new PollAccessRestrictedException();
}
@ -666,7 +658,7 @@ class APnutI
$p = new Post($this->get('/posts/' . $post_id, $args), $this);
$this->logger->debug(json_encode($p));
return $p;
} catch (NotAuthorizedException $nae) {
} catch (NotAuthorizedException) {
$this->logger->warning(
'NotAuthorizedException when getting post, trying without access token'
);
@ -753,7 +745,7 @@ class APnutI
bool $auto_crop = false,
array $raw = []
): Post {
return createPost($text, $reply_to, $is_nsfw, $auto_crop, $raw);
return $this->createPost($text, $reply_to, $is_nsfw, $auto_crop, $raw);
}
public function createPost(