Author: Christoph M. Becker (cmb69) Date: 2022-07-15T14:05:50+02:00 Commit: https://github.com/php/web-php/commit/5c9eab2f382599db143fb491f8ee7762960e8ab3 Raw diff: https://github.com/php/web-php/commit/5c9eab2f382599db143fb491f8ee7762960e8ab3.diff
Fix CS violations (case of null, false and true) Changed paths: M include/branches.inc M include/do-download.inc M include/get-download.inc M include/ip-to-country.inc M include/languages.inc M include/layout.inc M include/manual-lookup.inc M include/prepend.inc M include/site.inc Diff: diff --git a/include/branches.inc b/include/branches.inc index dc361988b..05063fe39 100644 --- a/include/branches.inc +++ b/include/branches.inc @@ -400,5 +400,5 @@ function get_current_release_for_branch(int $major, ?int $minor): ?string { } } - return NULL; + return null; } diff --git a/include/do-download.inc b/include/do-download.inc index c2ffbc4e2..33517dd6d 100644 --- a/include/do-download.inc +++ b/include/do-download.inc @@ -9,10 +9,10 @@ function get_actual_download_file($file) { // Could be a normal download or a manual download file - $possible_files = array($file => TRUE, "manual/$file" => FALSE); + $possible_files = array($file => true, "manual/$file" => false); // Find out what is the exact file requested - $found = FALSE; + $found = false; foreach ($possible_files as $name => $log) { if (@file_exists($_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $name)) { $found = $name; diff --git a/include/get-download.inc b/include/get-download.inc index f19e3f79e..6ae300b43 100644 --- a/include/get-download.inc +++ b/include/get-download.inc @@ -16,7 +16,7 @@ $site_config = array( ); // Find out what is the exact file requested -$file = FALSE; +$file = false; foreach ($possible_files as $name) { if (@file_exists($_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $name)) { $file = $name; @@ -30,7 +30,7 @@ site_header('Get Download', $site_config); echo '<div id="mirrors-container">'; $size = 0; // No downloadable file found -if ($file === FALSE) { +if ($file === false) { $info = "<p> The file you requested (<strong>" . htmlspecialchars($df, ENT_QUOTES, "UTF-8") . "</strong>) is not found on this server (<strong>{$MYSITE}</strong>).</p>"; diff --git a/include/ip-to-country.inc b/include/ip-to-country.inc index f7b39a058..44c7a29a8 100644 --- a/include/ip-to-country.inc +++ b/include/ip-to-country.inc @@ -51,9 +51,9 @@ function i2c_go() $ipnum = i2c_realip(); // User already has a country detected with this IP stored - if (!empty($_COOKIE['COUNTRY']) && strpos($_COOKIE['COUNTRY'], ',') !== FALSE) { + if (!empty($_COOKIE['COUNTRY']) && strpos($_COOKIE['COUNTRY'], ',') !== false) { list($COUNTRY, $storedip) = explode(",", $_COOKIE['COUNTRY']); - if ($storedip == $ipnum) { return TRUE; } + if ($storedip == $ipnum) { return true; } } // Convert the IP number to some useable form for searching @@ -66,7 +66,7 @@ function i2c_go() // in the index do not search, as it would take // a very long time. It is an error, if we have // not found anything in the index - if ($idx !== FALSE) { + if ($idx !== false) { $country = i2c_search_in_db($ipn, $idx); } else { $country = 'NA'; @@ -91,7 +91,7 @@ function i2c_search_in_index($ip) __DIR__ . "/../backend/ip-to-country.idx", "r" ); - if (!$dbidx) { return FALSE; } + if (!$dbidx) { return false; } // Read in granularity from index file and // convert current IP to something useful @@ -188,7 +188,7 @@ function i2c_realip() { // No IP found (will be overwritten by for // if any IP is found behind a firewall) - $ip = FALSE; + $ip = false; // If HTTP_CLIENT_IP is set, then give it priority if (!empty($_SERVER["HTTP_CLIENT_IP"])) { @@ -203,7 +203,7 @@ function i2c_realip() // Put the IP's into an array which we shall work with shortly. $ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']); - if ($ip) { array_unshift($ips, $ip); $ip = FALSE; } + if ($ip) { array_unshift($ips, $ip); $ip = false; } for ($i = 0; $i < count($ips); $i++) { // Skip RFC 1918 IP's 10.0.0.0/8, 172.16.0.0/12 and diff --git a/include/languages.inc b/include/languages.inc index 6895f3d4e..a75a5018d 100644 --- a/include/languages.inc +++ b/include/languages.inc @@ -90,7 +90,7 @@ $ACTIVE_ONLINE_LANGUAGES = array_diff($LANGUAGES, $INACTIVE_ONLINE_LANGUAGES); // Convert between language codes back and forth // [We use non standard languages codes and so conversion // is needed when communicating with the outside world] -function language_convert($langcode, $to_phpweb_format = TRUE) +function language_convert($langcode, $to_phpweb_format = true) { global $LANGUAGES; if ($to_phpweb_format) { diff --git a/include/layout.inc b/include/layout.inc index 892eb995b..26944447f 100644 --- a/include/layout.inc +++ b/include/layout.inc @@ -10,13 +10,13 @@ ini_set('highlight.string', 'string'); ini_set('highlight.html', 'html'); // Highlight PHP code -function highlight_php($code, $return = FALSE) +function highlight_php($code, $return = false) { - $highlighted = highlight_string($code, TRUE); + $highlighted = highlight_string($code, true); // Use this ugly hack for now to avoid code snippets with bad syntax screwing up the highlighter if (strstr($highlighted, "include/layout.inc</b>")) { - $highlighted = '<span class="html">'. nl2br(htmlentities($code, ENT_HTML5), FALSE) ."</span>"; + $highlighted = '<span class="html">'. nl2br(htmlentities($code, ENT_HTML5), false) ."</span>"; } // Fix output to use CSS classes and wrap well @@ -81,8 +81,8 @@ function resize_image($img, $width = 1, $height = 1) } // Return an <img> tag for a given image file available on the server -function make_image($file, $alt = FALSE, $align = FALSE, $extras = FALSE, - $dir = '/images', $addsize = TRUE) +function make_image($file, $alt = false, $align = false, $extras = false, + $dir = '/images', $addsize = true) { // If no / was provided at the start of $dir, add it $webdir = $_SERVER['MYSITE'] . ($dir[0] == '/' ? '' : '/') . $dir; @@ -116,7 +116,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, +function print_image($file, $alt = false, $align = false, $extras = false, $dir = '/images') { echo make_image($file, $alt, $align, $extras, $dir); @@ -134,13 +134,13 @@ function news_image($URL, $image, $alt, $print = true) } // Return HTML code for a submit button image -function make_submit($file, $alt = FALSE, $align = FALSE, $extras = FALSE, +function make_submit($file, $alt = false, $align = false, $extras = false, $dir = '/images', $border = 0) { // Get an image without size info and convert the // border attribute to use CSS, as border="" is not // supported on <input> elements in [X]HTML - $img = make_image($file, $alt, $align, $extras, $dir, FALSE); + $img = make_image($file, $alt, $align, $extras, $dir, false); $img = str_replace( "border=\"$border\"", "style=\"border: {$border}px;\"", @@ -152,7 +152,7 @@ function make_submit($file, $alt = FALSE, $align = FALSE, $extras = FALSE, } // Return a hiperlink to something within the site -function make_link ($url, $linktext = FALSE, $target = FALSE, $extras = FALSE) +function make_link ($url, $linktext = false, $target = false, $extras = false) { return sprintf("<a href=\"%s\"%s%s>%s</a>", $url, @@ -163,7 +163,7 @@ function make_link ($url, $linktext = FALSE, $target = FALSE, $extras = FALSE) } // Print a hyperlink to something, within the site -function print_link($url, $linktext = FALSE, $target = FALSE, $extras = FALSE) +function print_link($url, $linktext = false, $target = false, $extras = false) { echo make_link($url, $linktext, $target, $extras); } @@ -249,7 +249,7 @@ function clean($var) { function clean_note($text) { // Highlight PHP source - $text = highlight_php(trim($text), TRUE); + $text = highlight_php(trim($text), true); // Turn urls into links return preg_replace( diff --git a/include/manual-lookup.inc b/include/manual-lookup.inc index 4a33862e7..cb125a43a 100644 --- a/include/manual-lookup.inc +++ b/include/manual-lookup.inc @@ -105,12 +105,12 @@ function find_manual_page($lang, $keyword) // open the database, fall back to normal search. Use // open rather than popen to avoid any chance of confusion // when rsync updates the database - $dbh = FALSE; + $dbh = false; if (class_exists('PDO')) { if (in_array('sqlite', PDO::getAvailableDrivers())) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/backend/manual-lookup.sqlite')) { try { - $dbh = new PDO( 'sqlite:' . $_SERVER['DOCUMENT_ROOT'] . '/backend/manual-lookup.sqlite', '', '', array(PDO::ATTR_PERSISTENT => TRUE, PDO::ATTR_EMULATE_PREPARES => TRUE) ); + $dbh = new PDO( 'sqlite:' . $_SERVER['DOCUMENT_ROOT'] . '/backend/manual-lookup.sqlite', '', '', array(PDO::ATTR_PERSISTENT => true, PDO::ATTR_EMULATE_PREPARES => true) ); } catch (PDOException $e) { return find_manual_page_slow($lang, $keyword); } @@ -130,7 +130,7 @@ function find_manual_page($lang, $keyword) if ($keyword != '_') { $keyword = str_replace('_', '-', $keyword); } - if (strpos($keyword, '(') !== FALSE) { + if (strpos($keyword, '(') !== false) { $keyword = preg_replace("!\\(.*\\)!", "-", $keyword); } diff --git a/include/prepend.inc b/include/prepend.inc index b8b95f1d3..6332d5a33 100644 --- a/include/prepend.inc +++ b/include/prepend.inc @@ -99,10 +99,10 @@ function myphpnet_load() global $MYPHPNET, $MYSITE; // Empty the preferences array - $MYPHPNET = array(FALSE, FALSE, "NONE", 0, FALSE); + $MYPHPNET = array(false, false, "NONE", 0, false); if ($MYSITE === 'http://docs.php.net/') { - $MYPHPNET[4] = TRUE; + $MYPHPNET[4] = true; } // If we have a cookie, set the values in the array @@ -115,7 +115,7 @@ function myphpnet_load() } // Get or set preferred language code -function myphpnet_language($langcode = FALSE) +function myphpnet_language($langcode = false) { global $MYPHPNET, $LANGUAGES; @@ -135,7 +135,7 @@ const MYPHPNET_URL_FUNC = 'quickref'; const MYPHPNET_URL_MANUAL = 'manual'; // Set URL search fallback preference -function myphpnet_urlsearch($type = FALSE) +function myphpnet_urlsearch($type = false) { global $MYPHPNET; @@ -179,7 +179,7 @@ function myphpnet_save() // Fill in values not specified for ($i = 0; $i <= 3; $i++) { - if (!isset($MYPHPNET[$i])) { $MYPHPNET[$i] = FALSE; } + if (!isset($MYPHPNET[$i])) { $MYPHPNET[$i] = false; } } // Set all the preferred values for a year diff --git a/include/site.inc b/include/site.inc index add898e68..01f8400d2 100644 --- a/include/site.inc +++ b/include/site.inc @@ -15,8 +15,8 @@ const MIRROR_DOESNOTWORK = 3; $MIRRORS = array( "https://www.php.net/" => array( - "DEU", "MyraCloud", FALSE, - "https://myracloud.com/en/", MIRROR_SPECIAL, TRUE, + "DEU", "MyraCloud", false, + "https://myracloud.com/en/", MIRROR_SPECIAL, true, "en", MIRROR_OK), ); @@ -30,7 +30,7 @@ include __DIR__ . '/languages.inc'; // Returns true if the current (or specified) // site is the primary mirror site -function is_primary_site($site = FALSE) +function is_primary_site($site = false) { global $MYSITE; if (!$site) { $site = $MYSITE; } @@ -39,32 +39,32 @@ function is_primary_site($site = FALSE) // Returns true if the current (or specified) // mirror site is an official mirror site -function is_official_mirror($site = FALSE) +function is_official_mirror($site = false) { return (mirror_type($site) != MIRROR_VIRTUAL); } // Returns the current (or specified) // mirror site's default language -function default_language($site = FALSE) +function default_language($site = false) { global $MIRRORS, $MYSITE; if (!$site) { $site = $MYSITE; } - return (isset($MIRRORS[$site]) ? $MIRRORS[$site][6] : FALSE); + return (isset($MIRRORS[$site]) ? $MIRRORS[$site][6] : false); } // Returns true if the current (or specified) mirror // site is registered to have local search support -function have_search($site = FALSE) +function have_search($site = false) { global $MIRRORS, $MYSITE; if (!$site) { $site = $MYSITE; } - return (isset($MIRRORS[$site]) ? $MIRRORS[$site][5] : FALSE); + return (isset($MIRRORS[$site]) ? $MIRRORS[$site][5] : false); } // Returns the current (or specified) // mirror site's provider's name -function mirror_provider($site = FALSE) +function mirror_provider($site = false) { global $MIRRORS, $MYSITE; if (!$site) { $site = $MYSITE; } @@ -82,7 +82,7 @@ function mirror_provider($site = FALSE) // Returns the current (or specified) // mirror site's provider's URL -function mirror_provider_url($site = FALSE) +function mirror_provider_url($site = false) { global $MIRRORS,$MYSITE; if (!$site) { $site = $MYSITE; } @@ -100,7 +100,7 @@ function mirror_provider_url($site = FALSE) // Returns the current (or specified) // mirror site's type (use the constants!) -function mirror_type($site = FALSE) +function mirror_type($site = false) { global $MIRRORS, $MYSITE; if (!$site) { $site = $MYSITE; } @@ -149,7 +149,7 @@ function mirror_setcookie($name, $content, $exptime) return setcookie($name, $content, time() + $exptime, '/'); } - return FALSE; + return false; } // Use this function to write out proper headers on @@ -259,7 +259,7 @@ if ($_SERVER["SERVER_PORT"] != '80' && $_SERVER["SERVER_PORT"] != 443) { // If the mirror is not registered with this name, provide defaults // (no country code, no search, no stats, English default language ...) if (!isset($MIRRORS[$MYSITE])) { - $MIRRORS[$MYSITE] = array("xx", $MYSITE, FALSE, $MYSITE, MIRROR_VIRTUAL, FALSE, "en", MIRROR_OK); + $MIRRORS[$MYSITE] = array("xx", $MYSITE, false, $MYSITE, MIRROR_VIRTUAL, false, "en", MIRROR_OK); } // Override mirror language with local preference -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php