mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-19 19:15:22 +00:00
src: style sweep, someone is feeling picky today
This commit is contained in:
parent
530c5220dc
commit
23f440ceee
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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()
|
||||
{
|
||||
|
||||
@ -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';
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user