diff --git a/.travis.yml b/.travis.yml
index 4b6194fc..d3fc415a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,9 +22,13 @@ env:
DIRECTOR_TESTDB_USER="director_test"
before_script:
- - composer self-update --stable
+ - curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
+ - wget https://github.com/Icinga/icingaweb2/archive/v2.4.0.tar.gz
+ - tar xfz v2.4.0.tar.gz
+ - ln -s icingaweb2-2.4.0/library/Icinga
+ - ln -s icingaweb2-2.4.0/library/vendor/Zend
- ./test/travis-prepare.sh
- - composer install
script:
+ - php phpcs.phar --report-width=auto --report-full --report-gitblame --report-summary -p --standard=PSR2 --extensions=php --encoding=utf-8 -w -s library/Director/ application/ configuration.php run.php test
- phpunit --testdox || phpunit --verbose
diff --git a/application/clicommands/ConfigCommand.php b/application/clicommands/ConfigCommand.php
index 7b0ecb8e..f2fdd18c 100644
--- a/application/clicommands/ConfigCommand.php
+++ b/application/clicommands/ConfigCommand.php
@@ -110,7 +110,6 @@ class ConfigCommand extends Command
return;
}
-
}
if ($api->dumpConfig($config, $db)) {
diff --git a/application/controllers/DataController.php b/application/controllers/DataController.php
index 237b900c..cbe0b1ca 100644
--- a/application/controllers/DataController.php
+++ b/application/controllers/DataController.php
@@ -61,7 +61,6 @@ class DataController extends ActionController
'url' => 'director/data/listentry' . '?list_id=' . $id,
'label' => $this->translate('List entries'),
))->activate('editlist');
-
} else {
$this->view->title = $this->translate('Add');
diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php
index 57c21be3..c307b64f 100644
--- a/application/controllers/HostController.php
+++ b/application/controllers/HostController.php
@@ -6,11 +6,9 @@ use Exception;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Director\Exception\NestingError;
use Icinga\Module\Director\IcingaConfig\AgentWizard;
-use Icinga\Module\Director\Objects\IcingaEndpoint;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Objects\IcingaService;
use Icinga\Module\Director\Objects\IcingaServiceSet;
-use Icinga\Module\Director\Objects\IcingaZone;
use Icinga\Module\Director\Util;
use Icinga\Module\Director\Web\Controller\ObjectController;
@@ -167,8 +165,8 @@ class HostController extends ObjectController
)->where('hs.host_id = ?', $host->id);
$sets = IcingaServiceSet::loadAll($db, $query, 'object_name');
- foreach ($sets as $name => $set) {
+ foreach ($sets as $name => $set) {
$title = sprintf($this->translate('%s (Service set)'), $name);
$table = $this->loadTable('IcingaServiceSetService')
->setServiceSet($set)
@@ -337,7 +335,6 @@ class HostController extends ObjectController
$wizard->setTicketSalt($this->api()->getTicketSalt());
$this->view->windows = $wizard->renderWindowsInstaller();
$this->view->linux = $wizard->renderLinuxInstaller();
-
} catch (Exception $e) {
$this->view->ticket = 'ERROR';
$this->view->error = sprintf(
diff --git a/application/controllers/ImportsourceController.php b/application/controllers/ImportsourceController.php
index 1a3cfaf9..dcd4fb8e 100644
--- a/application/controllers/ImportsourceController.php
+++ b/application/controllers/ImportsourceController.php
@@ -13,7 +13,7 @@ class ImportsourceController extends ActionController
{
public function indexAction()
{
- $this->setAutoRefreshInterval(10);
+ $this->setAutorefreshInterval(10);
$id = $this->params->get('id');
$this->prepareTabs($id)->activate('show');
$source = $this->view->source = ImportSource::load($id, $this->db());
@@ -173,7 +173,6 @@ class ImportsourceController extends ActionController
'url' => 'director/importsource/preview' . '?id=' . $id,
'label' => $this->translate('Preview'),
));
-
} else {
$tabs->add('add', array(
'url' => 'director/importsource/add',
diff --git a/application/controllers/JobsController.php b/application/controllers/JobsController.php
index 3b57d64a..c1b1ad1f 100644
--- a/application/controllers/JobsController.php
+++ b/application/controllers/JobsController.php
@@ -23,7 +23,7 @@ class JobsController extends ActionController
$this->loadTable('job')
->setConnection($this->db())
);
- $this->setViewScript('list/table');
+ $this->setViewScript('list/table');
}
}
diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php
index 03b80a57..5a4153a3 100644
--- a/application/controllers/ServiceController.php
+++ b/application/controllers/ServiceController.php
@@ -124,7 +124,6 @@ class ServiceController extends ObjectController
}
if ($this->host && $object->usesVarOverrides()) {
-
$parent = IcingaService::create(array(
'object_type' => 'template',
// TODO: => 'myself', -> There is no such import: "myself"
@@ -157,7 +156,6 @@ class ServiceController extends ObjectController
if ($object->isTemplate()
&& $object->getResolvedProperty('check_command_id')
) {
-
$this->view->actionLinks .= ' ' . $this->view->qlink(
'Create apply-rule',
'director/service/add',
diff --git a/application/controllers/SyncruleController.php b/application/controllers/SyncruleController.php
index ae239f8c..dc8022cc 100644
--- a/application/controllers/SyncruleController.php
+++ b/application/controllers/SyncruleController.php
@@ -25,7 +25,6 @@ class SyncruleController extends ActionController
if ($lastRunId = $rule->getLastSyncRunId()) {
$this->loadSyncRun($lastRunId);
-
} else {
$this->view->run = null;
}
diff --git a/application/forms/DirectorDatafieldForm.php b/application/forms/DirectorDatafieldForm.php
index f8323969..ba4446be 100644
--- a/application/forms/DirectorDatafieldForm.php
+++ b/application/forms/DirectorDatafieldForm.php
@@ -16,13 +16,11 @@ class DirectorDatafieldForm extends DirectorObjectForm
protected function onRequest()
{
if ($this->hasBeenSent()) {
-
if ($this->shouldBeDeleted()) {
$varname = $this->getSentValue('varname');
if ($cnt = CustomVariables::countAll($varname, $this->getDb())) {
$this->askForVariableDeletion($varname, $cnt);
}
-
}
}
diff --git a/application/forms/DirectorJobForm.php b/application/forms/DirectorJobForm.php
index bf6ea783..7ca998c8 100644
--- a/application/forms/DirectorJobForm.php
+++ b/application/forms/DirectorJobForm.php
@@ -51,8 +51,8 @@ class DirectorJobForm extends DirectorObjectForm
));
$periods = $this->db->enumTimeperiods();
- if (!empty($periods)) {
+ if (!empty($periods)) {
$this->addElement(
'select',
'timeperiod_id',
diff --git a/application/forms/IcingaCloneObjectForm.php b/application/forms/IcingaCloneObjectForm.php
index 1831311b..0a33e03b 100644
--- a/application/forms/IcingaCloneObjectForm.php
+++ b/application/forms/IcingaCloneObjectForm.php
@@ -31,7 +31,6 @@ class IcingaCloneObjectForm extends QuickForm
$this->translate('Clone "%s"'),
$this->object->getObjectName()
);
-
}
public function onSuccess()
diff --git a/application/forms/IcingaDeleteObjectForm.php b/application/forms/IcingaDeleteObjectForm.php
index 77cbba14..409bdc3f 100644
--- a/application/forms/IcingaDeleteObjectForm.php
+++ b/application/forms/IcingaDeleteObjectForm.php
@@ -17,7 +17,6 @@ class IcingaDeleteObjectForm extends QuickForm
$this->translate('YES, please delete "%s"'),
$this->object->getObjectName()
);
-
}
public function onSuccess()
diff --git a/application/forms/IcingaImportObjectForm.php b/application/forms/IcingaImportObjectForm.php
index e7c85659..3942f745 100644
--- a/application/forms/IcingaImportObjectForm.php
+++ b/application/forms/IcingaImportObjectForm.php
@@ -26,7 +26,6 @@ class IcingaImportObjectForm extends QuickForm
$this->translate('Import external "%s"'),
$this->object->object_name
);
-
}
public function onSuccess()
diff --git a/application/forms/IcingaServiceForm.php b/application/forms/IcingaServiceForm.php
index 0370e005..bf09fbd1 100644
--- a/application/forms/IcingaServiceForm.php
+++ b/application/forms/IcingaServiceForm.php
@@ -93,7 +93,6 @@ class IcingaServiceForm extends DirectorObjectForm
$this->setSubmitLabel(
$this->translate('Override vars')
);
-
} else {
$this->addElementsToGroup(
array('inheritance_hint'),
@@ -360,8 +359,8 @@ class IcingaServiceForm extends DirectorObjectForm
'NOTE: only custom variables of type "Array" are eligible.'
)
));
-
}
+
return $this;
}
diff --git a/application/forms/IcingaTimePeriodForm.php b/application/forms/IcingaTimePeriodForm.php
index 01101f27..dca062f5 100644
--- a/application/forms/IcingaTimePeriodForm.php
+++ b/application/forms/IcingaTimePeriodForm.php
@@ -44,7 +44,6 @@ class IcingaTimePeriodForm extends DirectorObjectForm
'description' => $this->translate('the update method'),
'value' => 'LegacyTimePeriod',
));
-
} else {
// TODO: I'd like to skip this for objects inheriting from a template
// with a defined update_method. However, unfortunately it's too
diff --git a/application/forms/IcingaTimePeriodRangeForm.php b/application/forms/IcingaTimePeriodRangeForm.php
index 4df94434..cddadab0 100644
--- a/application/forms/IcingaTimePeriodRangeForm.php
+++ b/application/forms/IcingaTimePeriodRangeForm.php
@@ -31,7 +31,6 @@ class IcingaTimePeriodRangeForm extends DirectorObjectForm
));
$this->setButtons();
-
}
public function setTimePeriod(IcingaTimePeriod $period)
@@ -52,9 +51,9 @@ class IcingaTimePeriodRangeForm extends DirectorObjectForm
if ($this->period->hasBeenModified()) {
if (! $object->hasBeenLoadedFromDb()) {
-
$this->setHttpResponseCode(201);
}
+
$msg = sprintf(
$object->hasBeenLoadedFromDb()
? $this->translate('The %s has successfully been stored')
@@ -63,7 +62,6 @@ class IcingaTimePeriodRangeForm extends DirectorObjectForm
);
$this->period->store($this->db);
-
} else {
if ($this->isApiRequest()) {
$this->setHttpResponseCode(304);
diff --git a/application/forms/IcingaUserForm.php b/application/forms/IcingaUserForm.php
index 52aad1a8..5ff1ff44 100644
--- a/application/forms/IcingaUserForm.php
+++ b/application/forms/IcingaUserForm.php
@@ -29,7 +29,6 @@ class IcingaUserForm extends DirectorObjectForm
}
if (! $this->isTemplate()) {
-
$this->addElement('text', 'email', array(
'label' => $this->translate('Email'),
'description' => $this->translate('The Email address of the user.')
diff --git a/application/forms/IcingaUserGroupForm.php b/application/forms/IcingaUserGroupForm.php
index d98232e0..2aceaf9c 100644
--- a/application/forms/IcingaUserGroupForm.php
+++ b/application/forms/IcingaUserGroupForm.php
@@ -20,7 +20,6 @@ class IcingaUserGroupForm extends DirectorObjectForm
->addZoneElements()
->groupMainProperties()
->setButtons();
-
}
protected function addZoneElements()
diff --git a/application/forms/ImportCheckForm.php b/application/forms/ImportCheckForm.php
index 4af445fc..ae283051 100644
--- a/application/forms/ImportCheckForm.php
+++ b/application/forms/ImportCheckForm.php
@@ -33,7 +33,6 @@ class ImportCheckForm extends QuickForm
$this->setSuccessMessage(
$this->translate('This Import Source provides modified data')
);
-
} else {
$this->setSuccessMessage(
$this->translate(
diff --git a/application/forms/ImportRunForm.php b/application/forms/ImportRunForm.php
index 7054d90c..5764e387 100644
--- a/application/forms/ImportRunForm.php
+++ b/application/forms/ImportRunForm.php
@@ -33,7 +33,6 @@ class ImportRunForm extends QuickForm
$this->setSuccessMessage(
$this->translate('Imported new data from this Import Source')
);
-
} else {
$this->setSuccessMessage(
$this->translate(
diff --git a/application/forms/KickstartForm.php b/application/forms/KickstartForm.php
index eef6c27e..76733c07 100644
--- a/application/forms/KickstartForm.php
+++ b/application/forms/KickstartForm.php
@@ -39,7 +39,6 @@ class KickstartForm extends QuickForm
}
if (!$this->migrations()->hasSchema()) {
-
$this->addHtmlHint($this->translate(
'No database schema has been created yet'
), array('name' => 'HINT_schema'));
@@ -50,7 +49,6 @@ class KickstartForm extends QuickForm
}
if ($this->migrations()->hasPendingMigrations()) {
-
$this->addHtmlHint($this->translate(
'There are pending database migrations'
), array('name' => 'HINT_schema'));
@@ -182,7 +180,6 @@ class KickstartForm extends QuickForm
try {
$db->fetchOne('SELECT 1');
-
} catch (Exception $e) {
$this->getElement('resource')
->addError('Could not connect to database: ' . $e->getMessage());
diff --git a/application/forms/SyncCheckForm.php b/application/forms/SyncCheckForm.php
index 151477c9..c00104c2 100644
--- a/application/forms/SyncCheckForm.php
+++ b/application/forms/SyncCheckForm.php
@@ -62,6 +62,5 @@ class SyncCheckForm extends QuickForm
} else {
$this->addError($this->translate('Checking this sync rule failed'));
}
-
}
}
diff --git a/application/forms/SyncPropertyForm.php b/application/forms/SyncPropertyForm.php
index 64c6c0db..fa798c49 100644
--- a/application/forms/SyncPropertyForm.php
+++ b/application/forms/SyncPropertyForm.php
@@ -125,7 +125,6 @@ class SyncPropertyForm extends DirectorObjectForm
}
$this->setButtons();
-
}
protected function hasSubOption($options, $key)
diff --git a/application/tables/ActivityLogTable.php b/application/tables/ActivityLogTable.php
index e6a2e33e..a4f8c7e5 100644
--- a/application/tables/ActivityLogTable.php
+++ b/application/tables/ActivityLogTable.php
@@ -94,7 +94,6 @@ class ActivityLogTable extends QuickTable
'director/show/activitylog',
array_merge(array('id' => $row->id), $this->extraParams)
);
-
} else {
return false;
}
diff --git a/application/tables/IcingaServiceSetServiceTable.php b/application/tables/IcingaServiceSetServiceTable.php
index 38943f14..cc045e73 100644
--- a/application/tables/IcingaServiceSetServiceTable.php
+++ b/application/tables/IcingaServiceSetServiceTable.php
@@ -59,7 +59,6 @@ class IcingaServiceSetServiceTable extends QuickTable
);
return $this->url('director/host/servicesetservice', $params);
-
} else {
$params = array(
'name' => $row->service,
diff --git a/application/tables/IcingaServiceTable.php b/application/tables/IcingaServiceTable.php
index 8b5a66d9..5dcfb676 100644
--- a/application/tables/IcingaServiceTable.php
+++ b/application/tables/IcingaServiceTable.php
@@ -35,7 +35,6 @@ class IcingaServiceTable extends QuickTable
$params['id'] = $row->id;
} else {
$params = array('name' => $row->service);
-
}
return $this->url('director/service', $params);
@@ -56,7 +55,6 @@ class IcingaServiceTable extends QuickTable
array('class' => 'icon-plus')
);
}
-
} else {
$htm .= '. Related apply rules:
';
foreach ($extra as $service) {
diff --git a/application/tables/ImportsourceHookTable.php b/application/tables/ImportsourceHookTable.php
index 42964692..51166306 100644
--- a/application/tables/ImportsourceHookTable.php
+++ b/application/tables/ImportsourceHookTable.php
@@ -73,7 +73,6 @@ class ImportsourceHookTable extends QuickTable
public function fetchData()
{
if ($this->dataCache === null) {
-
$query = $this->getBaseQuery()->columns($this->getColumns());
if ($this->hasLimit() || $this->hasOffset()) {
diff --git a/application/views/helpers/FormExtensibleSet.php b/application/views/helpers/FormExtensibleSet.php
index 24844813..76304128 100644
--- a/application/views/helpers/FormExtensibleSet.php
+++ b/application/views/helpers/FormExtensibleSet.php
@@ -75,7 +75,6 @@ class Zend_View_Helper_FormExtensibleSet extends Zend_View_Helper_FormElement
$total = count($value);
foreach ($value as $val) {
-
if ($multiOptions !== null) {
if (in_array($val, $validOptions)) {
$multiOptions = $this->removeOption($multiOptions, $val);
@@ -129,7 +128,6 @@ class Zend_View_Helper_FormExtensibleSet extends Zend_View_Helper_FormElement
$elements[] = $htm;
}
} else {
-
$elements[] = '= 4.8",
- "icinga/icingaweb2": ">= 2.3",
- "squizlabs/php_codesniffer": ">= 2"
- },
- "autoload": {
- "psr-4": {
- "Icinga\\Module\\Director\\": "library/Director/"
- }
- },
- "repositories": [
- {
- "type": "package",
- "package": {
- "name": "icinga/icingaweb2",
- "version": "2.4.0",
- "dist": {
- "url": "https://github.com/Icinga/icingaweb2/archive/v2.4.0.zip",
- "type": "zip"
- },
- "source": {
- "url": "https://github.com/Icinga/icingaweb2.git",
- "type": "git",
- "reference": "master"
- }
- }
- }
- ]
-}
diff --git a/library/Director/Core/RestApiClient.php b/library/Director/Core/RestApiClient.php
index b95692f1..889a2c1d 100644
--- a/library/Director/Core/RestApiClient.php
+++ b/library/Director/Core/RestApiClient.php
@@ -135,7 +135,6 @@ class RestApiClient
if (! $raw) {
$headers[] = 'Accept: application/json';
-
}
if ($body !== null) {
diff --git a/library/Director/CustomVariable/CustomVariable.php b/library/Director/CustomVariable/CustomVariable.php
index 2d0761b8..d0a0a717 100644
--- a/library/Director/CustomVariable/CustomVariable.php
+++ b/library/Director/CustomVariable/CustomVariable.php
@@ -214,11 +214,8 @@ abstract class CustomVariable implements IcingaConfigRenderer
}
if (is_string($value)) {
-
return new CustomVariableString($key, $value);
-
} elseif (is_array($value)) {
-
foreach (array_keys($value) as $k) {
if (! (is_int($k) || ctype_digit($k))) {
return new CustomVariableDictionary($key, $value);
@@ -226,11 +223,9 @@ abstract class CustomVariable implements IcingaConfigRenderer
}
return new CustomVariableArray($key, array_values($value));
-
} elseif (is_object($value)) {
// TODO: check for specific class/stdClass/interface?
return new CustomVariableDictionary($key, $value);
-
} else {
throw new ProgrammingError('WTF (%s): %s', $key, var_export($value, 1));
}
diff --git a/library/Director/Dashboard/Dashlet/Dashlet.php b/library/Director/Dashboard/Dashlet/Dashlet.php
index 8c950326..84af868e 100644
--- a/library/Director/Dashboard/Dashlet/Dashlet.php
+++ b/library/Director/Dashboard/Dashlet/Dashlet.php
@@ -246,7 +246,6 @@ abstract class Dashlet
} else {
$msg = $view->translate('One object has been defined');
}
-
} else {
$msg = sprintf(
$view->translate('%d objects have been defined'),
@@ -256,13 +255,13 @@ abstract class Dashlet
$extra = array();
if ($stat->cnt_total !== $stat->cnt_object) {
-
if ($stat->cnt_template > 0) {
$extra[] = sprintf(
$view->translate('%d of them are templates'),
$stat->cnt_template
);
}
+
if ($stat->cnt_external > 0) {
$extra[] = sprintf(
$view->translate(
diff --git a/library/Director/Dashboard/Dashlet/DeploymentDashlet.php b/library/Director/Dashboard/Dashlet/DeploymentDashlet.php
index 6e8e5e94..7a527933 100644
--- a/library/Director/Dashboard/Dashlet/DeploymentDashlet.php
+++ b/library/Director/Dashboard/Dashlet/DeploymentDashlet.php
@@ -90,7 +90,6 @@ class DeploymentDashlet extends Dashlet
if ($cnt === 0) {
$msgs[] = $this->translate('There are no pending changes');
} else {
-
$msgs[] = sprintf(
$this->translate(
'A total of %d config changes happened since your last'
diff --git a/library/Director/Data/Db/DbObject.php b/library/Director/Data/Db/DbObject.php
index 11b71822..14f02ed2 100644
--- a/library/Director/Data/Db/DbObject.php
+++ b/library/Director/Data/Db/DbObject.php
@@ -579,7 +579,6 @@ abstract class DbObject
$properties = $this->db->fetchRow($select);
if (empty($properties)) {
-
if (is_array($this->getKeyName())) {
throw new NotFoundError(
'Failed to load %s for %s',
@@ -654,7 +653,6 @@ abstract class DbObject
$properties,
$this->createWhere()
);
-
}
/**
@@ -749,7 +747,6 @@ abstract class DbObject
);
}
}
-
} catch (Exception $e) {
if ($e instanceof IE) {
throw $e;
@@ -1001,7 +998,6 @@ abstract class DbObject
self::$prefetchStats[$class]->miss++;
return false;
}
-
} else {
self::$prefetchStats[$class]->miss++;
return false;
diff --git a/library/Director/Data/Db/DbObjectWithSettings.php b/library/Director/Data/Db/DbObjectWithSettings.php
index 0d047ebe..39cb05fb 100644
--- a/library/Director/Data/Db/DbObjectWithSettings.php
+++ b/library/Director/Data/Db/DbObjectWithSettings.php
@@ -124,7 +124,6 @@ abstract class DbObjectWithSettings extends DbObject
->from($this->settingsTable, array('setting_name', 'setting_value'))
->where($this->settingsRemoteId . ' = ?', $this->get('id'))
);
-
}
protected function onLoadFromDb()
diff --git a/library/Director/Data/Db/IcingaObjectQuery.php b/library/Director/Data/Db/IcingaObjectQuery.php
index cf8bba69..8bd58a82 100644
--- a/library/Director/Data/Db/IcingaObjectQuery.php
+++ b/library/Director/Data/Db/IcingaObjectQuery.php
@@ -221,7 +221,6 @@ class IcingaObjectQuery
if (! $this->hasAlias($alias . $cnt)) {
return $alias . $cnt;
}
-
} while (! $this->hasAlias($alias));
return $alias;
diff --git a/library/Director/Db/Cache/CustomVariableCache.php b/library/Director/Db/Cache/CustomVariableCache.php
index 517a1bfd..ea6ff090 100644
--- a/library/Director/Db/Cache/CustomVariableCache.php
+++ b/library/Director/Db/Cache/CustomVariableCache.php
@@ -41,7 +41,6 @@ class CustomVariableCache
);
foreach ($db->fetchAll($query) as $row) {
-
$id = $row->id;
unset($row->id);
diff --git a/library/Director/Db/Migration.php b/library/Director/Db/Migration.php
index bc7aa6d0..6842c75e 100644
--- a/library/Director/Db/Migration.php
+++ b/library/Director/Db/Migration.php
@@ -46,9 +46,7 @@ class Migration
$db->exec($query);
}
}
-
} catch (Exception $e) {
-
throw new IcingaException(
'Migration %d failed (%s) while running %s',
$this->version,
diff --git a/library/Director/IcingaConfig/AssignRenderer.php b/library/Director/IcingaConfig/AssignRenderer.php
index ae17fa3e..e0c58495 100644
--- a/library/Director/IcingaConfig/AssignRenderer.php
+++ b/library/Director/IcingaConfig/AssignRenderer.php
@@ -92,7 +92,6 @@ class AssignRenderer
$column,
$expression
);
-
} elseif ($filter instanceof FilterMatch) {
if (strpos($expression, '*') === false) {
return $this->renderEquals($column, $expression);
@@ -103,7 +102,6 @@ class AssignRenderer
$column
);
}
-
} elseif ($filter instanceof FilterMatchNot) {
if (strpos($expression, '*') === false) {
return sprintf(
@@ -118,42 +116,36 @@ class AssignRenderer
$column
);
}
-
} elseif ($filter instanceof FilterNotEqual) {
- return sprintf(
- '%s != %s',
- $column,
- $expression
- );
-
+ return sprintf(
+ '%s != %s',
+ $column,
+ $expression
+ );
} elseif ($filter instanceof FilterEqualOrGreaterThan) {
- return sprintf(
- '%s >= %s',
- $column,
- $expression
- );
-
+ return sprintf(
+ '%s >= %s',
+ $column,
+ $expression
+ );
} elseif ($filter instanceof FilterEqualOrLessThan) {
- return sprintf(
- '%s <= %s',
- $column,
- $expression
- );
-
+ return sprintf(
+ '%s <= %s',
+ $column,
+ $expression
+ );
} elseif ($filter instanceof FilterGreaterThan) {
- return sprintf(
- '%s > %s',
- $column,
- $expression
- );
-
+ return sprintf(
+ '%s > %s',
+ $column,
+ $expression
+ );
} elseif ($filter instanceof FilterLessThan) {
- return sprintf(
- '%s < %s',
- $column,
- $expression
- );
-
+ return sprintf(
+ '%s < %s',
+ $column,
+ $expression
+ );
} else {
throw new QueryException(
'Filter expression of type "%s" is not supported',
diff --git a/library/Director/IcingaConfig/ExtensibleSet.php b/library/Director/IcingaConfig/ExtensibleSet.php
index 69155832..694e61fe 100644
--- a/library/Director/IcingaConfig/ExtensibleSet.php
+++ b/library/Director/IcingaConfig/ExtensibleSet.php
@@ -61,8 +61,8 @@ class ExtensibleSet
{
if (null === $set) {
$this->reset();
- return $this;
+ return $this;
} elseif (is_array($set) || is_string($set)) {
$this->reset();
$this->override($set);
diff --git a/library/Director/IcingaConfig/IcingaConfig.php b/library/Director/IcingaConfig/IcingaConfig.php
index 88a57f89..2a87f441 100644
--- a/library/Director/IcingaConfig/IcingaConfig.php
+++ b/library/Director/IcingaConfig/IcingaConfig.php
@@ -457,7 +457,6 @@ class IcingaConfig
ini_set('zend.enable_gc', 0);
if (! $this->connection->isPgsql() && $this->db->quote("1\0") !== '\'1\\0\'') {
-
throw new IcingaException(
'Refusing to render the configuration, your DB layer corrupts binary data.'
. ' You might be affected by Zend Framework bug #655'
diff --git a/library/Director/IcingaConfig/IcingaConfigHelper.php b/library/Director/IcingaConfig/IcingaConfigHelper.php
index 1c219e83..807b6776 100644
--- a/library/Director/IcingaConfig/IcingaConfigHelper.php
+++ b/library/Director/IcingaConfig/IcingaConfigHelper.php
@@ -158,7 +158,6 @@ class IcingaConfigHelper
// Prefix for toConfigString?
return "{\n" . implode("\n", $vals) . "\n}";
-
}
public static function renderExpression($string)
diff --git a/library/Director/Import/Import.php b/library/Director/Import/Import.php
index 05847a41..5d4356c2 100644
--- a/library/Director/Import/Import.php
+++ b/library/Director/Import/Import.php
@@ -287,7 +287,6 @@ class Import
$db->beginTransaction();
try {
-
if ($this->isEmpty()) {
$newRows = array();
$newProperties = array();
diff --git a/library/Director/Import/Sync.php b/library/Director/Import/Sync.php
index 42f0503c..ded11aa1 100644
--- a/library/Director/Import/Sync.php
+++ b/library/Director/Import/Sync.php
@@ -276,9 +276,7 @@ class Sync
json_encode($row)
);
}
-
} else {
-
if (! property_exists($row, $key)) {
throw new IcingaException(
'There is no key column "%s" in this row from "%s": %s',
@@ -287,7 +285,6 @@ class Sync
json_encode($row)
);
}
-
}
if (! $this->rule->matches($row)) {
@@ -339,7 +336,6 @@ class Sync
{
// TODO: Make object_type (template, object...) and object_name mandatory?
if ($this->rule->hasCombinedKey()) {
-
$this->objects = array();
$destinationKeyPattern = $this->rule->getDestinationKeyPattern();
@@ -347,7 +343,6 @@ class Sync
$this->rule->object_type,
$this->db
) as $object) {
-
if ($object instanceof IcingaService) {
if (strstr($destinationKeyPattern, '${host}') && $object->host_id === null) {
continue;
@@ -608,9 +603,9 @@ class Sync
$this->run->set('duration_ms', (int) round(
(microtime(true) - $this->runStartTime) * 1000
))->store();
-
} catch (Exception $e) {
$dba->rollBack();
+
if ($object !== null && $object instanceof IcingaObject) {
throw new IcingaException(
'Exception while syncing %s %s: %s',
diff --git a/library/Director/Job/ConfigJob.php b/library/Director/Job/ConfigJob.php
index 4f80d4f3..f89c666f 100644
--- a/library/Director/Job/ConfigJob.php
+++ b/library/Director/Job/ConfigJob.php
@@ -114,7 +114,6 @@ class ConfigJob extends JobHook
} catch (Exception $e) {
// Ignore those errors, Icinga may be reloading
}
-
} else {
throw new IcingaException('Failed to deploy config "%s"', $checksum);
}
@@ -129,7 +128,6 @@ class ConfigJob extends JobHook
{
if ($this->isWithinGracePeriod()) {
if ($deployment = $this->lastDeployment()) {
-
return $deployment->getDeploymentTimestamp()
+ $this->getSetting('grace_period')
- time();
diff --git a/library/Director/KickstartHelper.php b/library/Director/KickstartHelper.php
index 9bc84cdc..5b9ee371 100644
--- a/library/Director/KickstartHelper.php
+++ b/library/Director/KickstartHelper.php
@@ -112,7 +112,6 @@ class KickstartHelper
protected function apiUser()
{
if ($this->apiUser === null) {
-
$name = $this->getValue('username');
$user = IcingaApiUser::create(array(
@@ -217,7 +216,6 @@ class KickstartHelper
$endpoints = array();
foreach ($this->api()->setDb($db)->getEndpointObjects() as $object) {
-
if ($object->object_name === $master) {
$apiuser = $this->apiUser();
$apiuser->store();
@@ -257,7 +255,6 @@ class KickstartHelper
try {
$this->switchToDeploymentApi()->getStatus();
} catch (Exception $e) {
-
throw new ConfigurationError(
'I was unable to re-establish a connection to the Endpoint "%s" (%s:%d).'
. ' When reconnecting to the configured Endpoint (%s:%d) I get an error: %s'
diff --git a/library/Director/Objects/IcingaHostGroup.php b/library/Director/Objects/IcingaHostGroup.php
index bf5bced6..faa2879a 100644
--- a/library/Director/Objects/IcingaHostGroup.php
+++ b/library/Director/Objects/IcingaHostGroup.php
@@ -55,7 +55,6 @@ class IcingaHostGroup extends IcingaObjectGroup
$file = $this->legacyZoneHostgroupFile($config);
$this->properties['members'] = array();
$file->addLegacyObject($this);
-
} else {
$allMembers = array();
diff --git a/library/Director/Objects/IcingaNotification.php b/library/Director/Objects/IcingaNotification.php
index 0677fce2..2ae5c881 100644
--- a/library/Director/Objects/IcingaNotification.php
+++ b/library/Director/Objects/IcingaNotification.php
@@ -151,7 +151,6 @@ class IcingaNotification extends IcingaObject
c::renderString($this->getObjectName()),
ucfirst($to)
);
-
} else {
return parent::renderObjectHeader();
}
diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php
index c0e80a84..b5312263 100644
--- a/library/Director/Objects/IcingaObject.php
+++ b/library/Director/Objects/IcingaObject.php
@@ -2378,7 +2378,6 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
}
foreach ($p as $k => $v) {
-
// Do not ship ids for IcingaObjects:
if ($resolveIds) {
if ($k === 'id' && $this->hasProperty('object_name')) {
@@ -2389,7 +2388,6 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
$relKey = substr($k, 0, -3);
if ($this->hasRelation($relKey)) {
-
if ($this->hasUnresolvedRelatedProperty($k)) {
$v = $this->$relKey;
} elseif ($v !== null) {
@@ -2419,7 +2417,6 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
} else {
$props[$k] = $v;
}
-
} else {
$props[$k] = $v;
}
diff --git a/library/Director/Objects/IcingaObjectGroups.php b/library/Director/Objects/IcingaObjectGroups.php
index e78c31a9..f29209dd 100644
--- a/library/Director/Objects/IcingaObjectGroups.php
+++ b/library/Director/Objects/IcingaObjectGroups.php
@@ -96,7 +96,6 @@ class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer
$unset = array();
foreach ($group as $k => $g) {
-
if ($g instanceof $class) {
$new[] = $g->object_name;
} else {
@@ -174,10 +173,9 @@ class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer
if ($group instanceof $class) {
$this->groups[$group->object_name] = $group;
-
} elseif (is_string($group)) {
-
$connection = $this->object->getConnection();
+
try {
$this->groups[$group] = $class::load($group, $connection);
} catch (NotFoundError $e) {
diff --git a/library/Director/Objects/IcingaObjectImports.php b/library/Director/Objects/IcingaObjectImports.php
index ffc440e5..470578af 100644
--- a/library/Director/Objects/IcingaObjectImports.php
+++ b/library/Director/Objects/IcingaObjectImports.php
@@ -118,8 +118,8 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer
{
$list = array();
$class = $this->getImportClass();
- foreach ($imports as $i) {
+ foreach ($imports as $i) {
if ($i instanceof $class) {
$list[] = $i->object_name;
} else {
diff --git a/library/Director/Objects/IcingaObjectMultiRelations.php b/library/Director/Objects/IcingaObjectMultiRelations.php
index 0d0a1a54..47692357 100644
--- a/library/Director/Objects/IcingaObjectMultiRelations.php
+++ b/library/Director/Objects/IcingaObjectMultiRelations.php
@@ -110,7 +110,6 @@ class IcingaObjectMultiRelations implements Iterator, Countable, IcingaConfigRen
$unset = array();
foreach ($relation as $k => $ro) {
-
if ($ro instanceof $class) {
$new[] = $ro->object_name;
} else {
@@ -187,9 +186,7 @@ class IcingaObjectMultiRelations implements Iterator, Countable, IcingaConfigRen
if ($relation instanceof $class) {
$this->relations[$relation->object_name] = $relation;
-
} elseif (is_string($relation)) {
-
$connection = $this->object->getConnection();
try {
// Related services can only be objects, used by ServiceSets
@@ -202,7 +199,6 @@ class IcingaObjectMultiRelations implements Iterator, Countable, IcingaConfigRen
$relation = $class::load($relation, $connection);
}
} catch (Exception $e) {
-
switch ($onError) {
case 'autocreate':
$relation = $class::create(array(
diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php
index 124ff59f..be92533c 100644
--- a/library/Director/Objects/IcingaService.php
+++ b/library/Director/Objects/IcingaService.php
@@ -260,8 +260,8 @@ class IcingaService extends IcingaObject
{
if ($this->isApplyRule()
&& !$this->hasBeenAssignedToHostTemplate()
- && $this->get('apply_for') !== null) {
-
+ && $this->get('apply_for') !== null
+ ) {
$name = $this->getObjectName();
$extraName = '';
@@ -280,6 +280,7 @@ class IcingaService extends IcingaObject
$this->get('apply_for')
) . $extraName;
}
+
return parent::renderObjectHeader();
}
diff --git a/library/Director/Objects/IcingaServiceSet.php b/library/Director/Objects/IcingaServiceSet.php
index dd694194..025bfb2b 100644
--- a/library/Director/Objects/IcingaServiceSet.php
+++ b/library/Director/Objects/IcingaServiceSet.php
@@ -169,7 +169,7 @@ class IcingaServiceSet extends IcingaObject
return sprintf($comment, $this->getObjectName());
}
- protected function copyVarsToService(IcingaService $service)
+ public function copyVarsToService(IcingaService $service)
{
$serviceVars = $service->vars();
@@ -208,7 +208,6 @@ class IcingaServiceSet extends IcingaObject
}
}
} else {
-
foreach ($this->getServiceObjects() as $service) {
$service->set('object_type', 'object');
$service->set('host_id', $this->get('host_id'));
diff --git a/library/Director/Objects/IcingaTemplateResolver.php b/library/Director/Objects/IcingaTemplateResolver.php
index 63155c7b..43d490d7 100644
--- a/library/Director/Objects/IcingaTemplateResolver.php
+++ b/library/Director/Objects/IcingaTemplateResolver.php
@@ -86,7 +86,6 @@ class IcingaTemplateResolver
$object = $this->object;
if ($object->hasBeenLoadedFromDb()) {
-
if ($object->gotImports() && $object->imports()->hasBeenModified()) {
return $this->listUnstoredParentIds();
}
@@ -121,11 +120,9 @@ class IcingaTemplateResolver
$this->requireTemplates();
if ($name === null) {
-
$object = $this->object;
if ($object->hasBeenLoadedFromDb()) {
-
if ($object->gotImports() && $object->imports()->hasBeenModified()) {
return $this->listUnstoredParentNames();
}
diff --git a/library/Director/Objects/ImportSource.php b/library/Director/Objects/ImportSource.php
index e360bf28..11013f7f 100644
--- a/library/Director/Objects/ImportSource.php
+++ b/library/Director/Objects/ImportSource.php
@@ -213,7 +213,6 @@ class ImportSource extends DbObjectWithSettings
}
$this->last_error_message = null;
-
} catch (Exception $e) {
$this->import_state = 'failing';
Benchmark::measure('Import failed for ' . $this->source_name);
diff --git a/library/Director/Objects/SyncRule.php b/library/Director/Objects/SyncRule.php
index 3d32deea..42d9a296 100644
--- a/library/Director/Objects/SyncRule.php
+++ b/library/Director/Objects/SyncRule.php
@@ -154,7 +154,6 @@ class SyncRule extends DbObject
}
$hadChanges = true;
-
} else {
Benchmark::measure('No modifications for sync rule ' . $this->get('rule_name'));
$this->set('sync_state', 'in-sync');
@@ -255,7 +254,6 @@ class SyncRule extends DbObject
public function hasCombinedKey()
{
if ($this->hasCombinedKey === null) {
-
$this->hasCombinedKey = false;
// TODO: Move to Objects
@@ -341,7 +339,6 @@ class SyncRule extends DbObject
$this->destinationKeyPattern = '${list_id}!${entry_name}';
}
-
}
}
diff --git a/library/Director/StartupLogRenderer.php b/library/Director/StartupLogRenderer.php
index 5e19b1c3..69360c58 100644
--- a/library/Director/StartupLogRenderer.php
+++ b/library/Director/StartupLogRenderer.php
@@ -18,8 +18,8 @@ class StartupLogRenderer
$markPattern = null;
// len [stage] + 1
$markReplace = ' ^';
- foreach (preg_split('/\n/', $log) as $line) {
+ foreach (preg_split('/\n/', $log) as $line) {
if (preg_match($sevPattern, $line, $m)) {
$severity = $m[1];
$line = preg_replace(
diff --git a/library/Director/Test/Bootstrap.php b/library/Director/Test/Bootstrap.php
new file mode 100644
index 00000000..56bd85ae
--- /dev/null
+++ b/library/Director/Test/Bootstrap.php
@@ -0,0 +1,28 @@
+getModuleManager()
+ ->loadModule('director', $basedir);
+ }
+}
diff --git a/library/Director/Test/TestSuiteStyle.php b/library/Director/Test/TestSuiteStyle.php
index f88fbada..babd43c5 100644
--- a/library/Director/Test/TestSuiteStyle.php
+++ b/library/Director/Test/TestSuiteStyle.php
@@ -62,6 +62,5 @@ class TestSuiteStyle extends TestSuite
echo $out ."\n";
echo file_get_contents($out);
unlink($out);
-
}
}
diff --git a/library/Director/Web/Controller/ActionController.php b/library/Director/Web/Controller/ActionController.php
index 8c05f775..8bef370e 100644
--- a/library/Director/Web/Controller/ActionController.php
+++ b/library/Director/Web/Controller/ActionController.php
@@ -265,7 +265,6 @@ abstract class ActionController extends Controller
$filter = $filterEditor->getFilter();
if ($filter->isEmpty()) {
-
if ($this->params->get('modifyFilter')) {
$this->view->addLink .= ' ' . $this->view->qlink(
$this->translate('Show unfiltered'),
@@ -287,9 +286,7 @@ abstract class ActionController extends Controller
)
);
}
-
} else {
-
$this->view->addLink .= ' ' . $this->view->qlink(
$this->shorten($filter, 32),
$this->getRequest()->getUrl()->with('modifyFilter', true),
diff --git a/library/Director/Web/Controller/ObjectController.php b/library/Director/Web/Controller/ObjectController.php
index 9119c5a6..22003ecb 100644
--- a/library/Director/Web/Controller/ObjectController.php
+++ b/library/Director/Web/Controller/ObjectController.php
@@ -282,7 +282,6 @@ abstract class ObjectController extends ActionController
null,
array('class' => 'icon-left-big')
);
-
}
$form->handleRequest();
diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php
index 3e402fcc..f898de12 100644
--- a/library/Director/Web/Form/DirectorObjectForm.php
+++ b/library/Director/Web/Form/DirectorObjectForm.php
@@ -479,11 +479,10 @@ abstract class DirectorObjectForm extends QuickForm
{
$object = $this->object();
if ($object->hasBeenModified()) {
-
if (! $object->hasBeenLoadedFromDb()) {
-
$this->setHttpResponseCode(201);
}
+
$msg = sprintf(
$object->hasBeenLoadedFromDb()
? $this->translate('The %s has successfully been stored')
@@ -603,7 +602,6 @@ abstract class DirectorObjectForm extends QuickForm
$post = $values = $this->getRequest()->getPost();
foreach ($post as $key => $value) {
-
if (preg_match('/^(.+?)_(\d+)__(MOVE_DOWN|MOVE_UP|REMOVE)$/', $key, $m)) {
$values[$m[1]] = array_filter($values[$m[1]], 'strlen');
switch ($m[3]) {
@@ -779,7 +777,6 @@ abstract class DirectorObjectForm extends QuickForm
if (!$this->hasObject()) {
if ($this->hasBeenSent()) {
-
return $this->getSentValue($name, $default);
} else {
if ($this->valueIsEmpty($val = $this->getValue($name))) {
@@ -1105,8 +1102,8 @@ abstract class DirectorObjectForm extends QuickForm
);
$periods = $this->db->enumTimeperiods();
- if (!empty($periods)) {
+ if (!empty($periods)) {
$this->addElement(
'select',
'check_period_id',
diff --git a/library/Director/Web/Form/Element/DataFilter.php b/library/Director/Web/Form/Element/DataFilter.php
index a85a54c1..ee9aa077 100644
--- a/library/Director/Web/Form/Element/DataFilter.php
+++ b/library/Director/Web/Form/Element/DataFilter.php
@@ -61,7 +61,6 @@ class DataFilter extends FormElement
} else {
$value = $this->arrayToFilter($value);
}
-
} catch (Exception $e) {
$value = null;
// TODO: getFile, getLine
diff --git a/library/Director/Web/Form/IcingaObjectFieldLoader.php b/library/Director/Web/Form/IcingaObjectFieldLoader.php
index 63ae9987..4d7b7a43 100644
--- a/library/Director/Web/Form/IcingaObjectFieldLoader.php
+++ b/library/Director/Web/Form/IcingaObjectFieldLoader.php
@@ -223,7 +223,6 @@ class IcingaObjectFieldLoader
$filters = array();
foreach ($this->fields as $key => $field) {
if ($filter = $field->var_filter) {
-
$filters[$key] = Filter::fromQueryString($filter);
}
}
diff --git a/library/Director/Web/Form/QuickForm.php b/library/Director/Web/Form/QuickForm.php
index 83d486e2..728d4fe7 100644
--- a/library/Director/Web/Form/QuickForm.php
+++ b/library/Director/Web/Form/QuickForm.php
@@ -149,8 +149,8 @@ abstract class QuickForm extends QuickBaseForm
'Fieldset',
);
}
- return $this->addDisplayGroup($elements, $name, $options);
+ return $this->addDisplayGroup($elements, $name, $options);
}
protected function createIdElement()
diff --git a/library/Director/Web/Table/QuickTable.php b/library/Director/Web/Table/QuickTable.php
index 69c69ea4..d4a90496 100644
--- a/library/Director/Web/Table/QuickTable.php
+++ b/library/Director/Web/Table/QuickTable.php
@@ -114,7 +114,6 @@ abstract class QuickTable implements Paginatable
$firstCol = true;
foreach ($this->getTitles() as $key => $title) {
-
// Support missing columns
if (property_exists($row, $key)) {
$val = $row->$key;
diff --git a/test/bootstrap.php b/test/bootstrap.php
index 88c39cab..849af319 100644
--- a/test/bootstrap.php
+++ b/test/bootstrap.php
@@ -1,39 +1,9 @@
getModuleManager()
- ->loadModule('director', $base);
+ $basedir = dirname(__DIR__);
+ require_once $basedir . '/library/Director/Test/Bootstrap.php';
+ Bootstrap::cli($basedir);
});
diff --git a/test/php/library/Director/Objects/IcingaHostTest.php b/test/php/library/Director/Objects/IcingaHostTest.php
index 6eab4c92..fa08a74a 100644
--- a/test/php/library/Director/Objects/IcingaHostTest.php
+++ b/test/php/library/Director/Objects/IcingaHostTest.php
@@ -724,7 +724,6 @@ class IcingaHostTest extends BaseTestCase
foreach (DirectorDatafield::loadAll($db, $query, 'id') as $datafield) {
$datafield->delete();
}
-
}
}
}