(REF) distmaker - Simplify joomlaxml.php input-parsing with "??" notation
authorTim Otten <totten@civicrm.org>
Mon, 11 Jan 2021 00:37:16 +0000 (16:37 -0800)
committerTim Otten <totten@civicrm.org>
Mon, 11 Jan 2021 00:37:50 +0000 (16:37 -0800)
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

index c2f70f9d5cd945e525d569ba714e0b3ec95ecb32..15c1fd1f82522758a9415ebbb82b5706d7d9d5cf 100644 (file)
@@ -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')