Skip to content

Commit

Permalink
no implicit nulls (they are deprecated in php8.4)
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Aug 31, 2024
1 parent df72df8 commit 7353683
Show file tree
Hide file tree
Showing 19 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion core/basepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ public function __construct(string $name, Link $link, string|HTMLElement $descri
/**
* @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.)
Expand Down
2 changes: 1 addition & 1 deletion core/block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core/cli_app.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function getDefaultInputDefinition(): InputDefinition
return $definition;
}

public function run(InputInterface $input = null, OutputInterface $output = null): int
public function run(?InputInterface $input = null, ?OutputInterface $output = null): int
{
global $user;

Expand Down
4 changes: 2 additions & 2 deletions core/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion core/imageboard/misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions core/testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ protected function assert_response(int $code): void
$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) {
Expand All @@ -184,12 +184,12 @@ protected function page_to_text(string $section = null): string
/**
* 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));
}
Expand Down
2 changes: 1 addition & 1 deletion core/tests/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private function assert_BSQ(
int $limit = 9999,
int $start = 0,
array $res = [],
array $path = null,
?array $path = null,
): void {
global $database;

Expand Down
2 changes: 1 addition & 1 deletion core/userclass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ext/bulk_actions/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ext/forum/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function display_thread_list(Page $page, array $threads, bool $showAdminO



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');
Expand Down
2 changes: 1 addition & 1 deletion ext/index/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion ext/media/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
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,
Expand Down
2 changes: 1 addition & 1 deletion ext/media/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ public static function image_resize_convert(
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,
Expand Down
2 changes: 1 addition & 1 deletion ext/ouroboros_api/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ protected function postCreate(OuroborosPost $post, ?string $md5 = ''): void
/**
* 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));
Expand Down
2 changes: 1 addition & 1 deletion ext/pools/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
) {
Expand Down
2 changes: 1 addition & 1 deletion ext/post_source/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function get_source_editor_html(Image $image): HTMLElement
);
}

protected function format_source(string $source = null): HTMLElement
protected function format_source(?string $source = null): HTMLElement
{
if (!empty($source)) {
if (!str_contains($source, "://")) {
Expand Down
2 changes: 1 addition & 1 deletion ext/rating/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public static function get_sorted_ratings(): array
* @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();
Expand Down
18 changes: 9 additions & 9 deletions ext/setup/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private function format_option(
}
}

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));

Expand All @@ -191,7 +191,7 @@ public function add_text_option(string $name, string $label = null, bool $table_
$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));

Expand All @@ -202,7 +202,7 @@ public function add_longtext_option(string $name, string $label = null, bool $ta
$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" : "";

Expand All @@ -221,13 +221,13 @@ public function add_bool_option(string $name, string $label = null, bool $table_
$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);

Expand All @@ -237,7 +237,7 @@ public function add_int_option(string $name, string $label = null, bool $table_r
$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";
Expand All @@ -249,7 +249,7 @@ public function add_shorthand_int_option(string $name, string $label = null, boo
/**
* @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);
Expand All @@ -275,7 +275,7 @@ public function add_choice_option(string $name, array $options, string $label =
/**
* @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, []);

Expand All @@ -294,7 +294,7 @@ public function add_multichoice_option(string $name, array $options, string $lab
$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));

Expand Down
2 changes: 1 addition & 1 deletion ext/wiki/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7353683

Please sign in to comment.