Skip to content

Commit

Permalink
PHPStan Level 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkarex authored and Joedmin committed Oct 24, 2024
1 parent ba8c2ba commit effeefb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Controllers/readeckButtonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public function requestAccessAction(): void

public function revokeAccessAction(): void
{
FreshRSS_Context::userConf()->instance_api_url = '';
FreshRSS_Context::userConf()->api_token = '';
FreshRSS_Context::userConf()->username = '';
FreshRSS_Context::userConf()->_attribute('instance_api_url');
FreshRSS_Context::userConf()->_attribute('api_token');
FreshRSS_Context::userConf()->_attribute('username');
FreshRSS_Context::userConf()->save();

$url_redirect = array('c' => 'extension', 'a' => 'configure', 'params' => array('e' => 'Readeck Button'));
Expand All @@ -65,7 +65,7 @@ public function revokeAccessAction(): void

public function addAction(): void
{
$this->view->_layout(false);
$this->view->_layout(null);

$entry_id = Minz_Request::paramString('id');
$entry_dao = FreshRSS_Factory::createEntryDao();
Expand All @@ -80,10 +80,10 @@ public function addAction(): void
'url' => $entry->link(),
);

$api_token = FreshRSS_Context::userConf()->api_token;
$instance_api_url = FreshRSS_Context::userConf()->instance_api_url;
$api_token = FreshRSS_Context::userConf()->attributeString('api_token');
$instance_api_url = FreshRSS_Context::userConf()->attributeString('instance_api_url');

$result = $this->curlPostRequest($instance_api_url . "/bookmarks", $post_data, $api_token);
$result = $this->curlPostRequest($instance_api_url . '/bookmarks', $post_data, $api_token);
$result['response'] = array('title' => $entry->title());

echo json_encode($result);
Expand All @@ -93,7 +93,7 @@ public function addAction(): void
* @param string $api_token
* @return array<string>
*/
private function getRequestHeaders($api_token): array
private function getRequestHeaders(string $api_token): array
{
return array(
'Content-Type: application/json; charset=UTF-8',
Expand All @@ -107,7 +107,7 @@ private function getRequestHeaders($api_token): array
* @param string $api_token
* @return \CurlHandle
*/
private function getCurlBase($url, $api_token): \CurlHandle
private function getCurlBase(string $url, string $api_token): \CurlHandle
{
$headers = $this->getRequestHeaders($api_token);

Expand All @@ -124,7 +124,7 @@ private function getCurlBase($url, $api_token): \CurlHandle
* @param string $api_token
* @return array<string,mixed>
*/
private function curlGetRequest($url, $api_token): array
private function curlGetRequest(string $url, string $api_token): array
{
$curl = $this->getCurlBase($url, $api_token);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
Expand All @@ -149,7 +149,7 @@ private function curlGetRequest($url, $api_token): array
* @param string $api_token
* @return array<string,mixed>
*/
private function curlPostRequest($url, $post_data, $api_token): array
private function curlPostRequest(string $url, array $post_data, string $api_token): array
{
$curl = $this->getCurlBase($url, $api_token);
curl_setopt($curl, CURLOPT_POST, true);
Expand All @@ -173,7 +173,7 @@ private function curlPostRequest($url, $post_data, $api_token): array
* @param string $header
* @return array<string,string>
*/
private function httpHeaderToArray($header): array
private function httpHeaderToArray(string $header): array
{
$headers = array();
$headers_parts = explode("\r\n", $header);
Expand Down
11 changes: 11 additions & 0 deletions Models/View.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace ReadeckButton;

final class View extends \Minz_View {

public string $readeck_button_vars = '';

}

0 comments on commit effeefb

Please sign in to comment.