Skip to content

Commit a8c736a

Browse files
authored
Enhancement: Enable void_return fixer (#661)
* Enhancement: Enable void_return fixer * Fix: Run 'make coding-standards'
1 parent 48a8964 commit a8c736a

9 files changed

+39
-38
lines changed

.php-cs-fixer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
'switch_case_space' => true,
4444
'trim_array_spaces' => true,
4545
'visibility_required' => true,
46+
'void_return' => true,
4647
'whitespace_after_comma_in_array' => true,
4748
]);
4849

include/changelogs.inc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
<?php
2-
function bugfix($number) {
2+
function bugfix($number): void {
33
echo "Fixed bug "; bugl($number);
44
}
55

6-
function bugl($number) {
6+
function bugl($number): void {
77
echo "<a href=\"http://bugs.php.net/$number\">#$number</a>";
88
}
99

10-
function implemented($number) {
10+
function implemented($number): void {
1111
echo "Implemented FR "; bugl($number);
1212
}
1313

14-
function peclbugfix($number) {
14+
function peclbugfix($number): void {
1515
echo "Fixed PECL bug "; bugl($number);
1616
}
1717

18-
function peclbugl($number) {
18+
function peclbugl($number): void {
1919
echo "<a href=\"http://pecl.php.net/bugs/bug.php?id=$number\">#$number</a>";
2020
}
2121

22-
function githubissue($repo, $number) {
22+
function githubissue($repo, $number): void {
2323
echo "Fixed issue "; githubissuel($repo, $number);
2424
}
2525

26-
function githubissuel($repo, $number) {
26+
function githubissuel($repo, $number): void {
2727
echo "<a href=\"https://github.com/$repo/issues/$number\">GH-$number</a>";
2828
}
2929

30-
function release_date($in) {
30+
function release_date($in): void {
3131
$time = strtotime($in);
3232
$human_readable = date('d M Y', $time);
3333
$for_tools = date('Y-m-d', $time);

include/do-download.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function get_actual_download_file($file)
2323
return $found;
2424
}
2525
// Download a file from a mirror site
26-
function download_file($mirror, $file)
26+
function download_file($mirror, $file): void
2727
{
2828
// Redirect to the particular file
2929
if (!headers_sent()) {

include/errors.inc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
// A 'good looking' 404 error message page
9-
function error_404()
9+
function error_404(): void
1010
{
1111
global $MYSITE;
1212
status_header(404);
@@ -19,7 +19,7 @@ function error_404()
1919
}
2020

2121
// A 'good looking' 404 error message page for manual pages
22-
function error_404_manual()
22+
function error_404_manual(): void
2323
{
2424
global $MYSITE;
2525
status_header(404);
@@ -35,7 +35,7 @@ function error_404_manual()
3535
}
3636

3737
// An error message page for manual pages from inactive languages
38-
function error_inactive_manual_page($lang_name, $en_page)
38+
function error_inactive_manual_page($lang_name, $en_page): void
3939
{
4040
global $MYSITE, $ACTIVE_ONLINE_LANGUAGES;
4141
status_header(404);
@@ -61,7 +61,7 @@ function error_inactive_manual_page($lang_name, $en_page)
6161
}
6262

6363
// This service is not working right now
64-
function error_noservice()
64+
function error_noservice(): void
6565
{
6666
global $MYSITE;
6767
site_header('Service not working', ["noindex"]);
@@ -76,7 +76,7 @@ function error_noservice()
7676
}
7777

7878
// There is no such mirror
79-
function error_nomirror($mirror) {
79+
function error_nomirror($mirror): void {
8080
site_header("No such mirror", ["noindex"]);
8181
echo "<h1>No such mirror</h1>\n<p>The mirror you tried to access (" .
8282
htmlspecialchars($mirror) .

include/layout.inc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ function highlight_php_trimmed($code, $return = false)
4848
}
4949

5050
// Stats pages still need this
51-
function commonHeader($title) { site_header($title); }
51+
function commonHeader($title): void { site_header($title); }
5252

5353
// Stats pages still need this
54-
function commonFooter() { site_footer(); }
54+
function commonFooter(): void { site_footer(); }
5555

5656
// Resize the image using the output of make_image()
5757
function resize_image($img, $width = 1, $height = 1)
@@ -105,7 +105,7 @@ function make_image($file, $alt = false, $align = false, $extras = false,
105105

106106
// Print an <img> tag out for a given file
107107
function print_image($file, $alt = false, $align = false, $extras = false,
108-
$dir = '/images')
108+
$dir = '/images'): void
109109
{
110110
echo make_image($file, $alt, $align, $extras, $dir);
111111
}
@@ -163,12 +163,12 @@ function make_popup_link ($url, $linktext = false, $target = false, $windowprops
163163
// print_popup_link()
164164
// print a hyperlink to something, within the site, that pops up a new window
165165
//
166-
function print_popup_link($url, $linktext = false, $windowprops = "", $target = false, $extras = false) {
166+
function print_popup_link($url, $linktext = false, $windowprops = "", $target = false, $extras = false): void {
167167
echo make_popup_link($url, $linktext, $windowprops, $target, $extras);
168168
}
169169

170170
// Print a link for a downloadable file (including filesize)
171-
function download_link($file, $title)
171+
function download_link($file, $title): void
172172
{
173173
$download_link = "/distributions/" . $file;
174174

@@ -236,7 +236,7 @@ function clean_note($text)
236236
);
237237
}
238238

239-
function display_errors($errors)
239+
function display_errors($errors): void
240240
{
241241
echo '<div class="errors">';
242242
if (count($errors) > 1) {
@@ -254,7 +254,7 @@ function display_errors($errors)
254254

255255
// Displays an event. Used in event submission
256256
// previews and event information displays
257-
function display_event($event, $include_date = 1)
257+
function display_event($event, $include_date = 1): void
258258
{
259259
global $COUNTRIES;
260260
// Current month (int)($_GET['cm'] ?: 0)
@@ -354,7 +354,7 @@ function display_event($event, $include_date = 1)
354354
}
355355

356356
// Print news links for archives
357-
function news_archive_sidebar()
357+
function news_archive_sidebar(): void
358358
{
359359
global $SIDEBAR_DATA;
360360
$SIDEBAR_DATA = '
@@ -447,7 +447,7 @@ EOT;
447447
return $retval;
448448
}
449449

450-
function site_header($title = 'Hypertext Preprocessor', $config = [])
450+
function site_header($title = 'Hypertext Preprocessor', $config = []): void
451451
{
452452
global $MYSITE;
453453

@@ -481,7 +481,7 @@ function site_header($title = 'Hypertext Preprocessor', $config = [])
481481

482482
require __DIR__ . "/header.inc";
483483
}
484-
function site_footer($config = [])
484+
function site_footer($config = []): void
485485
{
486486
require __DIR__ . "/footer.inc";
487487
}
@@ -511,7 +511,7 @@ function get_news_changes()
511511
return false;
512512
}
513513

514-
function news_toc($sections = null) {
514+
function news_toc($sections = null): void {
515515
include __DIR__ . "/pregen-news.inc";
516516
$items = [
517517
"news" => [
@@ -544,7 +544,7 @@ function news_toc($sections = null) {
544544
}
545545
}
546546
}
547-
function doc_toc($lang) {
547+
function doc_toc($lang): void {
548548
$file = __DIR__ . "/../manual/$lang/toc/index.inc";
549549
if (!file_exists($file)) {
550550
$lang = "en"; // Fallback on english if the translation doesn't exist
@@ -591,15 +591,15 @@ function doc_toc($lang) {
591591
echo "</dl>";
592592

593593
}
594-
function doc_toc_list($lang, $index, $file) {
594+
function doc_toc_list($lang, $index, $file): void {
595595
include __DIR__ . "/../manual/$lang/toc/$file.inc";
596596

597597
doc_toc_title($lang, $index, $file);
598598
foreach ($TOC as $entry) {
599599
echo "\t<dd><a href='/manual/$lang/{$entry[0]}'>{$entry[1]}</a></dd>\n";
600600
}
601601
}
602-
function doc_toc_title($lang, $index, $file, $elm = "dt") {
602+
function doc_toc_title($lang, $index, $file, $elm = "dt"): void {
603603
foreach ($index as $entry) {
604604
if ($entry[0] == "$file.php") {
605605
$link = $entry[0];

include/prepend.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ header("Content-type: text/html; charset=utf-8");
1515
header("Permissions-Policy: interest-cohort=()");
1616

1717
/* Fix Silly Same Origin Policies */
18-
(function () {
18+
(function (): void {
1919
if (!isset($_SERVER["HTTP_ORIGIN"])) {
2020
return;
2121
}
@@ -94,7 +94,7 @@ include __DIR__ . '/last_updated.inc';
9494
// -----------------------------------------------------------------------------
9595

9696
// Load in the user preferences
97-
function myphpnet_load()
97+
function myphpnet_load(): void
9898
{
9999
global $MYPHPNET, $MYSITE;
100100

@@ -169,7 +169,7 @@ function myphpnet_showug($enable = null) {
169169
}
170170

171171
// Save user settings in cookie
172-
function myphpnet_save()
172+
function myphpnet_save(): void
173173
{
174174
global $MYPHPNET;
175175

@@ -183,7 +183,7 @@ function myphpnet_save()
183183

184184
}
185185

186-
function google_cse() {
186+
function google_cse(): void {
187187
?>
188188
<noscript>
189189
php.net's search functionality requires JavaScript to operate. Please enable

include/results.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
function search_results($res, $q, $profile = 'all', $per_page = 10, $s = 0, $l = 'en', $show_title = true, $show_foot = true, $show_attrib = true) {
2+
function search_results($res, $q, $profile = 'all', $per_page = 10, $s = 0, $l = 'en', $show_title = true, $show_foot = true, $show_attrib = true): void {
33
$start_result = $s;
44
$end_result = $s + $res['ResultSet']['totalResultsReturned'] - 1;
55

include/shared-manual.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function manual_notes_load(string $id): array
112112
}
113113

114114
// Print out one user note entry
115-
function manual_note_display(UserNote $note, $voteOption = true)
115+
function manual_note_display(UserNote $note, $voteOption = true): void
116116
{
117117
if ($note->user) {
118118
$name = "\n <strong class=\"user\"><em>" . htmlspecialchars($note->user) . "</em></strong>";
@@ -264,7 +264,7 @@ function manual_navigation_methodname($methodname) {
264264

265265
// Set up variables important for this page
266266
// including HTTP header information
267-
function manual_setup($setup) {
267+
function manual_setup($setup): void {
268268
global $PGI, $MYSITE, $USERNOTES;
269269
global $ACTIVE_ONLINE_LANGUAGES;
270270

@@ -381,7 +381,7 @@ CHANGE_LANG;
381381
return trim($r);
382382
}
383383

384-
function manual_footer() {
384+
function manual_footer(): void {
385385
global $USERNOTES, $__RELATED;
386386

387387
manual_notes($USERNOTES);

include/site.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function mirror_type($site = false)
123123
}
124124

125125
// Redirect to an URI on this mirror site or outside this site
126-
function mirror_redirect($absoluteURI)
126+
function mirror_redirect($absoluteURI): void
127127
{
128128
global $MYSITE;
129129

@@ -160,7 +160,7 @@ function mirror_setcookie($name, $content, $exptime)
160160

161161
// Use this function to write out proper headers on
162162
// pages where the content should not be publicly cached
163-
function header_nocache()
163+
function header_nocache(): void
164164
{
165165
// Only try to send out headers in case
166166
// those were not sent already

0 commit comments

Comments
 (0)