From 7b488d7f935efadb6075b42bda691540890fc2f4 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 4 Dec 2019 11:01:35 +0100 Subject: [PATCH] swag: Fix violations of PSR-12 PSR-2 has been deprecated and phpcs v3.5.3 now checks for the successor PSR-12 --- application/forms/Config/ResourceConfigForm.php | 2 +- application/forms/Config/UserBackendConfigForm.php | 4 ++-- application/forms/Config/UserGroup/UserGroupBackendForm.php | 2 +- application/forms/Security/RoleForm.php | 2 +- library/Icinga/Application/Web.php | 2 +- library/Icinga/Chart/Donut.php | 4 +++- library/Icinga/Repository/IniRepository.php | 2 +- library/Icinga/Util/Format.php | 2 +- library/Icinga/Web/Form.php | 2 +- library/Icinga/Web/Form/Decorator/FormHints.php | 2 +- .../monitoring/application/forms/Setup/IdoResourcePage.php | 2 +- modules/monitoring/library/Monitoring/Cli/CliUtils.php | 2 +- modules/monitoring/library/Monitoring/MonitoringWizard.php | 5 ++++- modules/setup/application/forms/AuthBackendPage.php | 2 +- modules/setup/application/forms/LdapResourcePage.php | 2 +- .../library/Translation/Cli/ArrayToTextTableHelper.php | 3 +-- 16 files changed, 22 insertions(+), 18 deletions(-) diff --git a/application/forms/Config/ResourceConfigForm.php b/application/forms/Config/ResourceConfigForm.php index 95316aa92..dc3565ed5 100644 --- a/application/forms/Config/ResourceConfigForm.php +++ b/application/forms/Config/ResourceConfigForm.php @@ -320,7 +320,7 @@ class ResourceConfigForm extends ConfigForm if ($this->getElement('resource_validation')->isChecked() && parent::isValid($formData)) { $inspection = static::inspectResource($this); if ($inspection !== null) { - $join = function ($e) use (& $join) { + $join = function ($e) use (&$join) { return is_string($e) ? $e : join("\n", array_map($join, $e)); }; $this->addElement( diff --git a/application/forms/Config/UserBackendConfigForm.php b/application/forms/Config/UserBackendConfigForm.php index a911b7f21..16ce4bdf9 100644 --- a/application/forms/Config/UserBackendConfigForm.php +++ b/application/forms/Config/UserBackendConfigForm.php @@ -69,7 +69,7 @@ class UserBackendConfigForm extends ConfigForm $externalBackends = $this->config->toArray(); array_walk( $externalBackends, - function (& $authBackendCfg) { + function (&$authBackendCfg) { if (! isset($authBackendCfg['backend']) || $authBackendCfg['backend'] !== 'external') { $authBackendCfg = null; } @@ -397,7 +397,7 @@ class UserBackendConfigForm extends ConfigForm if ($this->getElement('backend_validation')->isChecked() && parent::isValid($formData)) { $inspection = static::inspectUserBackend($this); if ($inspection !== null) { - $join = function ($e) use (& $join) { + $join = function ($e) use (&$join) { return is_string($e) ? $e : join("\n", array_map($join, $e)); }; $this->addElement( diff --git a/application/forms/Config/UserGroup/UserGroupBackendForm.php b/application/forms/Config/UserGroup/UserGroupBackendForm.php index 30a889214..68e5ec6b2 100644 --- a/application/forms/Config/UserGroup/UserGroupBackendForm.php +++ b/application/forms/Config/UserGroup/UserGroupBackendForm.php @@ -229,7 +229,7 @@ class UserGroupBackendForm extends ConfigForm if (isset($formData['backend_validation']) && parent::isValid($formData)) { $inspection = static::inspectUserBackend($this); if ($inspection !== null) { - $join = function ($e) use (& $join) { + $join = function ($e) use (&$join) { return is_string($e) ? $e : join("\n", array_map($join, $e)); }; $this->addElement( diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index cb517f178..0f7c7a1d2 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -350,7 +350,7 @@ class RoleForm extends RepositoryForm return $success ? $this->translate('Role removed') : $this->translate('Role removal failed'); } - protected function sortPermissions(& $permissions) + protected function sortPermissions(&$permissions) { return uasort($permissions, function ($a, $b) { if (isset($a['isUsagePerm'])) { diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index bb9809479..35ce813b4 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -170,7 +170,7 @@ class Web extends EmbeddedWeb return $this->viewRenderer; } - private function hasAccessToSharedNavigationItem(& $config, Config $navConfig) + private function hasAccessToSharedNavigationItem(&$config, Config $navConfig) { // TODO: Provide a more sophisticated solution diff --git a/library/Icinga/Chart/Donut.php b/library/Icinga/Chart/Donut.php index d509a3356..887462f6c 100644 --- a/library/Icinga/Chart/Donut.php +++ b/library/Icinga/Chart/Donut.php @@ -297,7 +297,9 @@ class Donut 'r' => sprintf('%F', $this->radius), 'fill' => 'transparent', 'stroke-width' => $this->getThickness(), - 'stroke-dasharray' => sprintf('%F', $slice[0]) . ' ' . sprintf('%F', (99.9 - $slice[0])), // 99.9 prevents gaps (slight overlap) + 'stroke-dasharray' => sprintf('%F', $slice[0]) + . ' ' + . sprintf('%F', (99.9 - $slice[0])), // 99.9 prevents gaps (slight overlap) 'stroke-dashoffset' => sprintf('%F', $offset) ) ); diff --git a/library/Icinga/Repository/IniRepository.php b/library/Icinga/Repository/IniRepository.php index e2931c1a5..7385b3e64 100644 --- a/library/Icinga/Repository/IniRepository.php +++ b/library/Icinga/Repository/IniRepository.php @@ -405,7 +405,7 @@ abstract class IniRepository extends Repository implements Extensible, Updatable * * @throws ProgrammingError In case no valid section name is available */ - protected function extractSectionName(& $config, $keyColumn) + protected function extractSectionName(&$config, $keyColumn) { if (! is_array($config) && !$config instanceof ConfigObject) { throw new ProgrammingError('$config is neither an array nor a ConfigObject'); diff --git a/library/Icinga/Util/Format.php b/library/Icinga/Util/Format.php index 79839b825..7808af5cf 100644 --- a/library/Icinga/Util/Format.php +++ b/library/Icinga/Util/Format.php @@ -68,7 +68,7 @@ class Format return sprintf('%0.2f d', $value / 86400); } - protected static function formatForUnits($value, & $units, $base) + protected static function formatForUnits($value, &$units, $base) { $sign = ''; if ($value < 0) { diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index a2ad8f984..e68c63eff 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -1120,7 +1120,7 @@ class Form extends Zend_Form * @param Zend_Form $form * @param array $defaults */ - protected function preserveDefaults(Zend_Form $form, array & $defaults) + protected function preserveDefaults(Zend_Form $form, array &$defaults) { foreach ($form->getElements() as $name => $element) { if ((array_key_exists($name, $defaults) diff --git a/library/Icinga/Web/Form/Decorator/FormHints.php b/library/Icinga/Web/Form/Decorator/FormHints.php index 58418b241..797be26c2 100644 --- a/library/Icinga/Web/Form/Decorator/FormHints.php +++ b/library/Icinga/Web/Form/Decorator/FormHints.php @@ -95,7 +95,7 @@ class FormHints extends Zend_Form_Decorator_Abstract * * @return array */ - protected function recurseForm(Form $form, & $entirelyRequired = null, $elementsPassed = false) + protected function recurseForm(Form $form, &$entirelyRequired = null, $elementsPassed = false) { $requiredLabels = array(); if ($form->getRequiredCue() !== null) { diff --git a/modules/monitoring/application/forms/Setup/IdoResourcePage.php b/modules/monitoring/application/forms/Setup/IdoResourcePage.php index cc754a794..d648579b1 100644 --- a/modules/monitoring/application/forms/Setup/IdoResourcePage.php +++ b/modules/monitoring/application/forms/Setup/IdoResourcePage.php @@ -120,7 +120,7 @@ class IdoResourcePage extends Form $inspection = ResourceConfigForm::inspectResource($this); if ($inspection !== null) { if ($showLog) { - $join = function ($e) use (& $join) { + $join = function ($e) use (&$join) { return is_string($e) ? $e : join("\n", array_map($join, $e)); }; $this->addElement( diff --git a/modules/monitoring/library/Monitoring/Cli/CliUtils.php b/modules/monitoring/library/Monitoring/Cli/CliUtils.php index a2fd14db4..3d7d3ee32 100644 --- a/modules/monitoring/library/Monitoring/Cli/CliUtils.php +++ b/modules/monitoring/library/Monitoring/Cli/CliUtils.php @@ -94,7 +94,7 @@ class CliUtils ); } - public function objectStateFlags($type, & $row) + public function objectStateFlags($type, &$row) { $extra = array(); if ($row->{$type . '_in_downtime'}) { diff --git a/modules/monitoring/library/Monitoring/MonitoringWizard.php b/modules/monitoring/library/Monitoring/MonitoringWizard.php index a0dce1891..e466d706b 100644 --- a/modules/monitoring/library/Monitoring/MonitoringWizard.php +++ b/modules/monitoring/library/Monitoring/MonitoringWizard.php @@ -140,7 +140,10 @@ class MonitoringWizard extends Wizard implements SetupWizard $setup->addStep( new BackendStep(array( 'backendConfig' => $pageData['setup_monitoring_backend'], - 'resourceConfig' => array_diff_key($pageData['setup_monitoring_ido'], array('skip_validation' => null)) //TODO: Prefer a new backend once implemented. + 'resourceConfig' => array_diff_key( + $pageData['setup_monitoring_ido'], //TODO: Prefer a new backend once implemented. + array('skip_validation' => null) + ) )) ); diff --git a/modules/setup/application/forms/AuthBackendPage.php b/modules/setup/application/forms/AuthBackendPage.php index 4b11868af..71341e97c 100644 --- a/modules/setup/application/forms/AuthBackendPage.php +++ b/modules/setup/application/forms/AuthBackendPage.php @@ -188,7 +188,7 @@ class AuthBackendPage extends Form $inspection = UserBackendConfigForm::inspectUserBackend($self); if ($inspection !== null) { - $join = function ($e) use (& $join) { + $join = function ($e) use (&$join) { return is_string($e) ? $e : join("\n", array_map($join, $e)); }; $this->addElement( diff --git a/modules/setup/application/forms/LdapResourcePage.php b/modules/setup/application/forms/LdapResourcePage.php index 6eb34ca1f..77864071e 100644 --- a/modules/setup/application/forms/LdapResourcePage.php +++ b/modules/setup/application/forms/LdapResourcePage.php @@ -97,7 +97,7 @@ class LdapResourcePage extends Form if (isset($formData['backend_validation']) && parent::isValid($formData)) { $inspection = ResourceConfigForm::inspectResource($this); if ($inspection !== null) { - $join = function ($e) use (& $join) { + $join = function ($e) use (&$join) { return is_string($e) ? $e : join("\n", array_map($join, $e)); }; $this->addElement( diff --git a/modules/translation/library/Translation/Cli/ArrayToTextTableHelper.php b/modules/translation/library/Translation/Cli/ArrayToTextTableHelper.php index f5738e6f6..af01d5fa6 100644 --- a/modules/translation/library/Translation/Cli/ArrayToTextTableHelper.php +++ b/modules/translation/library/Translation/Cli/ArrayToTextTableHelper.php @@ -127,8 +127,7 @@ class ArrayToTextTableHelper $this->printHeading(); $rc = count($this->rows); - for ($i = 0; $i < $rc; - $i++) { + for ($i = 0; $i < $rc; $i++) { $this->printRow($i); }