From 8a8eecf828c55f5fa37de6e9bf091628e5e4bc52 Mon Sep 17 00:00:00 2001
From: Tim Otten <totten@civicrm.org>
Date: Sun, 10 Jan 2021 16:37:16 -0800
Subject: [PATCH] (REF) distmaker - Simplify joomlaxml.php input-parsing with
 "??" notation

Makes this much easier to read.

Honestly, I'm not sure it should even be checking $_SERVER like this --
$argv is probably enough, and I suspect that $_SERVER won't give the
expected values in most PHP environments.
---
 distmaker/utils/joomlaxml.php | 33 ++++-----------------------------
 1 file changed, 4 insertions(+), 29 deletions(-)

diff --git a/distmaker/utils/joomlaxml.php b/distmaker/utils/joomlaxml.php
index c2f70f9d5c..15c1fd1f82 100644
--- a/distmaker/utils/joomlaxml.php
+++ b/distmaker/utils/joomlaxml.php
@@ -1,34 +1,9 @@
 <?php
 
-if (isset($GLOBALS['_SERVER']['DM_SOURCEDIR'])) {
-  $sourceCheckoutDir = $GLOBALS['_SERVER']['DM_SOURCEDIR'];
-}
-else {
-  $sourceCheckoutDir = $argv[1];
-}
-$sourceCheckoutDirLength = strlen($sourceCheckoutDir);
-
-if (isset($GLOBALS['_SERVER']['DM_TMPDIR'])) {
-  $targetDir = $GLOBALS['_SERVER']['DM_TMPDIR'] . '/com_civicrm';
-}
-else {
-  $targetDir = $argv[2];
-}
-$targetDirLength = strlen($targetDir);
-
-if (isset($GLOBALS['_SERVER']['DM_VERSION'])) {
-  $version = $GLOBALS['_SERVER']['DM_VERSION'];
-}
-else {
-  $version = $argv[3];
-}
-
-if (isset($GLOBALS['_SERVER']['DM_PKGTYPE'])) {
-  $pkgType = $GLOBALS['_SERVER']['DM_PKGTYPE'];
-}
-else {
-  $pkgType = $argv[4];
-}
+$sourceCheckoutDir = $GLOBALS['_SERVER']['DM_SOURCEDIR'] ?? $argv[1];
+$targetDir = $GLOBALS['_SERVER']['DM_TMPDIR'] . '/com_civicrm' ?? $argv[2];
+$version = $GLOBALS['_SERVER']['DM_VERSION'] ?? $argv[3];
+$pkgType = $GLOBALS['_SERVER']['DM_PKGTYPE'] ?? $argv[4];
 
 ini_set('include_path',
   "{$sourceCheckoutDir}:{$sourceCheckoutDir}/packages:" . ini_get('include_path')
-- 
2.25.1