Skip to content

Commit

Permalink
Merge pull request #7961 from jdarwood007/lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Sesquipedalian authored Dec 22, 2023
2 parents 95d72cf + 5c80195 commit 7521dc0
Show file tree
Hide file tree
Showing 26 changed files with 105 additions and 109 deletions.
2 changes: 1 addition & 1 deletion Sources/Actions/Admin/Find.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
use SMF\IntegrationHook;
use SMF\Lang;
use SMF\Menu;
use SMF\PackageManager\XmlArray;
use SMF\User;
use SMF\Utils;
use SMF\WebFetch\WebFetchApi;
use SMF\PackageManager\XmlArray;

/**
* Provides the search functionality inside the admin control panel.
Expand Down
4 changes: 2 additions & 2 deletions Sources/Cache/APIs/Apcu.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function connect(): bool
/**
* {@inheritDoc}
*/
public function getData(string $key, int|null $ttl = null): mixed
public function getData(string $key, ?int $ttl = null): mixed
{
$key = $this->prefix . strtr($key, ':/', '-_');

Expand All @@ -66,7 +66,7 @@ public function getData(string $key, int|null $ttl = null): mixed
/**
* {@inheritDoc}
*/
public function putData(string $key, mixed $value, int|null $ttl = null): mixed
public function putData(string $key, mixed $value, ?int $ttl = null): mixed
{
$key = $this->prefix . strtr($key, ':/', '-_');

Expand Down
11 changes: 6 additions & 5 deletions Sources/Cache/APIs/FileBased.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function connect(): bool
/**
* {@inheritDoc}
*/
public function getData(string $key, int|null $ttl = null): mixed
public function getData(string $key, ?int $ttl = null): mixed
{
$file = sprintf(
'%s/data_%s.cache',
Expand All @@ -98,7 +98,7 @@ public function getData(string $key, int|null $ttl = null): mixed
/**
* {@inheritDoc}
*/
public function putData(string $key, mixed $value, int|null $ttl = null): mixed
public function putData(string $key, mixed $value, ?int $ttl = null): mixed
{
$file = sprintf(
'%s/data_%s.cache',
Expand All @@ -109,8 +109,9 @@ public function putData(string $key, mixed $value, int|null $ttl = null): mixed

if ($value === null) {
@unlink($file);

return true;
} else {
}
$cache_data = json_encode(
[
'expiration' => time() + $ttl,
Expand All @@ -128,7 +129,7 @@ public function putData(string $key, mixed $value, int|null $ttl = null): mixed
}

return true;
}

}

/**
Expand Down Expand Up @@ -198,7 +199,7 @@ public function cacheSettings(array &$config_vars): void
* @param string $dir A valid path
* @return bool If this was successful or not.
*/
public function setCachedir(string $dir = null): void
public function setCachedir(?string $dir = null): void
{
// If its invalid, use SMF's.
if (is_null($dir) || !is_writable($dir)) {
Expand Down
6 changes: 3 additions & 3 deletions Sources/Cache/APIs/MemcacheImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

declare(strict_types=1);

namespace SMF\Cache\APIs;

use Memcache;
Expand Down Expand Up @@ -124,7 +124,7 @@ public function connect(): bool
/**
* {@inheritDoc}
*/
public function getData(string $key, int $ttl = null): mixed
public function getData(string $key, ?int $ttl = null): mixed
{
$key = $this->prefix . strtr($key, ':/', '-_');

Expand All @@ -141,7 +141,7 @@ public function getData(string $key, int $ttl = null): mixed
/**
* {@inheritDoc}
*/
public function putData(string $key, mixed $value, int|null $ttl = null): mixed
public function putData(string $key, mixed $value, ?int $ttl = null): mixed
{
$key = $this->prefix . strtr($key, ':/', '-_');

Expand Down
6 changes: 3 additions & 3 deletions Sources/Cache/APIs/MemcachedImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

declare(strict_types=1);

namespace SMF\Cache\APIs;

use Memcached;
Expand Down Expand Up @@ -130,7 +130,7 @@ protected function addServers(): bool
/**
* {@inheritDoc}
*/
public function getData(string $key, int|null $ttl = null): mixed
public function getData(string $key, ?int $ttl = null): mixed
{
$key = $this->prefix . strtr($key, ':/', '-_');

Expand All @@ -147,7 +147,7 @@ public function getData(string $key, int|null $ttl = null): mixed
/**
* {@inheritDoc}
*/
public function putData(string $key, mixed $value, int|null $ttl = null): mixed
public function putData(string $key, mixed $value, ?int $ttl = null): mixed
{
$key = $this->prefix . strtr($key, ':/', '-_');

Expand Down
6 changes: 3 additions & 3 deletions Sources/Cache/APIs/Postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

declare(strict_types=1);

namespace SMF\Cache\APIs;

use SMF\Cache\CacheApi;
Expand Down Expand Up @@ -137,7 +137,7 @@ public function isSupported(bool $test = false): bool
/**
* {@inheritDoc}
*/
public function getData(string $key, int $ttl = null): mixed
public function getData(string $key, ?int $ttl = null): mixed
{
$result = pg_execute($this->db_connection, 'smf_cache_get_data', [$key, time()]);

Expand All @@ -153,7 +153,7 @@ public function getData(string $key, int $ttl = null): mixed
/**
* {@inheritDoc}
*/
public function putData(string $key, mixed $value, int|null $ttl = null): mixed
public function putData(string $key, mixed $value, ?int $ttl = null): mixed
{
$ttl = time() + (int) ($ttl !== null ? $ttl : $this->ttl);

Expand Down
6 changes: 3 additions & 3 deletions Sources/Cache/APIs/Sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

declare(strict_types=1);

namespace SMF\Cache\APIs;

use SMF\Cache\CacheApi;
Expand Down Expand Up @@ -85,7 +85,7 @@ public function isSupported(bool $test = false): bool
/**
* {@inheritDoc}
*/
public function getData(string $key, int $ttl = null): mixed
public function getData(string $key, ?int $ttl = null): mixed
{
$query = 'SELECT value FROM cache WHERE key = \'' . $this->cacheDB->escapeString($key) . '\' AND ttl >= ' . time() . ' LIMIT 1';
$result = $this->cacheDB->query($query);
Expand All @@ -102,7 +102,7 @@ public function getData(string $key, int $ttl = null): mixed
/**
* {@inheritDoc}
*/
public function putData(string $key, mixed $value, int|null $ttl = null): mixed
public function putData(string $key, mixed $value, ?int $ttl = null): mixed
{
$ttl = time() + (int) ($ttl !== null ? $ttl : $this->ttl);

Expand Down
6 changes: 3 additions & 3 deletions Sources/Cache/APIs/Zend.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

declare(strict_types=1);

namespace SMF\Cache\APIs;

use SMF\Cache\CacheApi;
Expand Down Expand Up @@ -51,7 +51,7 @@ public function connect(): bool
/**
* {@inheritDoc}
*/
public function getData(string $key, int $ttl = null): mixed
public function getData(string $key, ?int $ttl = null): mixed
{
$key = $this->prefix . strtr($key, ':/', '-_');

Expand All @@ -70,7 +70,7 @@ public function getData(string $key, int $ttl = null): mixed
/**
* {@inheritDoc}
*/
public function putData(string $key, mixed $value, int|null $ttl = null): mixed
public function putData(string $key, mixed $value, ?int $ttl = null): mixed
{
$key = $this->prefix . strtr($key, ':/', '-_');

Expand Down
2 changes: 1 addition & 1 deletion Sources/Cache/CacheApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

declare(strict_types=1);

namespace SMF\Cache;

use SMF\BackwardCompatibility;
Expand Down
6 changes: 3 additions & 3 deletions Sources/Cache/CacheApiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

declare(strict_types=1);

namespace SMF\Cache;

if (!defined('SMF')) {
Expand Down Expand Up @@ -45,7 +45,7 @@ public function connect(): bool;
* @return mixed The result from the cache, if there is no data or it is invalid, we return null.
* @todo Separate existence checking into its own method
*/
public function getData(string $key, int|null $ttl = null): mixed;
public function getData(string $key, ?int $ttl = null): mixed;

/**
* Stores a value, regardless of whether or not the key already exists (in
Expand All @@ -58,7 +58,7 @@ public function getData(string $key, int|null $ttl = null): mixed;
* @return mixed Whether or not we could save this to the cache.
* @todo Separate deletion into its own method
*/
public function putData(string $key, mixed $value, int|null $ttl = null): mixed;
public function putData(string $key, mixed $value, ?int $ttl = null): mixed;

/**
* Clean out the cache.
Expand Down
29 changes: 15 additions & 14 deletions Sources/Db/APIs/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class MySQL extends DatabaseApi implements DatabaseApiInterface
/**
* {@inheritDoc}
*/
public function query(string $identifier, string $db_string, array $db_values = [], object $connection = null): object|bool
public function query(string $identifier, string $db_string, array $db_values = [], ?object $connection = null): object|bool
{
// Comments that are allowed in a query are preg_removed.
$allowed_comments_from = [
Expand Down Expand Up @@ -256,7 +256,7 @@ public function query(string $identifier, string $db_string, array $db_values =
/**
* {@inheritDoc}
*/
public function quote(string $db_string, array $db_values, object $connection = null): string
public function quote(string $db_string, array $db_values, ?object $connection = null): string
{
// Only bother if there's something to replace.
if (strpos($db_string, '{') !== false) {
Expand Down Expand Up @@ -305,13 +305,14 @@ public function fetch_all(object $request): array
public function free_result(object $result): bool
{
mysqli_free_result($result);

return true;
}

/**
* {@inheritDoc}
*/
public function insert(string $method, string $table, array $columns, array $data, array $keys, int $returnmode = 0, object $connection = null): int|array|null
public function insert(string $method, string $table, array $columns, array $data, array $keys, int $returnmode = 0, ?object $connection = null): int|array|null
{
$connection = $connection ?? $this->connection;

Expand Down Expand Up @@ -508,7 +509,7 @@ public function insert(string $method, string $table, array $columns, array $dat
/**
* {@inheritDoc}
*/
public function insert_id(string $table, string $field = null, object $connection = null): int
public function insert_id(string $table, ?string $field = null, ?object $connection = null): int
{
// MySQL doesn't need the table or field information.
return mysqli_insert_id($connection ?? $this->connection);
Expand Down Expand Up @@ -541,7 +542,7 @@ public function num_fields(object $result): int
/**
* {@inheritDoc}
*/
public function escape_string(string $string, object $connection = null): string
public function escape_string(string $string, ?object $connection = null): string
{
return mysqli_real_escape_string($connection ?? $this->connection, $string);
}
Expand All @@ -557,23 +558,23 @@ public function unescape_string(string $string): string
/**
* {@inheritDoc}
*/
public function server_info(object $connection = null): string
public function server_info(?object $connection = null): string
{
return mysqli_get_server_info($connection ?? $this->connection);
}

/**
* {@inheritDoc}
*/
public function affected_rows(object $connection = null): int
public function affected_rows(?object $connection = null): int
{
return mysqli_affected_rows($connection ?? $this->connection);
}

/**
* {@inheritDoc}
*/
public function transaction(string $type = 'commit', object $connection = null): bool
public function transaction(string $type = 'commit', ?object $connection = null): bool
{
$type = strtoupper($type);

Expand Down Expand Up @@ -603,7 +604,7 @@ public function error(object $connection): string
/**
* {@inheritDoc}
*/
public function select(string $database, object $connection = null): bool
public function select(string $database, ?object $connection = null): bool
{
return mysqli_select_db($connection ?? $this->connection, $database);
}
Expand Down Expand Up @@ -639,7 +640,7 @@ public function is_resource(mixed $result): bool
/**
* {@inheritDoc}
*/
public function ping(object $connection = null): bool
public function ping(?object $connection = null): bool
{
return mysqli_ping($connection ?? $this->connection);
}
Expand Down Expand Up @@ -1152,7 +1153,7 @@ public function allow_persistent(): bool
/**
* {@inheritDoc}
*/
public function search_query(string $identifier, string $db_string, array $db_values = [], object $connection = null): object|bool
public function search_query(string $identifier, string $db_string, array $db_values = [], ?object $connection = null): object|bool
{
return $this->query($identifier, $db_string, $db_values, $connection);
}
Expand Down Expand Up @@ -1197,7 +1198,7 @@ public function create_word_search(string $size): void
/**
* {@inheritDoc}
*/
public function search_language(): string|null
public function search_language(): ?string
{
return null;
}
Expand Down Expand Up @@ -1340,7 +1341,7 @@ public function add_index(string $table_name, array $index_info, array $paramete
/**
* {@inheritDoc}
*/
public function calculate_type(string $type_name, int $type_size = null, bool $reverse = false): array
public function calculate_type(string $type_name, ?int $type_size = null, bool $reverse = false): array
{
// MySQL is actually the generic baseline.

Expand Down Expand Up @@ -2274,7 +2275,7 @@ protected function replacement__callback(array $matches): string
* @param int $line What line of $file the code which generated the error is on
* @return void|array Returns an array with the file and line if $error_type is 'return'
*/
protected function error_backtrace(string $error_message, string $log_message = '', string|int|bool $error_type = false, string $file = null, int $line = null): array|null
protected function error_backtrace(string $error_message, string $log_message = '', string|int|bool $error_type = false, ?string $file = null, ?int $line = null): ?array
{
if (empty($log_message)) {
$log_message = $error_message;
Expand Down
Loading

0 comments on commit 7521dc0

Please sign in to comment.