Skip to content

Enhancement: Enable void_return fixer #661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'switch_case_space' => true,
'trim_array_spaces' => true,
'visibility_required' => true,
'void_return' => true,
'whitespace_after_comma_in_array' => true,
]);

Expand Down
16 changes: 8 additions & 8 deletions include/changelogs.inc
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion include/do-download.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
10 changes: 5 additions & 5 deletions include/errors.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// A 'good looking' 404 error message page
function error_404()
function error_404(): void
{
global $MYSITE;
status_header(404);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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"]);
Expand All @@ -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) .
Expand Down
28 changes: 14 additions & 14 deletions include/layout.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand Down Expand Up @@ -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 = '
Expand Down Expand Up @@ -447,7 +447,7 @@ EOT;
return $retval;
}

function site_header($title = 'Hypertext Preprocessor', $config = [])
function site_header($title = 'Hypertext Preprocessor', $config = []): void
{
global $MYSITE;

Expand Down Expand Up @@ -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";
}
Expand Down Expand Up @@ -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" => [
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -591,15 +591,15 @@ 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);
foreach ($TOC as $entry) {
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];
Expand Down
8 changes: 4 additions & 4 deletions include/prepend.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -94,7 +94,7 @@ include __DIR__ . '/last_updated.inc';
// -----------------------------------------------------------------------------

// Load in the user preferences
function myphpnet_load()
function myphpnet_load(): void
{
global $MYPHPNET, $MYSITE;

Expand Down Expand Up @@ -169,7 +169,7 @@ function myphpnet_showug($enable = null) {
}

// Save user settings in cookie
function myphpnet_save()
function myphpnet_save(): void
{
global $MYPHPNET;

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/results.inc
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
6 changes: 3 additions & 3 deletions include/shared-manual.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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>";
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -381,7 +381,7 @@ CHANGE_LANG;
return trim($r);
}

function manual_footer() {
function manual_footer(): void {
global $USERNOTES, $__RELATED;

manual_notes($USERNOTES);
Expand Down
4 changes: 2 additions & 2 deletions include/site.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down