Skip to content

Commit 0384b4a

Browse files
committed
Code analysis with Psalm.
1 parent 03a488b commit 0384b4a

19 files changed

Lines changed: 301 additions & 231 deletions

‎all_words_wellknown.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function all_words_wellknown_get_words($txid)
4747
* @param string $termlc Same as $term, but in lowercase.
4848
* @param int $langid Language ID
4949
*
50-
* @return array<int, string> Number of rows edited and a javascript query.
50+
* @return array{0: int, 1: string} Number of rows edited and a javascript query.
5151
*
5252
* @since 2.5.3-fork Do not crash when echoing an error
5353
* @since 2.5.3-fork Do not crash when a word is already registred to the database
@@ -107,8 +107,8 @@ function all_words_wellknown_process_word($status, $term, $termlc, $langid)
107107
* @param int $txid Text ID
108108
* @param int $status New status to apply to all words.
109109
*
110-
* @return array<int,string> Number of edited words,
111-
* and JavaScript query to change their display
110+
* @return array{0: int, 1: string} Number of edited words,
111+
* and JavaScript query to change their display
112112
*
113113
* @since 2.5.3-fork Use 'let' instead of 'var' in returned JS
114114
*/

‎check_text.php‎

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
echo '<p><input type="button" value="&lt;&lt; Back" onclick="history.back();" /></p>';
2424
if (strlen(prepare_textdata($_REQUEST['TxText'])) > 65000) {
2525
echo "<p>Error: Text too long, must be below 65000 Bytes.</p>";
26-
}
27-
else {
28-
echo splitCheckText($_REQUEST['TxText'], $_REQUEST['TxLgID'], -1);
26+
} else {
27+
echo splitCheckText(
28+
(string)$_REQUEST['TxText'], (int)$_REQUEST['TxLgID'], -1
29+
);
2930
}
3031
echo '<p><input type="button" value="&lt;&lt; Back" onclick="history.back();" /></p>';
3132

@@ -34,26 +35,29 @@
3435
?>
3536
<form class="validate" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
3637
<table class="tab3" cellspacing="0" cellpadding="5">
37-
<tr>
38-
<td class="td1 right">Language:</td>
39-
<td class="td1">
40-
<select name="TxLgID" class="notempty setfocus">
41-
<?php
42-
echo get_languages_selectoptions(getSetting('currentlanguage'), '[Choose...]');
43-
?>
44-
</select> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" />
45-
</td>
46-
</tr>
47-
<tr>
48-
<td class="td1 right">Text:<br /><br />(max.<br />65,000<br />bytes)</td>
49-
<td class="td1">
50-
<textarea name="TxText" class="notempty checkbytes checkoutsidebmp" data_maxlength="65000" data_info="Text" cols="60" rows="20"></textarea> <img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" />
51-
</td>
52-
</tr>
53-
<tr>
54-
<td class="td1 right" colspan="2">
55-
<input type="button" value="&lt;&lt; Back" onclick="location.href='index.php';" />
56-
<input type="submit" name="op" value="Check" /></td>
38+
<tr>
39+
<td class="td1 right">Language:</td>
40+
<td class="td1">
41+
<select name="TxLgID" class="notempty setfocus">
42+
<?php
43+
echo get_languages_selectoptions(getSetting('currentlanguage'), '[Choose...]');
44+
?>
45+
</select>
46+
<img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" />
47+
</td>
48+
</tr>
49+
<tr>
50+
<td class="td1 right">Text:<br /><br />(max.<br />65,000<br />bytes)</td>
51+
<td class="td1">
52+
<textarea name="TxText" class="notempty checkbytes checkoutsidebmp" data_maxlength="65000" data_info="Text" cols="60" rows="20"></textarea>
53+
<img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" />
54+
</td>
55+
</tr>
56+
<tr>
57+
<td class="td1 right" colspan="2">
58+
<input type="button" value="&lt;&lt; Back" onclick="location.href='index.php';" />
59+
<input type="submit" name="op" value="Check" />
60+
</td>
5761
</tr>
5862
</table>
5963
</form>

‎delete_word.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* @param string $wid ID of the word
1919
*
20-
* @return string|null A word
20+
* @return string A word
2121
*
2222
* @global string $tbpref
2323
*/
@@ -29,7 +29,7 @@ function get_term($wid)
2929
FROM " . $tbpref . "words
3030
WHERE WoID = " . $wid
3131
);
32-
return $term;
32+
return (string)$term;
3333
}
3434

3535
/**

‎display_impr_text_text.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ function get_annotated_text($textid)
3030
FROM " . $tbpref . "texts
3131
WHERE TxID = " . $textid
3232
);
33-
34-
return $ann;
33+
return (string)$ann;
3534
}
3635

3736
/**

0 commit comments

Comments
 (0)