Skip to content
Snippets Groups Projects
Commit 6b795c4a authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update arrays to short syntax

parent 1bb70d00
Branches
No related tags found
1 merge request!66php8 only; added variable types; short array syntax; remove glyphicons
......@@ -165,7 +165,7 @@ function checkCommands(array $aCommands): string
$sOut="";
$aErrors = array();
$aErrors = [];
include("../config/inc_projects_config.php");
if (!isset($aConfig) || !is_array($aConfig)) {
// echo showerror("\$aConfig does not exist. The config was not included before including " . __FILE__ . " in the request/ script.");
......@@ -180,14 +180,14 @@ if (!isset($aConfig) || !is_array($aConfig)) {
}
$sOut.='<h2>Check subdirs of key dataDir</h2>';
foreach (array($aConfig['dataDir'] . '/database', $aConfig['dataDir'] . '/projects', $aConfig['dataDir'] . '/sshkeys', ) as $sDir2Check) {
foreach ([$aConfig['dataDir'] . '/database', $aConfig['dataDir'] . '/projects', $aConfig['dataDir'] . '/sshkeys', ] as $sDir2Check) {
$sOut.=checkdir($sDir2Check, 'dataDir + [subdir]');
}
// ----------------------------------------------------------------------
$sOut.='<h2>Check keys</h2>';
// check required keys in the config
foreach (array('auth', 'build', 'lang', 'phases', 'projects', ) as $sKey) {
foreach (['auth', 'build', 'lang', 'phases', 'projects', ] as $sKey) {
$sOut.="Key [$sKey] ";
if (!array_key_exists($sKey, $aConfig)) {
$sOut.="<span class=\"error\">failed</span> missing key [$sKey] in config<br>";
......
......@@ -28,6 +28,7 @@
* 2022-12-15 make it compatible to PHP 8.2; add doc + comments
* 2023-05-15 fix _getBar() - division by zero
* 2024-07-12 php8 only: use variable types; update phpdocs
* 2024-09-04 fix short array syntax
* ----------------------------------------------------------------------
*/
class logger
......@@ -86,12 +87,12 @@ class logger
if (!$this->bShowDebug) {
return false;
}
$this->aMessages[] = array(
$this->aMessages[] = [
'time' => microtime(true),
'message' => $sMessage,
'level' => preg_replace('/[^a-z0-9\-\_]/', '', $sLevel),
'memory' => memory_get_usage()
);
];
return true;
}
......
......@@ -790,15 +790,15 @@ class projectgui extends project
// ---------- Build plugins
/*
$aPluginsBuild = array(
'select' => array(
$aPluginsBuild = [
'select' => [
'type' => 'checkbox',
'name' => 'build[enabled_build_plugins]',
'label' => t("build-plugins"),
'options' => [],
),
],
// 'project-config' => '',
);
];
foreach (array_keys($this->getConfiguredPlugins('build')) as $sPluginName){
$sPluginFile=$this->_getPluginFilename('build', $sPluginName);
......@@ -809,20 +809,20 @@ class projectgui extends project
include_once $this->_getPluginFilename('build', $sPluginName);
$TmpRolloutPlugin = new $sMyClassname([]);
echo "FOUND $sMyClassname<br>";
$aPluginsBuild['select']['options'][$sPluginName]=array(
$aPluginsBuild['select']['options'][$sPluginName]=[
'label' => $TmpRolloutPlugin->getName(),
'checked' => $bActive,
// 'onclick' => '$(\'.'.$sMyDivClass.'\').hide(); $(\'.' . $sMyDivClassActive . '\').show();',
);
];
} catch (Exception $ex) {
}
} else {
$aRollout['project-select']['options'][$sPluginName]=array(
$aRollout['project-select']['options'][$sPluginName]=[
'label' => 'not found: <span class="error">' . $sMyClassname . '</span>',
'checked' => false,
'disabled' => "disabled",
);
];
}
......
......@@ -89,8 +89,8 @@ class vcs implements iVcs
public function setConfig(array $aRepoConfig = []): bool
{
// checks
// foreach (array("type", "url") as $key) {
foreach (array("type") as $key) {
// foreach (["type", "url"] as $key) {
foreach (["type"] as $key) {
if (!isset($aRepoConfig[$key])) {
die("ERROR: key $key does not exist in config <pre>" . print_r($aRepoConfig, true) . "</pre>");
}
......@@ -357,7 +357,7 @@ class vcs implements iVcs
// $this->log(__FUNCTION__ . ' $sBranchKey = '.$sBranchKey);
// $sMessage = $this->getCommitmessageByBranch($sName, $sRevision);
$aReturn[$sBranchKey] = array(
$aReturn[$sBranchKey] = [
// 'debug'=> $aTmp,
'revision' => $sRevision,
'name' => $sName,
......@@ -365,7 +365,7 @@ class vcs implements iVcs
'label' => $sType . ': ' . $sBranch,
'type' => $sType,
// 'message' => $sMessage
);
];
}
}
$this->_aRemoteBranches = $aReturn;
......@@ -417,14 +417,14 @@ class vcs implements iVcs
}
$sMessage = $this->getCommitmessageByBranch(false, $bRefresh ? 'dummy_to_force_refresh' : false);
if ($sMessage) {
$aReturn = array(
$aReturn = [
'branch' => $this->_sCurrentBranch,
'shortname' => $this->_aRemoteBranches[$this->_sCurrentBranch]['shortname'],
'revision' => $this->_aRemoteBranches[$this->_sCurrentBranch]['revision'],
'type' => $this->_aRemoteBranches[$this->_sCurrentBranch]['type'],
'message' => $sMessage,
'_data' => $this->_aRemoteBranches[$this->_sCurrentBranch],
);
];
} else {
$aReturn = $this->getRevision(false);
}
......@@ -488,16 +488,16 @@ class vcs implements iVcs
* the return will fill $this->_aData["phases"]["source"] in project class
* (array keys are revision, message or error)
* if ok:
* array(
* [
* "branch" => $sRevision,
* "revision" => $sRevision,
* "message" => $sCommitmessage
* );
* ];
*
* on error:
* array(
* [
* "error" => $sErrormessage,
* );
* ];
*
* @param string $sWorkDir optional: local directory with initialized git repo
* @return bool|array
......@@ -581,19 +581,19 @@ class vcs implements iVcs
// $sCommitMsg=preg_replace('/Author:\ .*\n/', '', $sCommitMsg);
// $sCommitMsg=preg_replace('/Date:\ .*\n/', '', $sCommitMsg);
$aReturn = array(
$aReturn = [
"branch" => $this->_sCurrentBranch,
"revision" => $sRevision,
"message" => $sCommitMsg // ."\n". microtime(true),
);
];
} else {
if (!$sLoginfo) {
$sLoginfo = $sGitCmd;
}
// echo "DEBUG: error on reading git revision<br>";
$aReturn = array(
$aReturn = [
"error" => '<pre>' . $sLoginfo . '<hr>' . $sGitCmd . '</pre>'
);
];
}
// $this->log(__FUNCTION__ . ' return is <pre>'.print_r($aReturn, 1).'</pre>');
return $aReturn;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment