Skip to content

Commit

Permalink
php storm code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
ggoffy committed Dec 30, 2021
1 parent 3f37277 commit 30b7f7c
Show file tree
Hide file tree
Showing 21 changed files with 76 additions and 116 deletions.
6 changes: 5 additions & 1 deletion blocks/repositories.php
Expand Up @@ -83,7 +83,11 @@ function b_wggithub_repositories_show($options)
if (\count($repositoriesAll) > 0) {
foreach (\array_keys($repositoriesAll) as $i) {
$block[$i]['id'] = $repositoriesAll[$i]->getVar('repo_id');
$block[$i]['name'] = $myts->htmlSpecialChars($repositoriesAll[$i]->getVar('repo_name'));
$repoName = $myts->htmlSpecialChars($repositoriesAll[$i]->getVar('repo_name'));
if ($lenghtTitle > 0) {
$repoName = \substr($repoName, 0, $lenghtTitle);
}
$block[$i]['name'] = $repoName;
$block[$i]['htmlurl'] = $myts->htmlSpecialChars($repositoriesAll[$i]->getVar('repo_htmlurl'));
}
}
Expand Down
12 changes: 6 additions & 6 deletions class/Common/XoopsConfirm.php
Expand Up @@ -62,19 +62,19 @@ public function __construct($hiddens, $action, $object, $title = '', $label = ''
public function getFormXoopsConfirm()
{
//in order to be accessable from user and admin area this should be place in language common.php
\define('CO__\WGGITHUB_DELETE_CONFIRM', 'Confirm delete');
\define('CO__\WGGITHUB_DELETE_LABEL', 'Do you really want to delete:');
\define('CO_WGGITHUB_DELETE_CONFIRM', 'Confirm delete');
\define('CO_WGGITHUB_DELETE_LABEL', 'Do you really want to delete:');

// Get Theme Form
if ('' === $this->action) {
$this->action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER');
}
if ('' === $this->title) {
$this->title = CO__\WGGITHUB_DELETE_CONFIRM;
$this->title = CO_WGGITHUB_DELETE_CONFIRM;
}
if ('' === $this->label) {

$this->label = CO__\WGGITHUB_DELETE_LABEL;
$this->label = CO_WGGITHUB_DELETE_LABEL;
}

\xoops_load('XoopsFormLoader');
Expand All @@ -87,8 +87,8 @@ public function getFormXoopsConfirm()
}
$form->addElement(new \XoopsFormHidden('ok', 1));
$buttonTray = new \XoopsFormElementTray('');
$buttonTray->addElement(new \XoopsFormButton('', 'confirm_submit', _YES, 'submit'));
$buttonBack = new \XoopsFormButton('', 'confirm_back', _NO, 'button');
$buttonTray->addElement(new \XoopsFormButton('', 'confirm_submit', \_YES, 'submit'));
$buttonBack = new \XoopsFormButton('', 'confirm_back', \_NO, 'button');
$buttonBack->setExtra('onclick="history.go(-1);return true;"');
$buttonTray->addElement($buttonBack);
$form->addElement($buttonTray);
Expand Down
44 changes: 26 additions & 18 deletions class/Github/Api.php
Expand Up @@ -35,6 +35,7 @@ public function __construct(Http\IClient $client = NULL)


/**
* @param OAuth\Token|null $token
* @return self
*/
public function setToken(OAuth\Token $token = NULL)
Expand Down Expand Up @@ -98,9 +99,10 @@ public function getDefaultAccept()
* @see request()
*
* @param string
* @param array $parameters
* @param array $headers
* @return Http\Response
*
* @throws MissingParameterException
*/
public function delete($urlPath, array $parameters = [], array $headers = [])
{
Expand All @@ -115,9 +117,10 @@ public function delete($urlPath, array $parameters = [], array $headers = [])
* @see request()
*
* @param string
* @param array $parameters
* @param array $headers
* @return Http\Response
*
* @throws MissingParameterException
*/
public function get($urlPath, array $parameters = [], array $headers = [])
{
Expand All @@ -132,9 +135,10 @@ public function get($urlPath, array $parameters = [], array $headers = [])
* @see request()
*
* @param string
* @param array $parameters
* @param array $headers
* @return Http\Response
*
* @throws MissingParameterException
*/
public function head($urlPath, array $parameters = [], array $headers = [])
{
Expand All @@ -148,12 +152,12 @@ public function head($urlPath, array $parameters = [], array $headers = [])
* @see createRequest()
* @see request()
*
* @param string
* @param mixed
* @param $urlPath
* @param $content
* @param array $parameters
* @param array $headers
* @return Http\Response
*
* @throws MissingParameterException
* @throws JsonException
*/
public function patch($urlPath, $content, array $parameters = [], array $headers = [])
{
Expand All @@ -167,12 +171,12 @@ public function patch($urlPath, $content, array $parameters = [], array $headers
* @see createRequest()
* @see request()
*
* @param string
* @param mixed
* @param $urlPath
* @param $content
* @param array $parameters
* @param array $headers
* @return Http\Response
*
* @throws MissingParameterException
* @throws JsonException
*/
public function post($urlPath, $content, array $parameters = [], array $headers = [])
{
Expand All @@ -186,12 +190,12 @@ public function post($urlPath, $content, array $parameters = [], array $headers
* @see createRequest()
* @see request()
*
* @param string
* @param mixed
* @param $urlPath
* @param null $content
* @param array $parameters
* @param array $headers
* @return Http\Response
*
* @throws MissingParameterException
* @throws JsonException
*/
public function put($urlPath, $content = NULL, array $parameters = [], array $headers = [])
{
Expand All @@ -202,9 +206,9 @@ public function put($urlPath, $content = NULL, array $parameters = [], array $he


/**
* @param Http\Request $request
* @return Http\Response
*
* @throws Http\BadResponseException
*/
public function request(Http\Request $request)
{
Expand Down Expand Up @@ -324,9 +328,10 @@ public function decode(Http\Response $response, array $okCodes = NULL)
* @see get()
*
* @param string
* @param array $parameters
* @param array $headers
* @return Paginator
*
* @throws MissingParameterException
*/
public function paginator($urlPath, array $parameters = [], array $headers = [])
{
Expand Down Expand Up @@ -380,9 +385,10 @@ public function getUrl()

/**
* @param string
* @param array $parameters
* @param array $defaultParameters
* @return string
*
* @throws MissingParameterException
*/
protected function expandColonParameters($url, array $parameters, array $defaultParameters)
{
Expand Down Expand Up @@ -414,6 +420,8 @@ protected function expandColonParameters($url, array $parameters, array $default
* @todo Inject remaining default parameters into query string?
*
* @param string
* @param array $parameters
* @param array $defaultParameters
* @return string
*/
protected function expandUriTemplate($url, array $parameters, array $defaultParameters)
Expand Down
7 changes: 0 additions & 7 deletions class/Github/Github.php
Expand Up @@ -105,13 +105,6 @@ public function readOrgRepositories($org)
*/
private function getSetting($user = false)
{

$this->user = 'ggoffy';
$this->token = 'effca620d3b6a14813e53086c5477646743073aa';

return true;


$helper = Helper::getInstance();
$settingsHandler = $helper->getHandler('Settings');
if ($user) {
Expand Down
4 changes: 2 additions & 2 deletions class/Github/Helpers.php
Expand Up @@ -61,10 +61,10 @@ public static function jsonEncode($value)


/**
* @param mixed
* @param $json
* @param bool $assoc
* @return string
*
* @throws JsonException
*/
public static function jsonDecode($json, $assoc = false)
{
Expand Down
4 changes: 2 additions & 2 deletions class/Github/Http/AbstractClient.php
Expand Up @@ -32,9 +32,9 @@ abstract class AbstractClient extends Github\Sanity implements IClient
/**
* @see https://developer.github.com/v3/#http-redirects
*
* @param Request $request
* @return Response
*
* @throws BadResponseException
*/
public function request(Request $request)
{
Expand Down Expand Up @@ -100,9 +100,9 @@ protected function setupRequest(Request $request)


/**
* @param Request $request
* @return Response
*
* @throws BadResponseException
*/
abstract protected function process(Request $request);

Expand Down
5 changes: 3 additions & 2 deletions class/Github/Http/CachedClient.php
Expand Up @@ -27,7 +27,7 @@ class CachedClient extends Github\Sanity implements IClient


/**
* @param Storages\ICache
* @param Storages\ICache $cache
* @param IClient
* @param bool forbid checking Github for new data; more or less development purpose only
*/
Expand All @@ -49,9 +49,9 @@ public function getInnerClient()


/**
* @param Request $request
* @return Response
*
* @throws BadResponseException
*/
public function request(Request $request)
{
Expand Down Expand Up @@ -126,6 +126,7 @@ public function onResponse($callback)


/**
* @param Response $response
* @return bool
*/
protected function isCacheable(Response $response)
Expand Down
2 changes: 1 addition & 1 deletion class/Github/Http/CurlClient.php
Expand Up @@ -42,9 +42,9 @@ protected function setupRequest(Request $request)


/**
* @param Request $request
* @return Response
*
* @throws BadResponseException
*/
protected function process(Request $request)
{
Expand Down
1 change: 1 addition & 0 deletions class/Github/Http/IClient.php
Expand Up @@ -11,6 +11,7 @@
interface IClient
{
/**
* @param Request $request
* @return Response
*/
function request(Request $request);
Expand Down
2 changes: 1 addition & 1 deletion class/Github/Http/Response.php
Expand Up @@ -74,9 +74,9 @@ public function getPrevious()


/**
* @param Response|null $previous
* @return self
*
* @throws Github\LogicException
*/
public function setPrevious(Response $previous = NULL)
{
Expand Down
3 changes: 2 additions & 1 deletion class/Github/Http/StreamClient.php
Expand Up @@ -31,9 +31,9 @@ protected function setupRequest(Request $request)


/**
* @param Request $request
* @return Response
*
* @throws BadResponseException
*/
protected function process(Request $request)
{
Expand Down Expand Up @@ -102,6 +102,7 @@ protected function fileGetContents($url, array $contextOptions)
unset($http_response_header[0]);

$headers = [];
$last = '';
foreach ($http_response_header as $header) {
if (\in_array(\substr($header, 0, 1), [' ', "\t"], TRUE)) {
$headers[$last] .= ' ' . \trim($header); # RFC2616, 2.2
Expand Down
1 change: 1 addition & 0 deletions class/Github/OAuth/Configuration.php
Expand Up @@ -36,6 +36,7 @@ public function __construct($clientId, $clientSecret, array $scopes = [])


/**
* @param array $conf
* @return Configuration
*/
public static function fromArray(array $conf)
Expand Down
5 changes: 4 additions & 1 deletion class/Github/OAuth/Token.php
Expand Up @@ -99,7 +99,10 @@ public function toArray()
}


/** @internal */
/** @internal
* @param array $data
* @return Token
*/
public static function createFromArray(array $data)
{
return new static($data['value'], $data['type'], $data['scopes']);
Expand Down
5 changes: 3 additions & 2 deletions class/Github/Sanity.php
Expand Up @@ -9,7 +9,7 @@
abstract class Sanity
{
/**
* @throws LogicException
* @param $name
*/
public function & __get($name)
{
Expand All @@ -18,7 +18,8 @@ public function & __get($name)


/**
* @throws LogicException
* @param $name
* @param $value
*/
public function __set($name, $value)
{
Expand Down
2 changes: 2 additions & 0 deletions class/Github/Storages/FileCache.php
Expand Up @@ -82,6 +82,8 @@ public function load($key)
return $cached;
}
}

return false;
}


Expand Down
2 changes: 2 additions & 0 deletions class/Github/exceptions.php
Expand Up @@ -51,6 +51,8 @@ abstract class ApiException extends RuntimeException
/**
* @param string
* @param int
* @param \Exception|null $previous
* @param Http\Response|null $response
*/
public function __construct($message = '', $code = 0, \Exception $previous = NULL, Http\Response $response = NULL)
{
Expand Down
4 changes: 4 additions & 0 deletions class/MDParser/Parsedown.php
Expand Up @@ -1789,6 +1789,10 @@ protected function li($lines)
/**
* Replace occurrences $regexp with $Elements in $text. Return an array of
* elements representing the replacement.
* @param $regexp
* @param $Elements
* @param $text
* @return array
*/
protected static function pregReplaceElements($regexp, $Elements, $text)
{
Expand Down

0 comments on commit 30b7f7c

Please sign in to comment.