Skip to content

Commit

Permalink
Use nullable types, in preparation for '= null' deprecation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Mar 4, 2024
1 parent a2d83f1 commit 488a6e5
Show file tree
Hide file tree
Showing 34 changed files with 93 additions and 99 deletions.
8 changes: 1 addition & 7 deletions lib/filer.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static private function prepare_docstore($parent, $path) {
}

/** @return ?non-empty-string */
static function docstore_tempdir(Conf $conf = null) {
static function docstore_tempdir(?Conf $conf = null) {
$conf = $conf ?? Conf::$main;
if ($conf && ($prefix = self::docstore_fixed_prefix($conf->docstore()))) {
$tmpdir = "{$prefix}tmp/";
Expand All @@ -160,12 +160,6 @@ static function docstore_tempdir(Conf $conf = null) {
return null;
}

/** @return ?non-empty-string
* @deprecated */
static function docstore_tmpdir(Conf $conf = null) {
return self::docstore_tempdir($conf);
}

/** @param string $pattern
* @param bool $extension
* @return ?string */
Expand Down
2 changes: 1 addition & 1 deletion lib/qrequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ function active_list() {
return $this->_active_list;
}

function set_active_list(SessionList $list = null) {
function set_active_list(?SessionList $list) {
assert($this->_active_list === false);
$this->_active_list = $list;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/tagger.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ function check_emoji_code($ltag) {
/** @param string $tag
* @param string $ltag
* @return ?TagInfo */
private function update_patterns($tag, $ltag, TagInfo $ti = null) {
private function update_patterns($tag, $ltag, ?TagInfo $ti) {
if (!$this->pattern_re) {
$a = [];
foreach ($this->pattern_storage as $p) {
Expand Down Expand Up @@ -1069,7 +1069,7 @@ static function assert_tag_string($tags, $strict = false) {
/** @param 0|1 $ctype
* @param ?string $tags
* @return string */
function censor($ctype, $tags, Contact $user, PaperInfo $prow = null) {
function censor($ctype, $tags, Contact $user, ?PaperInfo $prow = null) {
// empty tag optimization
if ($tags === null || $tags === "") {
return "";
Expand Down
4 changes: 2 additions & 2 deletions src/api/api_alltags.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static function run(Contact $user) {

/** @param string $tag
* @return ?string */
static private function strip($tag, Contact $user, PaperInfo $prow = null) {
static private function strip($tag, Contact $user, ?PaperInfo $prow) {
$twiddle = strpos($tag, "~");
if ($twiddle === false
|| ($twiddle === 0
Expand Down Expand Up @@ -55,7 +55,7 @@ static private function easy_alltags_api(Contact $user) {
$tags = [];
$result = $user->conf->qe($q . " where " . join(" and ", $qwhere));
while ($result && ($row = $result->fetch_row())) {
if (($tag = self::strip($row[0], $user))
if (($tag = self::strip($row[0], $user, null))
&& (!$hidden || !$dt->is_hidden($tag))) {
$tags[] = $tag;
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/api_assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright (c) 2008-2022 Eddie Kohler; see LICENSE.

class Assign_API {
static function assign(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
static function assign(Contact $user, Qrequest $qreq, ?PaperInfo $prow) {
if (!isset($qreq->assignments)) {
return JsonResult::make_missing_error("assignments");
}
Expand Down
4 changes: 2 additions & 2 deletions src/api/api_mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright (c) 2008-2023 Eddie Kohler; see LICENSE.

class Mail_API {
static function mailtext(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
static function mailtext(Contact $user, Qrequest $qreq, ?PaperInfo $prow) {
if (!$user->isPC
|| ($prow && !$user->can_view_paper($prow))) {
return JsonResult::make_permission_error();
Expand Down Expand Up @@ -95,7 +95,7 @@ static function can_view_maillog($user, $logrow) {
return $user->privChair || $user->contactId === (int) $logrow->contactId;
}

static function maillog(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
static function maillog(Contact $user, Qrequest $qreq, ?PaperInfo $prow) {
if (!$qreq->mailid || !ctype_digit($qreq->mailid)) {
return JsonResult::make_missing_error("mailid");
} else if (!$user->privChair) {
Expand Down
6 changes: 3 additions & 3 deletions src/api/api_paper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function __construct(Contact $user) {
$this->user = $user;
}

static function run_get(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
static function run_get(Contact $user, Qrequest $qreq, ?PaperInfo $prow) {
$ml = [];
if ($prow) {
$pids = [$prow->paperId];
Expand Down Expand Up @@ -102,7 +102,7 @@ static function analyze_zip_contents($zip) {
}
}

private function run_post(Qrequest $qreq, PaperInfo $prow = null) {
private function run_post(Qrequest $qreq, ?PaperInfo $prow) {
$ct = $qreq->body_content_type();
if ($ct === "application/json") {
$jsonstr = $qreq->body();
Expand Down Expand Up @@ -279,7 +279,7 @@ private function run_one_post($index, $j) {
return $p;
}

static function run(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
static function run(Contact $user, Qrequest $qreq, ?PaperInfo $prow) {
if ($qreq->is_get()) {
return self::run_get($user, $qreq, $prow);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/api/api_preference.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright (c) 2006-2023 Eddie Kohler; see LICENSE.

class Preference_API {
static function pref_api(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
static function pref_api(Contact $user, Qrequest $qreq, ?PaperInfo $prow) {
$overrides = $user->add_overrides(Contact::OVERRIDE_CONFLICT);
$u = APIHelpers::parse_reviewer_for($qreq->u ?? $qreq->reviewer, $user, $prow);
$user->set_overrides($overrides);
Expand Down
4 changes: 2 additions & 2 deletions src/api/api_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static function apply_search(JsonResult $jr, Contact $user, Qrequest $qreq, $sea
}
}

static function fieldhtml(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
static function fieldhtml(Contact $user, Qrequest $qreq, ?PaperInfo $prow) {
if ($qreq->f === null) {
return JsonResult::make_missing_error("f");
}
Expand Down Expand Up @@ -85,7 +85,7 @@ static function fieldhtml(Contact $user, Qrequest $qreq, PaperInfo $prow = null)
return $j;
}

static function fieldtext(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
static function fieldtext(Contact $user, Qrequest $qreq, ?PaperInfo $prow) {
if ($qreq->f === null) {
return JsonResult::make_missing_error("f");
}
Expand Down
6 changes: 3 additions & 3 deletions src/api/api_upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static function qreqint($x) {
}

/** @return array<string,mixed> */
function exec_start(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
function exec_start(Contact $user, Qrequest $qreq, ?PaperInfo $prow) {
$size = self::qreqint($qreq->size);
if ($size === null) {
return self::_make_simple_error(400, "<0>Missing `size` parameter");
Expand Down Expand Up @@ -619,7 +619,7 @@ private function _make_error($error_ftext) {
}

/** @return array<string,mixed> */
function exec(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
function exec(Contact $user, Qrequest $qreq, ?PaperInfo $prow) {
$this->_cap = $this->_capd = null;
if (!$this->tmpdir) {
return self::_make_simple_error(501, "<0>Upload API not available on this site");
Expand Down Expand Up @@ -710,7 +710,7 @@ function exec(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
}
}

static function run(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
static function run(Contact $user, Qrequest $qreq, ?PaperInfo $prow) {
return (new Upload_API($user->conf))->exec($user, $qreq, $prow);
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/api_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static function whoami(Contact $user, Qrequest $qreq) {
}

/** @return JsonResult */
static function user(Contact $user, Qrequest $qreq, PaperInfo $prow = null) {
static function user(Contact $user, Qrequest $qreq, ?PaperInfo $prow) {
if (!$user->can_lookup_user()) {
return JsonResult::make_permission_error();
}
Expand Down
4 changes: 2 additions & 2 deletions src/assignmentset.php
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ private function expand_special_user($user, AssignmentParser $aparser, PaperInfo

/** @param CsvRow $req
* @return void */
private function apply_req(AssignmentParser $aparser = null, $req) {
private function apply_req(?AssignmentParser $aparser, $req) {
// check action
if (!$aparser) {
if ($req["action"]) {
Expand Down Expand Up @@ -2086,7 +2086,7 @@ class Assignment_PaperColumn extends PaperColumn {
public $content = [];
/** @var ?AssignmentCountSet */
public $change_counts;
function __construct(Contact $user, Contact $reviewer = null) {
function __construct(Contact $user, ?Contact $reviewer = null) {
parent::__construct($user->conf, (object) ["name" => "autoassignment", "prefer_row" => true, "className" => "pl_autoassignment"]);
$this->conf = $user->conf;
$this->user = $user;
Expand Down
4 changes: 2 additions & 2 deletions src/commentinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class CommentInfo {
];


function __construct(PaperInfo $prow = null, Conf $conf = null) {
function __construct(?PaperInfo $prow = null, ?Conf $conf = null) {
assert(($prow || $conf) && (!$prow || !$conf || $prow->conf === $conf));
if ($prow) {
$this->conf = $prow->conf;
Expand Down Expand Up @@ -128,7 +128,7 @@ private function fetch_incorporate() {

/** @param Dbl_Result $result
* @return ?CommentInfo */
static function fetch($result, PaperInfo $prow = null, Conf $conf = null) {
static function fetch($result, ?PaperInfo $prow, ?Conf $conf) {
$cinfo = $result->fetch_object("CommentInfo", [$prow, $conf]);
if ($cinfo) {
$cinfo->fetch_incorporate();
Expand Down
22 changes: 11 additions & 11 deletions src/conference.php
Original file line number Diff line number Diff line change
Expand Up @@ -3906,7 +3906,7 @@ function document_metadata_query_fields() {

/** @param array{paperId?:list<int>|PaperID_SearchTerm,where?:string} $options
* @return \mysqli_result|Dbl_Result */
function paper_result($options, Contact $user = null) {
function paper_result($options, ?Contact $user = null) {
// Options:
// "paperId" => $pids Only papers in list<int> $pids
// "finalized" Only submitted papers
Expand Down Expand Up @@ -4173,14 +4173,14 @@ function paper_result($options, Contact $user = null) {

/** @param array{paperId?:list<int>|PaperID_SearchTerm} $options
* @return PaperInfoSet|Iterable<PaperInfo> */
function paper_set($options, Contact $user = null) {
function paper_set($options, ?Contact $user = null) {
$result = $this->paper_result($options, $user);
return PaperInfoSet::make_result($result, $user, $this);
}

/** @param int $pid
* @return ?PaperInfo */
function paper_by_id($pid, Contact $user = null, $options = []) {
function paper_by_id($pid, ?Contact $user = null, $options = []) {
$options["paperId"] = [$pid];
$result = $this->paper_result($options, $user);
$prow = PaperInfo::fetch($result, $user, $this);
Expand All @@ -4190,7 +4190,7 @@ function paper_by_id($pid, Contact $user = null, $options = []) {

/** @param int $pid
* @return PaperInfo */
function checked_paper_by_id($pid, Contact $user = null, $options = []) {
function checked_paper_by_id($pid, ?Contact $user = null, $options = []) {
$prow = $this->paper_by_id($pid, $user, $options);
if (!$prow) {
throw new Exception("Conf::checked_paper_by_id({$pid}) failed");
Expand Down Expand Up @@ -4220,7 +4220,7 @@ function set_paper_request(Qrequest $qreq, Contact $user) {

/** @param string $text
* @param int $type */
static function msg_on(Conf $conf = null, $text, $type) {
static function msg_on(?Conf $conf, $text, $type) {
assert(is_int($type) && is_string($text ?? ""));
if (($text ?? "") === "") {
// do nothing
Expand Down Expand Up @@ -5273,7 +5273,7 @@ private function make_search_keyword_map() {
$this->_xtbuild(["etc/searchkeywords.json"], "searchKeywords");
}
/** @return ?object */
function search_keyword($keyword, Contact $user = null) {
function search_keyword($keyword, ?Contact $user = null) {
if ($this->_search_keyword_base === null) {
$this->make_search_keyword_map();
}
Expand All @@ -5288,7 +5288,7 @@ function search_keyword($keyword, Contact $user = null) {

/** @param string $keyword
* @return ?AssignmentParser */
function assignment_parser($keyword, Contact $user = null) {
function assignment_parser($keyword, ?Contact $user = null) {
require_once("assignmentset.php");
if ($this->_assignment_parsers === null) {
list($this->_assignment_parsers, $unused) =
Expand Down Expand Up @@ -5346,10 +5346,10 @@ function api_map() {
}
return $this->_api_map;
}
function has_api($fn, Contact $user = null, $method = null) {
function has_api($fn, ?Contact $user = null, $method = null) {
return !!$this->api($fn, $user, $method);
}
function api($fn, Contact $user = null, $method = null) {
function api($fn, ?Contact $user = null, $method = null) {
$xtp = (new XtParams($this, $user))->add_allow_checker_method($method);
$uf = $xtp->search_name($this->api_map(), $fn);
return self::xt_enabled($uf) ? $uf : null;
Expand Down Expand Up @@ -5431,7 +5431,7 @@ function paper_column_factories() {
return $this->_paper_column_factories;
}
/** @return ?object */
function basic_paper_column($name, Contact $user = null) {
function basic_paper_column($name, ?Contact $user = null) {
$xtp = new XtParams($this, $user);
$uf = $xtp->search_name($this->paper_column_map(), $name);
return self::xt_enabled($uf) ? $uf : null;
Expand Down Expand Up @@ -5701,7 +5701,7 @@ private function hook_map() {
}
return $this->_hook_map;
}
function call_hooks($name, Contact $user = null, ...$args) {
function call_hooks($name, ?Contact $user, ...$args) {
$hs = ($this->hook_map())[$name] ?? null;
foreach ($this->_hook_factories as $fj) {
if ($fj->match === ".*"
Expand Down
Loading

0 comments on commit 488a6e5

Please sign in to comment.