diff --git a/core/basepage.php b/core/basepage.php index 68b4536c..6f7e4195 100644 --- a/core/basepage.php +++ b/core/basepage.php @@ -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.) diff --git a/core/block.php b/core/block.php index 23fc3b58..9972cb2e 100644 --- a/core/block.php +++ b/core/block.php @@ -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; diff --git a/core/cli_app.php b/core/cli_app.php index b6c2c5cd..a3dbdd75 100644 --- a/core/cli_app.php +++ b/core/cli_app.php @@ -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; diff --git a/core/config.php b/core/config.php index 4295f28f..2f80a7f9 100644 --- a/core/config.php +++ b/core/config.php @@ -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; diff --git a/core/imageboard/misc.php b/core/imageboard/misc.php index c4514a6c..1d1d1adb 100644 --- a/core/imageboard/misc.php +++ b/core/imageboard/misc.php @@ -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( diff --git a/core/testcase.php b/core/testcase.php index 5e081484..6a611ce8 100644 --- a/core/testcase.php +++ b/core/testcase.php @@ -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)); } diff --git a/core/tests/SearchTest.php b/core/tests/SearchTest.php index 9a346d61..5abafe1a 100644 --- a/core/tests/SearchTest.php +++ b/core/tests/SearchTest.php @@ -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; diff --git a/core/userclass.php b/core/userclass.php index 1f363100..2f64fe8d 100644 --- a/core/userclass.php +++ b/core/userclass.php @@ -26,7 +26,7 @@ class UserClass /** * @param array $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; diff --git a/ext/bulk_actions/main.php b/ext/bulk_actions/main.php index 7d298664..d9968c20 100644 --- a/ext/bulk_actions/main.php +++ b/ext/bulk_actions/main.php @@ -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); diff --git a/ext/forum/theme.php b/ext/forum/theme.php index c530cfec..08a746d9 100644 --- a/ext/forum/theme.php +++ b/ext/forum/theme.php @@ -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'); diff --git a/ext/index/events.php b/ext/index/events.php index 02e9ec83..121239fb 100644 --- a/ext/index/events.php +++ b/ext/index/events.php @@ -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(); diff --git a/ext/media/events.php b/ext/media/events.php index a7bce3f4..abf13a10 100644 --- a/ext/media/events.php +++ b/ext/media/events.php @@ -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, diff --git a/ext/media/main.php b/ext/media/main.php index 0660c952..5c511446 100644 --- a/ext/media/main.php +++ b/ext/media/main.php @@ -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, diff --git a/ext/ouroboros_api/main.php b/ext/ouroboros_api/main.php index 8fbb1659..98c7fab4 100644 --- a/ext/ouroboros_api/main.php +++ b/ext/ouroboros_api/main.php @@ -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)); diff --git a/ext/pools/main.php b/ext/pools/main.php index 8d889449..4d5291e3 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -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 = "" ) { diff --git a/ext/post_source/theme.php b/ext/post_source/theme.php index a31994b6..626d3b13 100644 --- a/ext/post_source/theme.php +++ b/ext/post_source/theme.php @@ -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, "://")) { diff --git a/ext/rating/main.php b/ext/rating/main.php index 0d4f6a40..2afc9263 100644 --- a/ext/rating/main.php +++ b/ext/rating/main.php @@ -440,7 +440,7 @@ class Ratings extends Extension * @param ImageRating[]|null $ratings * @return array */ - 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(); diff --git a/ext/setup/main.php b/ext/setup/main.php index 19dd2fd1..3579a5e4 100644 --- a/ext/setup/main.php +++ b/ext/setup/main.php @@ -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 .= ""; // } - 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 = "\n"; @@ -249,7 +249,7 @@ class SetupBlock extends Block /** * @param array $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 $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)); diff --git a/ext/wiki/main.php b/ext/wiki/main.php index 07a3e73d..ea67fcab 100644 --- a/ext/wiki/main.php +++ b/ext/wiki/main.php @@ -66,7 +66,7 @@ class WikiPage /** * @param array $row */ - public function __construct(array $row = null) + public function __construct(?array $row = null) { //assert(!empty($row)); global $database;