From 23f440ceee18d5878b1b967ecc63bd522fffff9c Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 14 Jan 2019 08:46:46 +0100 Subject: [PATCH] src: style sweep, someone is feeling picky today --- .../Base/ApiMutableModelControllerBase.php | 4 ++-- .../Base/ApiMutableServiceControllerBase.php | 8 ++++---- .../OPNsense/Cron/Api/SettingsController.php | 4 ++-- .../OPNsense/Firewall/Api/AliasController.php | 4 ++-- .../OPNsense/IDS/Api/ServiceController.php | 8 ++++---- .../OPNsense/IDS/Api/SettingsController.php | 4 ++-- .../OPNsense/Monit/Api/ServiceController.php | 8 ++++---- .../OPNsense/Proxy/Api/ServiceController.php | 8 ++++---- .../OPNsense/Proxy/Api/SettingsController.php | 4 ++-- .../OPNsense/Routes/Api/RoutesController.php | 4 ++-- .../TrafficShaper/Api/SettingsController.php | 4 ++-- .../mvc/app/library/OPNsense/Core/Config.php | 4 ++-- .../Constraints/ComparedToFieldConstraint.php | 11 +++++++---- .../Constraints/ComparedToFieldConstraintTest.php | 15 ++++++++++----- 14 files changed, 49 insertions(+), 41 deletions(-) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php b/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php index d0be70164..0400ebdc9 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableModelControllerBase.php @@ -45,12 +45,12 @@ abstract class ApiMutableModelControllerBase extends ApiControllerBase /** * @var string this implementations internal model name to use (in set/get output) */ - static protected $internalModelName = null; + protected static $internalModelName = null; /** * @var string model class name to use */ - static protected $internalModelClass = null; + protected static $internalModelClass = null; /** * @var null|BaseModel model object to work on diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableServiceControllerBase.php b/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableServiceControllerBase.php index 768fb6852..0c683efc5 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableServiceControllerBase.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableServiceControllerBase.php @@ -43,22 +43,22 @@ abstract class ApiMutableServiceControllerBase extends ApiControllerBase /** * @var string this implementations internal model service to use */ - static protected $internalServiceName = null; + protected static $internalServiceName = null; /** * @var string model class name to use */ - static protected $internalServiceClass = null; + protected static $internalServiceClass = null; /** * @var string model template name to use */ - static protected $internalServiceTemplate = null; + protected static $internalServiceTemplate = null; /** * @var string model enabled xpath to use */ - static protected $internalServiceEnabled = null; + protected static $internalServiceEnabled = null; /** * @var null|BaseModel model object to work on diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php index f6145d6ad..d11331edf 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php @@ -41,8 +41,8 @@ use \OPNsense\Cron\Cron; class SettingsController extends ApiMutableModelControllerBase { - static protected $internalModelName = 'job'; - static protected $internalModelClass = '\OPNsense\Cron\Cron'; + protected static $internalModelName = 'job'; + protected static $internalModelClass = '\OPNsense\Cron\Cron'; /** * retrieve job settings or return defaults diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php index 69e918c20..e07c64e8a 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Firewall/Api/AliasController.php @@ -39,8 +39,8 @@ use \OPNsense\Base\UserException; class AliasController extends ApiMutableModelControllerBase { - static protected $internalModelName = 'alias'; - static protected $internalModelClass = 'OPNsense\Firewall\Alias'; + protected static $internalModelName = 'alias'; + protected static $internalModelClass = 'OPNsense\Firewall\Alias'; /** * search aliases diff --git a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php index 0709f1575..bbde7b534 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php @@ -41,10 +41,10 @@ use \Phalcon\Filter; */ class ServiceController extends ApiMutableServiceControllerBase { - static protected $internalServiceClass = '\OPNsense\IDS\IDS'; - static protected $internalServiceEnabled = 'general.enabled'; - static protected $internalServiceTemplate = 'OPNsense/IDS'; - static protected $internalServiceName = 'ids'; + protected static $internalServiceClass = '\OPNsense\IDS\IDS'; + protected static $internalServiceEnabled = 'general.enabled'; + protected static $internalServiceTemplate = 'OPNsense/IDS'; + protected static $internalServiceName = 'ids'; /** * Reconfigure IDS diff --git a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php index 9da761231..e01058aa5 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php @@ -41,8 +41,8 @@ use \OPNsense\Base\UIModelGrid; */ class SettingsController extends ApiMutableModelControllerBase { - static protected $internalModelName = 'ids'; - static protected $internalModelClass = '\OPNsense\IDS\IDS'; + protected static $internalModelName = 'ids'; + protected static $internalModelClass = '\OPNsense\IDS\IDS'; /** * Query non layered model items diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Monit/Api/ServiceController.php b/src/opnsense/mvc/app/controllers/OPNsense/Monit/Api/ServiceController.php index fa47a5135..afd0bfa88 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Monit/Api/ServiceController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Monit/Api/ServiceController.php @@ -40,10 +40,10 @@ use \OPNsense\Monit\Monit; */ class ServiceController extends ApiMutableServiceControllerBase { - static protected $internalServiceClass = '\OPNsense\Monit\Monit'; - static protected $internalServiceEnabled = 'general.enabled'; - static protected $internalServiceTemplate = 'OPNsense/Monit'; - static protected $internalServiceName = 'monit'; + protected static $internalServiceClass = '\OPNsense\Monit\Monit'; + protected static $internalServiceEnabled = 'general.enabled'; + protected static $internalServiceTemplate = 'OPNsense/Monit'; + protected static $internalServiceName = 'monit'; /** * initialize object properties diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php index a76230e17..d3cfa889f 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/ServiceController.php @@ -38,10 +38,10 @@ use \OPNsense\Proxy\Proxy; */ class ServiceController extends ApiMutableServiceControllerBase { - static protected $internalServiceClass = '\OPNsense\Proxy\Proxy'; - static protected $internalServiceEnabled = 'general.enabled'; - static protected $internalServiceTemplate = 'OPNsense/Proxy'; - static protected $internalServiceName = 'proxy'; + protected static $internalServiceClass = '\OPNsense\Proxy\Proxy'; + protected static $internalServiceEnabled = 'general.enabled'; + protected static $internalServiceTemplate = 'OPNsense/Proxy'; + protected static $internalServiceName = 'proxy'; protected function reconfigureForceRestart() { diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/SettingsController.php index 3009490d1..86a89b334 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Proxy/Api/SettingsController.php @@ -40,8 +40,8 @@ use \OPNsense\Base\UIModelGrid; */ class SettingsController extends ApiMutableModelControllerBase { - static protected $internalModelName = 'proxy'; - static protected $internalModelClass = '\OPNsense\Proxy\Proxy'; + protected static $internalModelName = 'proxy'; + protected static $internalModelClass = '\OPNsense\Proxy\Proxy'; /** * diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php b/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php index ffd14c357..c70a5cacc 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php @@ -40,8 +40,8 @@ use \OPNsense\Routes\Route; class RoutesController extends ApiMutableModelControllerBase { - static protected $internalModelName = 'route'; - static protected $internalModelClass = '\OPNsense\Routes\Route'; + protected static $internalModelName = 'route'; + protected static $internalModelClass = '\OPNsense\Routes\Route'; /** * search routes diff --git a/src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php index 3700ff45a..b03964ae0 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php @@ -38,8 +38,8 @@ use \OPNsense\Core\Config; */ class SettingsController extends ApiMutableModelControllerBase { - static protected $internalModelName = 'ts'; - static protected $internalModelClass = '\OPNsense\TrafficShaper\TrafficShaper'; + protected static $internalModelName = 'ts'; + protected static $internalModelClass = '\OPNsense\TrafficShaper\TrafficShaper'; /** * validate and save model after update or insertion. diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php index c361e945a..32175d0be 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php @@ -562,7 +562,7 @@ class Config extends Singleton /** * cleanup, close file handle */ - public function __destruct () + public function __destruct() { if ($this->config_file_handle !== null) { fclose($this->config_file_handle); @@ -574,7 +574,7 @@ class Config extends Singleton * lock configuration * @param boolean $reload reload config from open file handle to enforce synchronicity */ - public function lock($reload=true) + public function lock($reload = true) { if ($this->config_file_handle !== null) { flock($this->config_file_handle, LOCK_EX); diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php index 8eb970e88..ffb0ca41a 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraint.php @@ -60,9 +60,11 @@ class ComparedToFieldConstraint extends BaseConstraint if (!((!$this->isEmpty($node) && !$this->isEmpty($other_node_content)) && // check if all fields are set is_numeric((string)$node) && is_numeric((string)$other_node_content) && // check if both are numeric - $this->is_contraint_fulfilled($operator, - floatval((string)$node), floatval((string)$other_node_content)))) { - + $this->is_contraint_fulfilled( + $operator, + floatval((string)$node), + floatval((string)$other_node_content) + ))) { $this->appendMessage($validator, $attribute); } } @@ -75,7 +77,8 @@ class ComparedToFieldConstraint extends BaseConstraint * @param $foreign_value float the value of the referenced field * @return bool if the contraint is fulfilled */ - private function is_contraint_fulfilled($operator, $our_value, $foreign_value) { + private function is_contraint_fulfilled($operator, $our_value, $foreign_value) + { switch ($operator) { case 'gt': return $our_value > $foreign_value; diff --git a/src/opnsense/mvc/tests/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraintTest.php b/src/opnsense/mvc/tests/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraintTest.php index 87f6ae231..655d3354b 100644 --- a/src/opnsense/mvc/tests/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraintTest.php +++ b/src/opnsense/mvc/tests/app/models/OPNsense/Base/Constraints/ComparedToFieldConstraintTest.php @@ -38,7 +38,8 @@ use OPNsense\Base\FieldTypes\IntegerField; class ComparedToFieldConstraintTest extends \PHPUnit\Framework\TestCase { // lesser then - public function test_if_it_validates_number_ranges_correctly_with_lt_and_no_error() { + public function test_if_it_validates_number_ranges_correctly_with_lt_and_no_error() + { $validator = new \Phalcon\Validation(); $validate = $this->make_validator(2, 3, 'test', 'lt'); $ret = $validate->validate($validator, ''); @@ -47,7 +48,8 @@ class ComparedToFieldConstraintTest extends \PHPUnit\Framework\TestCase $this->assertEquals(true, $ret); } - public function test_if_it_validates_number_ranges_correctly_with_lt_and_error() { + public function test_if_it_validates_number_ranges_correctly_with_lt_and_error() + { $validator = new \Phalcon\Validation(); $validate = $this->make_validator(3, 3, 'test', 'lt'); $ret = $validate->validate($validator, ''); @@ -56,7 +58,8 @@ class ComparedToFieldConstraintTest extends \PHPUnit\Framework\TestCase $this->assertEquals(true, $ret); } // greater then - public function test_if_it_validates_number_ranges_correctly_with_gt_and_no_error() { + public function test_if_it_validates_number_ranges_correctly_with_gt_and_no_error() + { $validator = new \Phalcon\Validation(); $validate = $this->make_validator(5, 3, 'test', 'gt'); $ret = $validate->validate($validator, ''); @@ -65,7 +68,8 @@ class ComparedToFieldConstraintTest extends \PHPUnit\Framework\TestCase $this->assertEquals(true, $ret); } - public function test_if_it_validates_number_ranges_correctly_with_gt_and_error() { + public function test_if_it_validates_number_ranges_correctly_with_gt_and_error() + { $validator = new \Phalcon\Validation(); $validate = $this->make_validator(2, 3, 'test', 'gt'); $ret = $validate->validate($validator, ''); @@ -81,7 +85,8 @@ class ComparedToFieldConstraintTest extends \PHPUnit\Framework\TestCase * @param $operator string see the related documentaton * @return ComparedToFieldConstraint the created contraint */ - private function make_validator($node_value, $other_field_value, $field, $operator) { + private function make_validator($node_value, $other_field_value, $field, $operator) + { $node = new IntegerField(); $other_field = new IntegerField(); $shared_parent = new ArrayField();