[web-php] master: Ternary to null coalescing
| From: | Mathias Reker ⚡️ via GitHub | Date: | Fri, 17 Jun 2022 16:49:16 +0000 |
| Subject: | [web-php] master: Ternary to null coalescing | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-30098@lists.php.net to get a copy of this message | ||
Author: Mathias Reker ⚡️ (MathiasReker)
Committer: GitHub (web-flow)
Pusher: cmb69
Date: 2022-06-17T18:43:40+02:00
Commit: https://github.com/php/web-php/commit/ede0cad42fc21c800696f91b777db635ca0825aa
Raw diff: https://github.com/php/web-php/commit/ede0cad42fc21c800696f91b777db635ca0825aa.diff
Ternary to null coalescing
Use null coalescing operator ?? where possible.
Closes GH-528.
Changed paths:
M eol.php
M manual/add-note.php
M manual/vote-note.php
Diff:
diff --git a/eol.php b/eol.php
index d63c00b1d..889260158 100644
--- a/eol.php
+++ b/eol.php
@@ -61,7 +61,7 @@
</a>
</td>
<td>
- <?php echo isset($BRANCH_NOTES[$branch]) ? $BRANCH_NOTES[$branch] : ''; ?>
+ <?php echo $BRANCH_NOTES[$branch] ?? ''; ?>
</td>
</tr>
<?php endforeach ?>
diff --git a/manual/add-note.php b/manual/add-note.php
index 6403e65c8..743c8f3fe 100644
--- a/manual/add-note.php
+++ b/manual/add-note.php
@@ -88,9 +88,8 @@
// No error was found, and the submit action is required
if (!$error && strtolower($_POST['action']) != "preview") {
- $redirip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
- $_SERVER['HTTP_X_FORWARDED_FOR'] :
- (isset($_SERVER['HTTP_VIA']) ? $_SERVER['HTTP_VIA'] :
'');
+ $redirip = $_SERVER['HTTP_X_FORWARDED_FOR'] ??
+ ($_SERVER['HTTP_VIA'] ?? '');
// Post the variables to the central user note script
$result = posttohost(
diff --git a/manual/vote-note.php b/manual/vote-note.php
index a9600eb4b..cb3a6be4b 100644
--- a/manual/vote-note.php
+++ b/manual/vote-note.php
@@ -9,8 +9,8 @@
$error = false;
$thankyou = false;
$headerset = false;
-$BACKpage = htmlspecialchars(isset($_REQUEST['page']) ? $_REQUEST['page'] :
'');
-$BACKid = htmlspecialchars(isset($_REQUEST['id']) ? $_REQUEST['id'] :
'');
+$BACKpage = htmlspecialchars($_REQUEST['page'] ?? '');
+$BACKid = htmlspecialchars($_REQUEST['id'] ?? '');
$link = "/{$BACKpage}#{$BACKid}";
$master_url = "https://main.php.net/entry/user-notes-vote.php";