Author: Andreas Möller (localheinz) Committer: GitHub (web-flow) Pusher: kamil-tekiela Date: 2023-12-05T14:06:29+01:00
Commit: https://github.com/php/web-php/commit/a8c736a079f8f439ec125b41596ef875871b9ece Raw diff: https://github.com/php/web-php/commit/a8c736a079f8f439ec125b41596ef875871b9ece.diff Enhancement: Enable `void_return` fixer (#661) * Enhancement: Enable void_return fixer * Fix: Run 'make coding-standards' Changed paths: M .php-cs-fixer.php M include/changelogs.inc M include/do-download.inc M include/errors.inc M include/layout.inc M include/prepend.inc M include/results.inc M include/shared-manual.inc M include/site.inc Diff: diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 40d0847678..c76d76095e 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -43,6 +43,7 @@ 'switch_case_space' => true, 'trim_array_spaces' => true, 'visibility_required' => true, + 'void_return' => true, 'whitespace_after_comma_in_array' => true, ]); diff --git a/include/changelogs.inc b/include/changelogs.inc index 22c346a0ae..a3317ab03d 100644 --- a/include/changelogs.inc +++ b/include/changelogs.inc @@ -1,33 +1,33 @@ <?php -function bugfix($number) { +function bugfix($number): void { echo "Fixed bug "; bugl($number); } -function bugl($number) { +function bugl($number): void { echo "<a href=\"http://bugs.php.net/$number\">#$number</a>"; } -function implemented($number) { +function implemented($number): void { echo "Implemented FR "; bugl($number); } -function peclbugfix($number) { +function peclbugfix($number): void { echo "Fixed PECL bug "; bugl($number); } -function peclbugl($number) { +function peclbugl($number): void { echo "<a href=\"http://pecl.php.net/bugs/bug.php?id=$number\">#$number</a>"; } -function githubissue($repo, $number) { +function githubissue($repo, $number): void { echo "Fixed issue "; githubissuel($repo, $number); } -function githubissuel($repo, $number) { +function githubissuel($repo, $number): void { echo "<a href=\"https://github.com/$repo/issues/$number\">GH-$number</a>"; } -function release_date($in) { +function release_date($in): void { $time = strtotime($in); $human_readable = date('d M Y', $time); $for_tools = date('Y-m-d', $time); diff --git a/include/do-download.inc b/include/do-download.inc index 9c767ce5ee..b31f763b2c 100644 --- a/include/do-download.inc +++ b/include/do-download.inc @@ -23,7 +23,7 @@ function get_actual_download_file($file) return $found; } // Download a file from a mirror site -function download_file($mirror, $file) +function download_file($mirror, $file): void { // Redirect to the particular file if (!headers_sent()) { diff --git a/include/errors.inc b/include/errors.inc index 93a1840bc4..ac5d2586d3 100644 --- a/include/errors.inc +++ b/include/errors.inc @@ -6,7 +6,7 @@ */ // A 'good looking' 404 error message page -function error_404() +function error_404(): void { global $MYSITE; status_header(404); @@ -19,7 +19,7 @@ function error_404() } // A 'good looking' 404 error message page for manual pages -function error_404_manual() +function error_404_manual(): void { global $MYSITE; status_header(404); @@ -35,7 +35,7 @@ function error_404_manual() } // An error message page for manual pages from inactive languages -function error_inactive_manual_page($lang_name, $en_page) +function error_inactive_manual_page($lang_name, $en_page): void { global $MYSITE, $ACTIVE_ONLINE_LANGUAGES; status_header(404); @@ -61,7 +61,7 @@ function error_inactive_manual_page($lang_name, $en_page) } // This service is not working right now -function error_noservice() +function error_noservice(): void { global $MYSITE; site_header('Service not working', ["noindex"]); @@ -76,7 +76,7 @@ function error_noservice() } // There is no such mirror -function error_nomirror($mirror) { +function error_nomirror($mirror): void { site_header("No such mirror", ["noindex"]); echo "<h1>No such mirror</h1>\n<p>The mirror you tried to access (" . htmlspecialchars($mirror) . diff --git a/include/layout.inc b/include/layout.inc index 7378d66ec1..563ed8bade 100644 --- a/include/layout.inc +++ b/include/layout.inc @@ -48,10 +48,10 @@ function highlight_php_trimmed($code, $return = false) } // Stats pages still need this -function commonHeader($title) { site_header($title); } +function commonHeader($title): void { site_header($title); } // Stats pages still need this -function commonFooter() { site_footer(); } +function commonFooter(): void { site_footer(); } // Resize the image using the output of make_image() function resize_image($img, $width = 1, $height = 1) @@ -105,7 +105,7 @@ function make_image($file, $alt = false, $align = false, $extras = false, // Print an <img> tag out for a given file function print_image($file, $alt = false, $align = false, $extras = false, - $dir = '/images') + $dir = '/images'): void { echo make_image($file, $alt, $align, $extras, $dir); } @@ -163,12 +163,12 @@ function make_popup_link ($url, $linktext = false, $target = false, $windowprops // print_popup_link() // print a hyperlink to something, within the site, that pops up a new window // -function print_popup_link($url, $linktext = false, $windowprops = "", $target = false, $extras = false) { +function print_popup_link($url, $linktext = false, $windowprops = "", $target = false, $extras = false): void { echo make_popup_link($url, $linktext, $windowprops, $target, $extras); } // Print a link for a downloadable file (including filesize) -function download_link($file, $title) +function download_link($file, $title): void { $download_link = "/distributions/" . $file; @@ -236,7 +236,7 @@ function clean_note($text) ); } -function display_errors($errors) +function display_errors($errors): void { echo '<div class="errors">'; if (count($errors) > 1) { @@ -254,7 +254,7 @@ function display_errors($errors) // Displays an event. Used in event submission // previews and event information displays -function display_event($event, $include_date = 1) +function display_event($event, $include_date = 1): void { global $COUNTRIES; // Current month (int)($_GET['cm'] ?: 0) @@ -354,7 +354,7 @@ function display_event($event, $include_date = 1) } // Print news links for archives -function news_archive_sidebar() +function news_archive_sidebar(): void { global $SIDEBAR_DATA; $SIDEBAR_DATA = ' @@ -447,7 +447,7 @@ EOT; return $retval; } -function site_header($title = 'Hypertext Preprocessor', $config = []) +function site_header($title = 'Hypertext Preprocessor', $config = []): void { global $MYSITE; @@ -481,7 +481,7 @@ function site_header($title = 'Hypertext Preprocessor', $config = []) require __DIR__ . "/header.inc"; } -function site_footer($config = []) +function site_footer($config = []): void { require __DIR__ . "/footer.inc"; } @@ -511,7 +511,7 @@ function get_news_changes() return false; } -function news_toc($sections = null) { +function news_toc($sections = null): void { include __DIR__ . "/pregen-news.inc"; $items = [ "news" => [ @@ -544,7 +544,7 @@ function news_toc($sections = null) { } } } -function doc_toc($lang) { +function doc_toc($lang): void { $file = __DIR__ . "/../manual/$lang/toc/index.inc"; if (!file_exists($file)) { $lang = "en"; // Fallback on english if the translation doesn't exist @@ -591,7 +591,7 @@ function doc_toc($lang) { echo "</dl>"; } -function doc_toc_list($lang, $index, $file) { +function doc_toc_list($lang, $index, $file): void { include __DIR__ . "/../manual/$lang/toc/$file.inc"; doc_toc_title($lang, $index, $file); @@ -599,7 +599,7 @@ function doc_toc_list($lang, $index, $file) { echo "\t<dd><a href='/manual/$lang/{$entry[0]}'>{$entry[1]}</a></dd>\n"; } } -function doc_toc_title($lang, $index, $file, $elm = "dt") { +function doc_toc_title($lang, $index, $file, $elm = "dt"): void { foreach ($index as $entry) { if ($entry[0] == "$file.php") { $link = $entry[0]; diff --git a/include/prepend.inc b/include/prepend.inc index 13f901dff1..c6f03a4d5d 100644 --- a/include/prepend.inc +++ b/include/prepend.inc @@ -15,7 +15,7 @@ header("Content-type: text/html; charset=utf-8"); header("Permissions-Policy: interest-cohort=()"); /* Fix Silly Same Origin Policies */ -(function () { +(function (): void { if (!isset($_SERVER["HTTP_ORIGIN"])) { return; } @@ -94,7 +94,7 @@ include __DIR__ . '/last_updated.inc'; // ----------------------------------------------------------------------------- // Load in the user preferences -function myphpnet_load() +function myphpnet_load(): void { global $MYPHPNET, $MYSITE; @@ -169,7 +169,7 @@ function myphpnet_showug($enable = null) { } // Save user settings in cookie -function myphpnet_save() +function myphpnet_save(): void { global $MYPHPNET; @@ -183,7 +183,7 @@ function myphpnet_save() } -function google_cse() { +function google_cse(): void { ?> <noscript> php.net's search functionality requires JavaScript to operate. Please enable diff --git a/include/results.inc b/include/results.inc index 90c1864625..25f93bf64b 100644 --- a/include/results.inc +++ b/include/results.inc @@ -1,5 +1,5 @@ <?php -function search_results($res, $q, $profile = 'all', $per_page = 10, $s = 0, $l = 'en', $show_title = true, $show_foot = true, $show_attrib = true) { +function search_results($res, $q, $profile = 'all', $per_page = 10, $s = 0, $l = 'en', $show_title = true, $show_foot = true, $show_attrib = true): void { $start_result = $s; $end_result = $s + $res['ResultSet']['totalResultsReturned'] - 1; diff --git a/include/shared-manual.inc b/include/shared-manual.inc index f17379bb3f..b25a9bd39e 100644 --- a/include/shared-manual.inc +++ b/include/shared-manual.inc @@ -112,7 +112,7 @@ function manual_notes_load(string $id): array } // Print out one user note entry -function manual_note_display(UserNote $note, $voteOption = true) +function manual_note_display(UserNote $note, $voteOption = true): void { if ($note->user) { $name = "\n <strong class=\"user\"><em>" . htmlspecialchars($note->user) . "</em></strong>"; @@ -264,7 +264,7 @@ function manual_navigation_methodname($methodname) { // Set up variables important for this page // including HTTP header information -function manual_setup($setup) { +function manual_setup($setup): void { global $PGI, $MYSITE, $USERNOTES; global $ACTIVE_ONLINE_LANGUAGES; @@ -381,7 +381,7 @@ CHANGE_LANG; return trim($r); } -function manual_footer() { +function manual_footer(): void { global $USERNOTES, $__RELATED; manual_notes($USERNOTES); diff --git a/include/site.inc b/include/site.inc index 65183ed1de..d0426b9f20 100644 --- a/include/site.inc +++ b/include/site.inc @@ -123,7 +123,7 @@ function mirror_type($site = false) } // Redirect to an URI on this mirror site or outside this site -function mirror_redirect($absoluteURI) +function mirror_redirect($absoluteURI): void { global $MYSITE; @@ -160,7 +160,7 @@ function mirror_setcookie($name, $content, $exptime) // Use this function to write out proper headers on // pages where the content should not be publicly cached -function header_nocache() +function header_nocache(): void { // Only try to send out headers in case // those were not sent already -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php