mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-21 08:12:26 +02:00
N°8796 - Add PHP code style validation in iTop and extensions - format whole code base
This commit is contained in:
@@ -28,14 +28,10 @@ use Symfony\Component\Dotenv\Dotenv;
|
||||
require_once APPROOT.'/lib/autoload.php';
|
||||
|
||||
// Load current environment if necessary (typically from CLI as the app is not started yet)
|
||||
if (!defined('MODULESROOT'))
|
||||
{
|
||||
if (file_exists(__DIR__.'/../../../../approot.inc.php'))
|
||||
{
|
||||
if (!defined('MODULESROOT')) {
|
||||
if (file_exists(__DIR__.'/../../../../approot.inc.php')) {
|
||||
require_once __DIR__.'/../../../../approot.inc.php'; // When in env-xxxx folder
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
require_once __DIR__.'/../../../../../approot.inc.php'; // When in datamodels/x.x folder
|
||||
}
|
||||
require_once APPROOT.'/application/startup.inc.php';
|
||||
@@ -62,7 +58,7 @@ if (!class_exists(Dotenv::class)) {
|
||||
}
|
||||
|
||||
if (null === $sEnv = (isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null))) {
|
||||
$oDotenv->populate(array('APP_ENV' => $sEnv = 'prod'));
|
||||
$oDotenv->populate(['APP_ENV' => $sEnv = 'prod']);
|
||||
}
|
||||
|
||||
if ('test' !== $sEnv && file_exists($sPathDist = "$sPath.local")) {
|
||||
@@ -83,31 +79,27 @@ if (!class_exists(Dotenv::class)) {
|
||||
$_SERVER += $_ENV;
|
||||
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = (isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null)) ?: 'prod';
|
||||
$_SERVER['APP_DEBUG'] = isset($_SERVER['APP_DEBUG']) ? $_SERVER['APP_DEBUG'] : (isset($_ENV['APP_DEBUG']) ? $_ENV['APP_DEBUG'] : ('prod' !== $_SERVER['APP_ENV']));
|
||||
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int)$_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'],
|
||||
FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
|
||||
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int)$_SERVER['APP_DEBUG'] || filter_var(
|
||||
$_SERVER['APP_DEBUG'],
|
||||
FILTER_VALIDATE_BOOLEAN
|
||||
) ? '1' : '0';
|
||||
|
||||
if ($_SERVER['APP_DEBUG'])
|
||||
{
|
||||
if ($_SERVER['APP_DEBUG']) {
|
||||
umask(0000);
|
||||
|
||||
if (class_exists(Debug::class))
|
||||
{
|
||||
if (class_exists(Debug::class)) {
|
||||
Debug::enable();
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_ENV['PORTAL_ID']))
|
||||
{
|
||||
if (isset($_ENV['PORTAL_ID'])) {
|
||||
// Nothing to do
|
||||
}
|
||||
// Note: Default value is set to "false" to differentiate an empty value from a non given parameter
|
||||
elseif ($sPortalId = utils::ReadParam('portal_id', false, true))
|
||||
{
|
||||
elseif ($sPortalId = utils::ReadParam('portal_id', false, true)) {
|
||||
|
||||
$_ENV['PORTAL_ID'] = $sPortalId;
|
||||
}
|
||||
elseif (defined('PORTAL_ID'))
|
||||
{
|
||||
} elseif (defined('PORTAL_ID')) {
|
||||
$_ENV['PORTAL_ID'] = PORTAL_ID;
|
||||
@trigger_error(
|
||||
sprintf(
|
||||
@@ -118,16 +110,14 @@ elseif (defined('PORTAL_ID'))
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($_ENV['PORTAL_ID']))
|
||||
{
|
||||
if (empty($_ENV['PORTAL_ID'])) {
|
||||
echo "Missing argument 'portal_id'";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Make sure that the PORTAL_ID constant is also defined
|
||||
// Note: This is widely used in extensions, snippets and all
|
||||
if (!defined('PORTAL_ID'))
|
||||
{
|
||||
if (!defined('PORTAL_ID')) {
|
||||
define('PORTAL_ID', $_ENV['PORTAL_ID']);
|
||||
}
|
||||
|
||||
@@ -141,4 +131,4 @@ $_ENV['COMBODO_PORTAL_BASE_ABSOLUTE_URL'] = utils::GetAbsoluteUrlModulesRoot().'
|
||||
$_ENV['COMBODO_PORTAL_BASE_ABSOLUTE_PATH'] = MODULESROOT.'/itop-portal-base/portal/public/';
|
||||
$_ENV['COMBODO_PORTAL_INSTANCE_ABSOLUTE_URL'] = utils::GetAbsoluteUrlModulesRoot().$_ENV['PORTAL_ID'].'/';
|
||||
$_ENV['COMBODO_PORTAL_LANGUAGE'] = UserRights::GetUserLanguage();
|
||||
$_ENV['COMBODO_PORTAL_METADATA_LANGUAGE'] = strtolower(substr($_ENV['COMBODO_PORTAL_LANGUAGE'], 0, 2));;
|
||||
$_ENV['COMBODO_PORTAL_METADATA_LANGUAGE'] = strtolower(substr($_ENV['COMBODO_PORTAL_LANGUAGE'], 0, 2));;
|
||||
|
||||
Reference in New Issue
Block a user