no implicit nulls (they are deprecated in php8.4)

This commit is contained in:
Shish 2024-09-01 00:04:34 +01:00 committed by Shish
parent df72df8040
commit 7353683a13
19 changed files with 30 additions and 30 deletions

View file

@ -731,7 +731,7 @@ class NavLink
/**
* @param string[] $pages_matched
*/
public static function is_active(array $pages_matched, string $url = null): bool
public static function is_active(array $pages_matched, ?string $url = null): bool
{
/**
* Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.)

View file

@ -45,7 +45,7 @@ class Block
*/
public bool $is_content = true;
public function __construct(string $header = null, string|\MicroHTML\HTMLElement $body = null, string $section = "main", int $position = 50, string $id = null)
public function __construct(?string $header = null, string|\MicroHTML\HTMLElement|null $body = null, string $section = "main", int $position = 50, ?string $id = null)
{
$this->header = $header;
$this->body = (string)$body;

View file

@ -28,7 +28,7 @@ class CliApp extends \Symfony\Component\Console\Application
return $definition;
}
public function run(InputInterface $input = null, OutputInterface $output = null): int
public function run(?InputInterface $input = null, ?OutputInterface $output = null): int
{
global $user;

View file

@ -253,8 +253,8 @@ class DatabaseConfig extends Config
public function __construct(
Database $database,
string $table_name = "config",
string $sub_column = null,
string $sub_value = null
?string $sub_column = null,
?string $sub_value = null
) {
global $cache;

View file

@ -136,7 +136,7 @@ function get_thumbnail_max_size_scaled(): array
}
function create_image_thumb(Image $image, string $engine = null): void
function create_image_thumb(Image $image, ?string $engine = null): void
{
global $config;
create_scaled_image(

View file

@ -162,7 +162,7 @@ if (class_exists("\\PHPUnit\\Framework\\TestCase")) {
$this->assertEquals($code, $page->code);
}
protected function page_to_text(string $section = null): string
protected function page_to_text(?string $section = null): string
{
global $page;
if ($page->mode == PageMode::PAGE) {
@ -184,12 +184,12 @@ if (class_exists("\\PHPUnit\\Framework\\TestCase")) {
/**
* Assert that the page contains the given text somewhere in the blocks
*/
protected function assert_text(string $text, string $section = null): void
protected function assert_text(string $text, ?string $section = null): void
{
$this->assertStringContainsString($text, $this->page_to_text($section));
}
protected function assert_no_text(string $text, string $section = null): void
protected function assert_no_text(string $text, ?string $section = null): void
{
$this->assertStringNotContainsString($text, $this->page_to_text($section));
}

View file

@ -190,7 +190,7 @@ class SearchTest extends ShimmiePHPUnitTestCase
int $limit = 9999,
int $start = 0,
array $res = [],
array $path = null,
?array $path = null,
): void {
global $database;

View file

@ -26,7 +26,7 @@ class UserClass
/**
* @param array<string, bool> $abilities
*/
public function __construct(string $name, string $parent = null, array $abilities = [])
public function __construct(string $name, ?string $parent = null, array $abilities = [])
{
$this->name = $name;
$this->abilities = $abilities;

View file

@ -17,7 +17,7 @@ class BulkActionBlockBuildingEvent extends Event
/** @var string[] */
public array $search_terms = [];
public function add_action(string $action, string $button_text, string $access_key = null, string $confirmation_message = "", string $block = "", int $position = 40): void
public function add_action(string $action, string $button_text, ?string $access_key = null, string $confirmation_message = "", string $block = "", int $position = 40): void
{
if (!empty($access_key)) {
assert(strlen($access_key) == 1);

View file

@ -34,7 +34,7 @@ class ForumTheme extends Themelet
public function display_new_thread_composer(Page $page, string $threadText = null, string $threadTitle = null): void
public function display_new_thread_composer(Page $page, ?string $threadText = null, ?string $threadTitle = null): void
{
global $config, $user;
$max_characters = $config->get_int('forumMaxCharsPerPost');

View file

@ -24,7 +24,7 @@ class SearchTermParseEvent extends Event
/**
* @param string[] $context
*/
public function __construct(int $id, string $term = null, array $context = [])
public function __construct(int $id, ?string $term = null, array $context = [])
{
parent::__construct();

View file

@ -27,7 +27,7 @@ class MediaResizeEvent extends Event
int $target_width,
int $target_height,
string $resize_type = Media::RESIZE_TYPE_FIT,
string $target_mime = null,
?string $target_mime = null,
string $alpha_color = Media::DEFAULT_ALPHA_CONVERSION_COLOR,
int $target_quality = 80,
bool $minimize = false,

View file

@ -548,7 +548,7 @@ class Media extends Extension
int $new_width,
int $new_height,
string $output_filename,
string $output_mime = null,
?string $output_mime = null,
string $alpha_color = Media::DEFAULT_ALPHA_CONVERSION_COLOR,
string $resize_type = self::RESIZE_TYPE_FIT,
int $output_quality = 80,

View file

@ -399,7 +399,7 @@ class OuroborosAPI extends Extension
/**
* Wrapper for getting a single post
*/
protected function postShow(int $id = null): void
protected function postShow(?int $id = null): void
{
if (!is_null($id)) {
$post = new _SafeOuroborosImage(Image::by_id_ex($id));

View file

@ -45,7 +45,7 @@ class PoolCreationEvent extends Event
public function __construct(
string $title,
User $pool_user = null,
?User $pool_user = null,
bool $public = false,
string $description = ""
) {

View file

@ -36,7 +36,7 @@ class PostSourceTheme extends Themelet
);
}
protected function format_source(string $source = null): HTMLElement
protected function format_source(?string $source = null): HTMLElement
{
if (!empty($source)) {
if (!str_contains($source, "://")) {

View file

@ -440,7 +440,7 @@ class Ratings extends Extension
* @param ImageRating[]|null $ratings
* @return array<string, string>
*/
public static function get_ratings_dict(array $ratings = null): array
public static function get_ratings_dict(?array $ratings = null): array
{
if (!isset($ratings)) {
$ratings = self::get_sorted_ratings();

View file

@ -181,7 +181,7 @@ class SetupBlock extends Block
}
}
public function add_text_option(string $name, string $label = null, bool $table_row = false): void
public function add_text_option(string $name, ?string $label = null, bool $table_row = false): void
{
$val = html_escape($this->config->get_string($name));
@ -191,7 +191,7 @@ class SetupBlock extends Block
$this->format_option($name, $html, $label, $table_row);
}
public function add_longtext_option(string $name, string $label = null, bool $table_row = false): void
public function add_longtext_option(string $name, ?string $label = null, bool $table_row = false): void
{
$val = html_escape($this->config->get_string($name));
@ -202,7 +202,7 @@ class SetupBlock extends Block
$this->format_option($name, $html, $label, $table_row, true);
}
public function add_bool_option(string $name, string $label = null, bool $table_row = false): void
public function add_bool_option(string $name, ?string $label = null, bool $table_row = false): void
{
$checked = $this->config->get_bool($name) ? " checked" : "";
@ -221,13 +221,13 @@ class SetupBlock extends Block
$this->format_option($name, $html, null, $table_row);
}
// public function add_hidden_option($name, $label=null) {
// public function add_hidden_option($name) {
// global $config;
// $val = $config->get_string($name);
// $this->body .= "<input type='hidden' id='$name' name='$name' value='$val'>";
// }
public function add_int_option(string $name, string $label = null, bool $table_row = false): void
public function add_int_option(string $name, ?string $label = null, bool $table_row = false): void
{
$val = $this->config->get_int($name);
@ -237,7 +237,7 @@ class SetupBlock extends Block
$this->format_option($name, $html, $label, $table_row);
}
public function add_shorthand_int_option(string $name, string $label = null, bool $table_row = false): void
public function add_shorthand_int_option(string $name, ?string $label = null, bool $table_row = false): void
{
$val = to_shorthand_int($this->config->get_int($name, 0));
$html = "<input type='text' id='$name' name='_config_$name' value='$val' size='6'>\n";
@ -249,7 +249,7 @@ class SetupBlock extends Block
/**
* @param array<string,string|int> $options
*/
public function add_choice_option(string $name, array $options, string $label = null, bool $table_row = false): void
public function add_choice_option(string $name, array $options, ?string $label = null, bool $table_row = false): void
{
if (is_int(array_values($options)[0])) {
$current = $this->config->get_int($name);
@ -275,7 +275,7 @@ class SetupBlock extends Block
/**
* @param array<string,string> $options
*/
public function add_multichoice_option(string $name, array $options, string $label = null, bool $table_row = false): void
public function add_multichoice_option(string $name, array $options, ?string $label = null, bool $table_row = false): void
{
$current = $this->config->get_array($name, []);
@ -294,7 +294,7 @@ class SetupBlock extends Block
$this->format_option($name, $html, $label, $table_row);
}
public function add_color_option(string $name, string $label = null, bool $table_row = false): void
public function add_color_option(string $name, ?string $label = null, bool $table_row = false): void
{
$val = html_escape($this->config->get_string($name));

View file

@ -66,7 +66,7 @@ class WikiPage
/**
* @param array<string, mixed> $row
*/
public function __construct(array $row = null)
public function __construct(?array $row = null)
{
//assert(!empty($row));
global $database;