mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
setup: phpstan level 0
This commit is contained in:
@@ -95,8 +95,17 @@ SQL;
|
|||||||
$aSelectInstall = CMDBSource::QueryToArray($sSQLQuery);
|
$aSelectInstall = CMDBSource::QueryToArray($sSQLQuery);
|
||||||
} catch (MySQLException $e) {
|
} catch (MySQLException $e) {
|
||||||
// No database or erroneous information
|
// No database or erroneous information
|
||||||
$this->log_error('Can not connect to the database: host: '.$oConfig->Get('db_host').', user:'.$oConfig->Get('db_user').', pwd:'.$oConfig->Get('db_pwd').', db name:'.$oConfig->Get('db_name'));
|
SetupLog::Error(
|
||||||
$this->log_error('Exception '.$e->getMessage());
|
'Can not connect to the database',
|
||||||
|
null,
|
||||||
|
[
|
||||||
|
'host' => $oConfig->Get('db_host'),
|
||||||
|
'user' => $oConfig->Get('db_user'),
|
||||||
|
'pwd:' => $oConfig->Get('db_pwd'),
|
||||||
|
'db name' => $oConfig->Get('db_name'),
|
||||||
|
'msg' => $e->getMessage(),
|
||||||
|
]
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +138,8 @@ SQL;
|
|||||||
// so assume that the datamodel version is equal to the application version
|
// so assume that the datamodel version is equal to the application version
|
||||||
$aResult['datamodel_version'] = $aResult['product_version'];
|
$aResult['datamodel_version'] = $aResult['product_version'];
|
||||||
}
|
}
|
||||||
$this->log_info("GetApplicationVersion returns: product_name: ".$aResult['product_name'].', product_version: '.$aResult['product_version']);
|
|
||||||
|
SetupLog::Info(__METHOD__, null, ["product_name" => $aResult['product_name'], "product_version" => $aResult['product_version']]);
|
||||||
return empty($aResult) ? false : $aResult;
|
return empty($aResult) ? false : $aResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ header("Expires: Fri, 17 Jul 1970 05:00:00 GMT"); // Date in the past
|
|||||||
/**
|
/**
|
||||||
* Main program
|
* Main program
|
||||||
*/
|
*/
|
||||||
$sOperation = Utils::ReadParam('operation', '');
|
$sOperation = utils::ReadParam('operation', '');
|
||||||
try {
|
try {
|
||||||
SetupUtils::CheckSetupToken();
|
SetupUtils::CheckSetupToken();
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ try {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'toggle_use_symbolic_links':
|
case 'toggle_use_symbolic_links':
|
||||||
$sUseSymbolicLinks = Utils::ReadParam('bUseSymbolicLinks', false);
|
$sUseSymbolicLinks = utils::ReadParam('bUseSymbolicLinks', false);
|
||||||
$bUseSymbolicLinks = ($sUseSymbolicLinks === 'true');
|
$bUseSymbolicLinks = ($sUseSymbolicLinks === 'true');
|
||||||
MFCompiler::SetUseSymbolicLinksFlag($bUseSymbolicLinks);
|
MFCompiler::SetUseSymbolicLinksFlag($bUseSymbolicLinks);
|
||||||
echo "toggle useSymbolicLinks flag : $bUseSymbolicLinks";
|
echo "toggle useSymbolicLinks flag : $bUseSymbolicLinks";
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ require_once(APPROOT.'/application/startup.inc.php');
|
|||||||
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
|
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
|
||||||
LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
|
LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
|
||||||
|
|
||||||
$sOperation = Utils::ReadParam('operation', 'step1');
|
$sOperation = utils::ReadParam('operation', 'step1');
|
||||||
$oP = new SetupPage('iTop email test utility');
|
$oP = new SetupPage('iTop email test utility');
|
||||||
|
|
||||||
// Although this page doesn't expose sensitive info, with it we can send multiple emails
|
// Although this page doesn't expose sensitive info, with it we can send multiple emails
|
||||||
@@ -208,7 +208,7 @@ function DisplayStep2(SetupPage $oP, $sFrom, $sTo)
|
|||||||
$oP->add("<p>Sending an email to '".htmlentities($sTo, ENT_QUOTES, 'utf-8')."'... (From: '".htmlentities($sFrom, ENT_QUOTES, 'utf-8')."')</p>\n");
|
$oP->add("<p>Sending an email to '".htmlentities($sTo, ENT_QUOTES, 'utf-8')."'... (From: '".htmlentities($sFrom, ENT_QUOTES, 'utf-8')."')</p>\n");
|
||||||
$oP->add("<form method=\"post\">\n");
|
$oP->add("<form method=\"post\">\n");
|
||||||
|
|
||||||
$oEmail = new Email();
|
$oEmail = new EMail();
|
||||||
$oEmail->SetRecipientTO($sTo);
|
$oEmail->SetRecipientTO($sTo);
|
||||||
$oEmail->SetRecipientFrom($sFrom);
|
$oEmail->SetRecipientFrom($sFrom);
|
||||||
$oEmail->SetSubject("Test iTop");
|
$oEmail->SetSubject("Test iTop");
|
||||||
@@ -256,8 +256,8 @@ try {
|
|||||||
|
|
||||||
case 'step2':
|
case 'step2':
|
||||||
$oP->no_cache();
|
$oP->no_cache();
|
||||||
$sTo = Utils::ReadParam('to', '', false, 'raw_data');
|
$sTo = utils::ReadParam('to', '', false, 'raw_data');
|
||||||
$sFrom = Utils::ReadParam('from', '', false, 'raw_data');
|
$sFrom = utils::ReadParam('from', '', false, 'raw_data');
|
||||||
DisplayStep2($oP, $sFrom, $sTo);
|
DisplayStep2($oP, $sFrom, $sTo);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use CoreException;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use IssueLog;
|
use IssueLog;
|
||||||
use SetupLog;
|
use SetupLog;
|
||||||
use Utils;
|
use utils;
|
||||||
|
|
||||||
class ModelReflectionSerializer
|
class ModelReflectionSerializer
|
||||||
{
|
{
|
||||||
@@ -34,7 +34,7 @@ class ModelReflectionSerializer
|
|||||||
public function GetModelFromEnvironment(string $sEnv): array
|
public function GetModelFromEnvironment(string $sEnv): array
|
||||||
{
|
{
|
||||||
IssueLog::Info(__METHOD__, null, ['env' => $sEnv]);
|
IssueLog::Info(__METHOD__, null, ['env' => $sEnv]);
|
||||||
$sPHPExec = trim(Utils::GetConfig()->Get('php_path'));
|
$sPHPExec = trim(utils::GetConfig()->Get('php_path'));
|
||||||
$sOutput = "";
|
$sOutput = "";
|
||||||
$iRes = 0;
|
$iRes = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Combodo\iTop\Setup\ModuleDependency;
|
|||||||
require_once(APPROOT.'/setup/runtimeenv.class.inc.php');
|
require_once(APPROOT.'/setup/runtimeenv.class.inc.php');
|
||||||
|
|
||||||
use Combodo\iTop\PhpParser\Evaluation\PhpExpressionEvaluator;
|
use Combodo\iTop\PhpParser\Evaluation\PhpExpressionEvaluator;
|
||||||
use ModuleFileReaderException;
|
use Combodo\iTop\Setup\ModuleDiscovery\ModuleFileReaderException;
|
||||||
use RunTimeEnvironment;
|
use RunTimeEnvironment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,16 +19,16 @@ class ModuleDependencySort
|
|||||||
|
|
||||||
final public static function GetInstance(): ModuleDependencySort
|
final public static function GetInstance(): ModuleDependencySort
|
||||||
{
|
{
|
||||||
if (!isset(static::$oInstance)) {
|
if (!isset(self::$oInstance)) {
|
||||||
static::$oInstance = new static();
|
self::$oInstance = new ModuleDependencySort();
|
||||||
}
|
}
|
||||||
|
|
||||||
return static::$oInstance;
|
return self::$oInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public static function SetInstance(?ModuleDependencySort $oInstance): void
|
final public static function SetInstance(?ModuleDependencySort $oInstance): void
|
||||||
{
|
{
|
||||||
static::$oInstance = $oInstance;
|
self::$oInstance = $oInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ use CoreException;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use ParseError;
|
use ParseError;
|
||||||
use PhpParser\Error;
|
use PhpParser\Error;
|
||||||
|
use PhpParser\Node\Arg;
|
||||||
|
use PhpParser\Node\Expr\Array_;
|
||||||
|
use PhpParser\Node\Expr\Assign;
|
||||||
use PhpParser\Node\Expr\StaticCall;
|
use PhpParser\Node\Expr\StaticCall;
|
||||||
|
use PhpParser\Node\Scalar\String_;
|
||||||
|
use PhpParser\Node\Stmt\ElseIf_;
|
||||||
use PhpParser\Node\Stmt\Expression;
|
use PhpParser\Node\Stmt\Expression;
|
||||||
use PhpParser\Node\Stmt\If_;
|
use PhpParser\Node\Stmt\If_;
|
||||||
use PhpParser\ParserFactory;
|
use PhpParser\ParserFactory;
|
||||||
use PhpParser\Node\Expr\Assign;
|
|
||||||
use PhpParser\Node\Stmt\ElseIf_;
|
|
||||||
use PhpParser\Node\Expr\Array_;
|
|
||||||
use PhpParser\Node\Scalar\String_;
|
|
||||||
use PhpParser\Node\Arg;
|
|
||||||
|
|
||||||
require_once __DIR__.'/ModuleFileReaderException.php';
|
require_once __DIR__.'/ModuleFileReaderException.php';
|
||||||
require_once APPROOT.'sources/PhpParser/Evaluation/PhpExpressionEvaluator.php';
|
require_once APPROOT.'sources/PhpParser/Evaluation/PhpExpressionEvaluator.php';
|
||||||
@@ -49,11 +49,11 @@ class ModuleFileReader
|
|||||||
|
|
||||||
final public static function GetInstance(): ModuleFileReader
|
final public static function GetInstance(): ModuleFileReader
|
||||||
{
|
{
|
||||||
if (!isset(static::$oInstance)) {
|
if (!isset(self::$oInstance)) {
|
||||||
static::$oInstance = new static();
|
self::$oInstance = new ModuleFileReader();
|
||||||
}
|
}
|
||||||
|
|
||||||
return static::$oInstance;
|
return self::$oInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public static function SetInstance(?ModuleFileReader $oInstance): void
|
final public static function SetInstance(?ModuleFileReader $oInstance): void
|
||||||
|
|||||||
@@ -126,9 +126,8 @@ class RunTimeEnvironment
|
|||||||
* from the given file
|
* from the given file
|
||||||
* @param $oConfig object The configuration (volatile, not necessarily already on disk)
|
* @param $oConfig object The configuration (volatile, not necessarily already on disk)
|
||||||
* @param $bModelOnly boolean Whether or not to allow loading a data model with no corresponding DB
|
* @param $bModelOnly boolean Whether or not to allow loading a data model with no corresponding DB
|
||||||
* @return none
|
|
||||||
*/
|
*/
|
||||||
public function InitDataModel($oConfig, $bModelOnly = true, $bUseCache = false)
|
public function InitDataModel($oConfig, $bModelOnly = true, $bUseCache = false): void
|
||||||
{
|
{
|
||||||
require_once APPROOT.'/setup/moduleinstallation.class.inc.php';
|
require_once APPROOT.'/setup/moduleinstallation.class.inc.php';
|
||||||
|
|
||||||
@@ -896,7 +895,7 @@ class RunTimeEnvironment
|
|||||||
try {
|
try {
|
||||||
call_user_func_array($aCallSpec, $aArgs);
|
call_user_func_array($aCallSpec, $aArgs);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$sModuleId = isset($sModuleId) ? $sModuleId : "";
|
$sModuleId = $aModuleInfo[ModuleFileReader::MODULE_INFO_ID] ?? "";
|
||||||
$sErrorMessage = "Module $sModuleId : error when calling module installer class $sModuleInstallerClass for $sHandlerName handler";
|
$sErrorMessage = "Module $sModuleId : error when calling module installer class $sModuleInstallerClass for $sHandlerName handler";
|
||||||
$aExceptionContextData = [
|
$aExceptionContextData = [
|
||||||
'ModulelId' => $sModuleId,
|
'ModulelId' => $sModuleId,
|
||||||
|
|||||||
@@ -599,7 +599,7 @@ class SetupUtils
|
|||||||
// create and test destination location
|
// create and test destination location
|
||||||
//
|
//
|
||||||
$sDestDir = dirname($sDBBackupPath);
|
$sDestDir = dirname($sDBBackupPath);
|
||||||
setuputils::builddir($sDestDir);
|
SetupUtils::builddir($sDestDir);
|
||||||
if (!is_dir($sDestDir)) {
|
if (!is_dir($sDestDir)) {
|
||||||
$aResult[] = new CheckResult(CheckResult::ERROR, "$sDestDir does not exist and could not be created.");
|
$aResult[] = new CheckResult(CheckResult::ERROR, "$sDestDir does not exist and could not be created.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||||
use Combodo\iTop\Application\UI\Base\Component\Html\Html;
|
|
||||||
use Combodo\iTop\Application\WebPage\WebPage;
|
use Combodo\iTop\Application\WebPage\WebPage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -402,18 +401,6 @@ abstract class WizardStep
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
abstract public function Display(WebPage $oPage);
|
abstract public function Display(WebPage $oPage);
|
||||||
/**
|
|
||||||
* Displays the wizard page for the current class/state
|
|
||||||
* return UIBlock
|
|
||||||
* The name of the input fields (and their id if one is supplied) MUST NOT start with "_"
|
|
||||||
* (this is reserved for the wizard's own parameters)
|
|
||||||
* @return \Combodo\iTop\Application\UI\Base\UIBlock
|
|
||||||
* @since 3.0.0
|
|
||||||
*/
|
|
||||||
public function DisplayBlock(WebPage $oPage)
|
|
||||||
{
|
|
||||||
return new Html($this->Display($oPage));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes the page's parameters and (if moving forward) returns the next step/state to be displayed
|
* Processes the page's parameters and (if moving forward) returns the next step/state to be displayed
|
||||||
|
|||||||
Reference in New Issue
Block a user