Revert "Revert "Update code style""

This reverts commit 96ae68f27d.
This commit is contained in:
DariusIII
2024-09-13 22:11:13 +02:00
parent 2170d2e263
commit e5782ae554
10 changed files with 52 additions and 83 deletions
+20 -51
View File
@@ -71,8 +71,6 @@ class IRCClient
/**
* Buffer contents.
*
* @var string
*/
protected ?string $_buffer = null;
@@ -89,12 +87,12 @@ class IRCClient
protected array $_channelData = [];
/**
* Nick name when we log in.
* Nickname when we log in.
*/
protected string $_nickName;
/**
* User name when we log in.
* Username when we log in.
*/
protected string $_userName;
@@ -150,11 +148,7 @@ class IRCClient
*/
public function setSocketTimeout(int $timeout)
{
if (! is_numeric($timeout)) {
echo 'ERROR: IRC socket timeout must be a number!'.PHP_EOL;
} else {
$this->_socket_timeout = $timeout;
}
$this->_socket_timeout = $timeout;
}
/**
@@ -164,11 +158,7 @@ class IRCClient
*/
public function setConnectionTimeout(int $timeout)
{
if (! is_numeric($timeout)) {
echo 'ERROR: IRC connection timeout must be a number!'.PHP_EOL;
} else {
$this->_remote_connection_timeout = $timeout;
}
$this->_remote_connection_timeout = $timeout;
}
/**
@@ -176,11 +166,7 @@ class IRCClient
*/
public function setConnectionRetries(int $retries)
{
if (! is_numeric($retries)) {
echo 'ERROR: IRC connection retries must be a number!'.PHP_EOL;
} else {
$this->_reconnectRetries = $retries;
}
$this->_reconnectRetries = $retries;
}
/**
@@ -190,11 +176,7 @@ class IRCClient
*/
public function setReConnectDelay(int $delay)
{
if (! is_numeric($delay)) {
echo 'ERROR: IRC reconnect delay must be a number!'.PHP_EOL;
} else {
$this->_reconnectDelay = $delay;
}
$this->_reconnectDelay = $delay;
}
/**
@@ -211,18 +193,12 @@ class IRCClient
$socket_string = $transport.'://'.$hostname.':'.$port;
if ($socket_string !== $this->_remote_socket_string || ! $this->_connected()) {
if (! \is_string($hostname) || $hostname === '') {
if ($hostname === '') {
echo 'ERROR: IRC host name must not be empty!'.PHP_EOL;
return false;
}
if (! is_numeric($port)) {
echo 'ERROR: IRC port must be a number!'.PHP_EOL;
return false;
}
$this->_remote_host = $hostname;
$this->_remote_port = $port;
$this->_remote_transport = $transport;
@@ -278,7 +254,7 @@ class IRCClient
$this->_realName = $realName;
$this->_password = $password;
if (($password !== null && ! empty($password)) && ! $this->_writeSocket('PASSWORD '.$password)) {
if (empty($password) && ! $this->_writeSocket('PASSWORD '.$password)) {
return false;
}
@@ -336,12 +312,7 @@ class IRCClient
return true;
}
/**
* Quit from IRC.
*
* @param string $message Optional disconnect message.
*/
public function quit(string $message = null): bool
public function quit(?string $message = null): bool
{
if ($this->_connected()) {
$this->_writeSocket('QUIT'.($message === null ? '' : ' :'.$message));
@@ -354,7 +325,7 @@ class IRCClient
/**
* Read the incoming buffer in a loop.
*/
public function readIncoming()
public function readIncoming(): void
{
while (true) {
$this->_readSocket();
@@ -418,9 +389,7 @@ class IRCClient
* Implementation.
* Extended classes will use this function to parse the messages in the channel using $this->_channelData.
*/
protected function processChannelMessages()
{
}
protected function processChannelMessages() {}
/**
* Join a channel.
@@ -435,7 +404,7 @@ class IRCClient
*/
protected function _pong(string $host)
{
if ($this->_writeSocket('PONG '.$host) === false) {
if (! $this->_writeSocket('PONG '.$host)) {
$this->_reconnect();
}
@@ -448,7 +417,7 @@ class IRCClient
/**
* Send PING to a host.
*/
protected function _ping(string $host)
protected function _ping(string $host): void
{
$pong = $this->_writeSocket('PING '.$host);
@@ -466,13 +435,13 @@ class IRCClient
/**
* Attempt to reconnect to IRC.
*/
protected function _reconnect()
protected function _reconnect(): void
{
if (! $this->connect($this->_remote_host, $this->_remote_port, $this->_remote_tls)) {
exit('FATAL: Could not reconnect to ('.$this->_remote_host.') after ('.$this->_reconnectRetries.') tries.'.PHP_EOL);
}
if ($this->_alreadyLoggedIn === false) {
if (! $this->_alreadyLoggedIn) {
if (! $this->login($this->_nickName, $this->_userName, $this->_realName, $this->_password)) {
exit('FATAL: Could not log in to ('.$this->_remote_host.')!'.PHP_EOL);
}
@@ -484,7 +453,7 @@ class IRCClient
/**
* Read response from the IRC server.
*/
protected function _readSocket()
protected function _readSocket(): void
{
$buffer = '';
do {
@@ -530,10 +499,10 @@ class IRCClient
/**
* Write a single character to the socket.
*
* @param string (char) $character A single character.
* @param string $character(char) $character A single character.
* @return int|bool Number of bytes written or false.
*/
protected function _writeSocketChar($character)
protected function _writeSocketChar(string $character): bool|int
{
return @fwrite($this->_socket, $character);
}
@@ -541,7 +510,7 @@ class IRCClient
/**
* Initiate stream socket to IRC server.
*/
protected function _initiateStream()
protected function _initiateStream(): void
{
$this->_closeStream();
@@ -564,7 +533,7 @@ class IRCClient
/**
* Close the socket.
*/
protected function _closeStream()
protected function _closeStream(): void
{
if ($this->_socket !== null) {
$this->_socket = null;
+10 -10
View File
@@ -111,9 +111,9 @@ class NNTP extends \Net_NNTP_Client
parent::__construct();
$this->_echo = config('nntmux.echocli');
$this->_tmux = new Tmux();
$this->_tmux = new Tmux;
$this->_nntpRetries = Settings::settingValue('..nntpretries') !== '' ? (int) Settings::settingValue('..nntpretries') : 0 + 1;
$this->colorCli = new ColorCLI();
$this->colorCli = new ColorCLI;
$this->_currentPort = config('nntmux_nntp.port');
$this->_currentServer = config('nntmux_nntp.server');
$this->_primaryNntpConnections = config('nntmux_nntp.main_nntp_connections');
@@ -521,7 +521,7 @@ class NNTP extends \Net_NNTP_Client
$body = '';
$aConnected = false;
$nntp = ($alternate ? new self() : null);
$nntp = ($alternate ? new self : null);
// Check if the msgIds are in an array.
if (\is_array($identifiers)) {
@@ -757,10 +757,10 @@ class NNTP extends \Net_NNTP_Client
* @param string $subject string The subject. ie.: $subject = 'Test article';
* @param \Exception|string $body string The message. ie.: $message = 'This is only a test, please disregard.';
* @param string $from string The poster. ie.: $from = '<anon@anon.com>';
* @param $extra string Extra, separated by \r\n
* ie.: $extra = 'Organization: <NNTmux>\r\nNNTP-Posting-Host: <127.0.0.1>';
* @param $yEnc bool Encode the message with yEnc?
* @param $compress bool Compress the message with GZip?
* @param $extra string Extra, separated by \r\n
* ie.: $extra = 'Organization: <NNTmux>\r\nNNTP-Posting-Host: <127.0.0.1>';
* @param $yEnc bool Encode the message with yEnc?
* @param $compress bool Compress the message with GZip?
* @return mixed On success : (bool) True.
* On failure : (object) PEAR_Error.
*
@@ -942,7 +942,7 @@ class NNTP extends \Net_NNTP_Client
* headers when XFeature GZip compression is enabled server side.
*
* @return \Blacklight\NNTP|array|string Our overridden function when compression is enabled.
* parent Parent function when no compression.
* parent Parent function when no compression.
*/
public function _getTextResponse(): NNTP|array|string
{
@@ -1280,8 +1280,8 @@ class NNTP extends \Net_NNTP_Client
* @param int $port (optional) The port number to connect to, defaults to 119.
* @param int $timeout (optional) How many seconds to wait before giving up when connecting.
* @param int $socketTimeout (optional) How many seconds to wait before timing out the (blocked) socket.
* @return mixed (bool) On success: True when posting allowed, otherwise false.
* (object) On failure: pear_error
* @return mixed (bool) On success: True when posting allowed, otherwise false.
* (object) On failure: pear_error
*/
public function connect($host = null, $encryption = null, $port = null, $timeout = 15, $socketTimeout = 120)
{
+11 -11
View File
@@ -1,17 +1,17 @@
<?php
use Dotenv\Dotenv;
use Dotenv\Repository\RepositoryBuilder;
use Illuminate\Contracts\Console\Kernel;
use Dotenv\Dotenv;
use Dotenv\Repository\RepositoryBuilder;
use Illuminate\Contracts\Console\Kernel;
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
require __DIR__.DIRECTORY_SEPARATOR.'app.php';
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'app/Extensions/util/PhpYenc.php';
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
require __DIR__.DIRECTORY_SEPARATOR.'app.php';
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'app/Extensions/util/PhpYenc.php';
$repository = RepositoryBuilder::createWithDefaultAdapters()->make();
$repository = RepositoryBuilder::createWithDefaultAdapters()->make();
$dotenv = Dotenv::create($repository, dirname(__DIR__, 1), null)->load();
$dotenv = Dotenv::create($repository, dirname(__DIR__, 1), null)->load();
/** @var Kernel $kernel */
$kernel = app(Kernel::class);
$kernel->bootstrap();
/** @var Kernel $kernel */
$kernel = app(Kernel::class);
$kernel->bootstrap();
+2 -2
View File
@@ -7,8 +7,8 @@
/**
* Smarty {php}{/php} block plugin.
*
* @param string $content contents of the block
* @param object $template template object
* @param string $content contents of the block
* @param object $template template object
* @param bool $ &$repeat repeat flag
* @return string content re-formatted
*/
@@ -24,8 +24,8 @@ use App\Models\Category;
*
* @usage {getcatval category=BOOKS_COMICS}
*
*@param string $params Name of constant whose value to return.
*@return Value of the specified Category constant.
* @param string $params Name of constant whose value to return.
* @return Value of the specified Category constant.
*/
function smarty_function_getcatval($params)
{
@@ -31,8 +31,8 @@ require_once 'load_plugin_dependency.php';
* @author Monte Ohrt <monte at ohrt dot com>
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
*
* @param array $params parameters
* @param Smarty_Internal_Template $template template object
* @param array $params parameters
* @param Smarty_Internal_Template $template template object
* @return string
*
* @uses smarty_function_escape_special_chars()
@@ -7,7 +7,7 @@ function load_plugin_dependency($filename)
global $smarty;
if (! isset($smarty)) {
$smarty = new Smarty();
$smarty = new Smarty;
}
switch (true) {
@@ -47,10 +47,10 @@ function smarty_modifier_fsize_format($size, $format = '', $precision = 2, $dec_
$sizes = array_reverse($sizes, true);
}
//~ get "human" filesize
foreach ($sizes as $unit => $bytes) {
foreach ($sizes as $unit => $bytes) {
if ($size > $bytes || $unit == $format) {
//~ return formatted size
return number_format($size / $bytes, $precision, $dec_point, $thousands_sep).' '.$unit;
return number_format($size / $bytes, $precision, $dec_point, $thousands_sep).' '.$unit;
} //~ end if
} //~ end foreach
} //~ end function
@@ -14,7 +14,7 @@ use Ytake\LaravelSmarty\Smarty;
*/
// Fix by nZEDb
if (! isset($smarty)) {
$smarty = new Smarty();
$smarty = new Smarty;
}
switch (true) {
case is_string($smarty->getPluginsDir()) && is_dir($smarty->getPluginsDir()):
@@ -9,7 +9,7 @@
*
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param DateTime|int|string $string date object, timestamp or string that can be converted using strtotime()
* @param DateTime|int|string $string date object, timestamp or string that can be converted using strtotime()
* @return int
*/
function smarty_make_timestamp($string)