Skip to content

Commit

Permalink
Typechecking annotations: whyNot, SettingValues.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed May 6, 2020
1 parent 194fed3 commit cc212a8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function base64url_encode($text) {
return rtrim(strtr(base64_encode($text), '+/', '-_'), '=');
}

function base64url_decode($data) {
function base64url_decode($text) {
return base64_decode(strtr($text, '-_', '+/'));
}

Expand Down
7 changes: 4 additions & 3 deletions src/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -2825,15 +2825,16 @@ function perm_view_option(PaperInfo $prow, $opt) {
|| ($oview == "nonblind"
&& !$this->can_view_authors($prow)))) {
$whyNot["permission"] = "view_option";
$whyNot["optionPermission"] = $opt;
$whyNot["option"] = $opt;
} else if ($opt->final
&& ($prow->outcome <= 0
|| $prow->timeSubmitted <= 0
|| !$rights->can_view_decision)) {
$whyNot["optionNotAccepted"] = $opt;
$whyNot["optionNotAccepted"] = true;
$whyNot["option"] = $opt;
} else {
$whyNot["permission"] = "view_option";
$whyNot["optionPermission"] = $opt;
$whyNot["option"] = $opt;
}
return $whyNot;
}
Expand Down
5 changes: 3 additions & 2 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ function filter_whynot($whyNot, $keys) {
return $revWhyNot;
}

/** @param array{conf:Conf,paperId?:int,reviewId?:int,option?:PaperOption} $whyNot */
function whyNotText($whyNot, $text_only = false) {
global $Conf, $Now;
if (is_string($whyNot)) {
Expand Down Expand Up @@ -430,13 +431,13 @@ function whyNotText($whyNot, $text_only = false) {
}
if (isset($whyNot["permission"])) {
if ($whyNot["permission"] === "view_option") {
$ms[] = $conf->_c("eperm", "Permission error.", $whyNot["permission"], $paperId, $quote($whyNot["optionPermission"]->title()));
$ms[] = $conf->_c("eperm", "Permission error.", $whyNot["permission"], $paperId, $quote($whyNot["option"]->title()));
} else {
$ms[] = $conf->_c("eperm", "Permission error.", $whyNot["permission"], $paperId);
}
}
if (isset($whyNot["optionNotAccepted"])) {
$ms[] = $conf->_("The %2\$s field is reserved for accepted submissions.", $paperId, $quote($whyNot["optionNotAccepted"]->title()));
$ms[] = $conf->_("The %2\$s field is reserved for accepted submissions.", $paperId, $quote($whyNot["option"]->title()));
}
if (isset($whyNot["documentNotFound"])) {
$ms[] = $conf->_("No such document “%s”.", $quote($whyNot["documentNotFound"]));
Expand Down
2 changes: 2 additions & 0 deletions src/settingvalues.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ function sjs($name, $js = array()) {
return $x;
}

/** @return Si */
function si($name) {
$si = Si::get($this->conf, $name);
if (!$si) {
Expand Down Expand Up @@ -682,6 +683,7 @@ function reqv($name, $default_value = null) {
$xname = str_replace(".", "_", $name);
return $this->req[$xname] ?? $default_value;
}
/** @return list<Si> */
private function req_sis(Si $si) {
$xsis = [];
$xname = str_replace(".", "_", $si->name);
Expand Down

0 comments on commit cc212a8

Please sign in to comment.