correct phpcs config

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2018-02-27 09:30:57 +01:00
parent b46d3a3769
commit b097c19c0a
4 changed files with 43 additions and 34 deletions

View File

@@ -1555,7 +1555,7 @@ class Domains extends ApiCommand implements ResourceEntity
// trigger when domain id for alias destination has changed: both for old and new destination // trigger when domain id for alias destination has changed: both for old and new destination
triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $this->logger()); triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $this->logger());
triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger());
} else if ($result['wwwserveralias'] != $wwwserveralias || $result['letsencrypt'] != $letsencrypt) { } elseif ($result['wwwserveralias'] != $wwwserveralias || $result['letsencrypt'] != $letsencrypt) {
// or when wwwserveralias or letsencrypt was changed // or when wwwserveralias or letsencrypt was changed
triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger()); triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $this->logger());
} }

View File

@@ -83,20 +83,24 @@ class Froxlor extends ApiCommand
/** /**
* *
* @todo import settings * @todo import settings
* *
* @access admin * @access admin
*/ */
public function importSettings() public function importSettings()
{} {
throw new Exception("Not available yet.", 501);
}
/** /**
* *
* @todo export settings to file * @todo export settings to file
* *
* @access admin * @access admin
*/ */
public function exportSettings() public function exportSettings()
{} {
throw new Exception("Not available yet.", 501);
}
/** /**
* return a list of all settings * return a list of all settings
@@ -202,7 +206,7 @@ class Froxlor extends ApiCommand
array_push($functions, array_merge(array( array_push($functions, array_merge(array(
'module' => $module, 'module' => $module,
'function' => $func->name 'function' => $func->name
), $this->_getParamListFromDoc($module, $func->name))); ), $this->getParamListFromDoc($module, $func->name)));
} }
} }
} else { } else {
@@ -234,7 +238,7 @@ class Froxlor extends ApiCommand
array_push($functions, array_merge(array( array_push($functions, array_merge(array(
'module' => $matches[1], 'module' => $matches[1],
'function' => $func->name 'function' => $func->name
), $this->_getParamListFromDoc($matches[1], $func->name))); ), $this->getParamListFromDoc($matches[1], $func->name)));
} }
} }
} }
@@ -259,7 +263,7 @@ class Froxlor extends ApiCommand
* @throws Exception * @throws Exception
* @return array|bool * @return array|bool
*/ */
private function _getParamListFromDoc($module = null, $function = null) private function getParamListFromDoc($module = null, $function = null)
{ {
try { try {
// set the module // set the module
@@ -307,7 +311,8 @@ class Froxlor extends ApiCommand
'type' => $r[1], 'type' => $r[1],
'desc' => (isset($r[2]) ? trim($r[2]) : '') 'desc' => (isset($r[2]) ? trim($r[2]) : '')
); );
} else if (! empty($c) && strpos($c, '@throws') === false) { }
elseif (! empty($c) && strpos($c, '@throws') === false) {
if (substr($c, 0, 3) == "/**") { if (substr($c, 0, 3) == "/**") {
continue; continue;
} }
@@ -331,7 +336,7 @@ class Froxlor extends ApiCommand
} }
} }
} }
$result['head'] =trim($result['head']); $result['head'] = trim($result['head']);
return $result; return $result;
} catch (\ReflectionException $e) { } catch (\ReflectionException $e) {
return array(); return array();

View File

@@ -1,15 +1,12 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<ruleset name="PSR2-Froxlor"> <ruleset name="PSR2-Froxlor">
<description>PSR2 with tabs instead of spaces.</description> <description>PSR2 with tabs instead of spaces.</description>
<config name="show_progress" value="1" />
<config name="ignore_warnings_on_exit" value="1" />
<arg name="tab-width" value="4" /> <arg name="tab-width" value="4" />
<rule ref="PSR2"> <rule ref="PSR2">
<exclude name="Generic.WhiteSpace.DisallowTabIndent" /> <exclude name="Generic.WhiteSpace.DisallowTabIndent" />
</rule> <exclude name="Generic.Files.LineLength" />
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent" /> <exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="1" />
<property name="tabIndent" value="true" />
</properties>
</rule> </rule>
</ruleset> </ruleset>

View File

@@ -37,7 +37,9 @@ class CustomersTest extends TestCase
'custom_notes' => 'secret', 'custom_notes' => 'secret',
'custom_notes_show' => 0, 'custom_notes_show' => 0,
'gender' => 5, 'gender' => 5,
'allowed_phpconfigs' => array(1) 'allowed_phpconfigs' => array(
1
)
]; ];
$json_result = Customers::getLocal($admin_userdata, $data)->add(); $json_result = Customers::getLocal($admin_userdata, $data)->add();
@@ -67,7 +69,7 @@ class CustomersTest extends TestCase
'firstname' => 'Test2', 'firstname' => 'Test2',
'name' => 'Testman2' 'name' => 'Testman2'
]; ];
$this->expectExceptionMessage('Requested parameter "email" is empty where it should not be for "Customers:add"'); $this->expectExceptionMessage('Requested parameter "email" is empty where it should not be for "Customers:add"');
Customers::getLocal($admin_userdata, $data)->add(); Customers::getLocal($admin_userdata, $data)->add();
} }
@@ -127,12 +129,11 @@ class CustomersTest extends TestCase
'id' => 1 'id' => 1
))->get(); ))->get();
$customer_userdata = json_decode($json_result, true)['data']; $customer_userdata = json_decode($json_result, true)['data'];
$this->expectExceptionCode(403); $this->expectExceptionCode(403);
$this->expectExceptionMessage("Not allowed to execute given command."); $this->expectExceptionMessage("Not allowed to execute given command.");
$json_result = Customers::getLocal($customer_userdata)->list(); $json_result = Customers::getLocal($customer_userdata)->list();
} }
/** /**
@@ -248,7 +249,7 @@ class CustomersTest extends TestCase
'id' => 1, 'id' => 1,
'deactivated' => 0 'deactivated' => 0
))->update(); ))->update();
// get customer // get customer
$json_result = Customers::getLocal($admin_userdata, array( $json_result = Customers::getLocal($admin_userdata, array(
'id' => 1 'id' => 1
@@ -283,7 +284,7 @@ class CustomersTest extends TestCase
))->get(); ))->get();
$reseller_userdata = json_decode($json_result, true)['data']; $reseller_userdata = json_decode($json_result, true)['data'];
$reseller_userdata['adminsession'] = 1; $reseller_userdata['adminsession'] = 1;
$this->expectExceptionMessage("You cannot allocate more resources than you own for yourself."); $this->expectExceptionMessage("You cannot allocate more resources than you own for yourself.");
// add new customer // add new customer
$data = [ $data = [
@@ -292,12 +293,12 @@ class CustomersTest extends TestCase
'firstname' => 'Test', 'firstname' => 'Test',
'name' => 'Testman', 'name' => 'Testman',
'customernumber' => 1338, 'customernumber' => 1338,
'subdomains' => -1, 'subdomains' => - 1,
'new_customer_password' => 'h0lYmo1y' 'new_customer_password' => 'h0lYmo1y'
]; ];
Customers::getLocal($reseller_userdata, $data)->add(); Customers::getLocal($reseller_userdata, $data)->add();
} }
public function testCustomerCustomersDelete() public function testCustomerCustomersDelete()
{ {
global $admin_userdata; global $admin_userdata;
@@ -308,7 +309,9 @@ class CustomersTest extends TestCase
$customer_userdata = json_decode($json_result, true)['data']; $customer_userdata = json_decode($json_result, true)['data'];
$this->expectExceptionCode(403); $this->expectExceptionCode(403);
$this->expectExceptionMessage("Not allowed to execute given command."); $this->expectExceptionMessage("Not allowed to execute given command.");
Customers::getLocal($customer_userdata, array('loginname' => 'test1'))->delete(); Customers::getLocal($customer_userdata, array(
'loginname' => 'test1'
))->delete();
} }
public function testResellerCustomersDeleteNotOwned() public function testResellerCustomersDeleteNotOwned()
@@ -321,7 +324,9 @@ class CustomersTest extends TestCase
$reseller_userdata = json_decode($json_result, true)['data']; $reseller_userdata = json_decode($json_result, true)['data'];
$reseller_userdata['adminsession'] = 1; $reseller_userdata['adminsession'] = 1;
$this->expectExceptionCode(404); $this->expectExceptionCode(404);
Customers::getLocal($reseller_userdata, array('loginname' => 'test1'))->delete(); Customers::getLocal($reseller_userdata, array(
'loginname' => 'test1'
))->delete();
} }
public function testAdminCustomersDelete() public function testAdminCustomersDelete()
@@ -337,11 +342,13 @@ class CustomersTest extends TestCase
'new_customer_password' => 'h0lYmo1y' 'new_customer_password' => 'h0lYmo1y'
]; ];
Customers::getLocal($admin_userdata, $data)->add(); Customers::getLocal($admin_userdata, $data)->add();
$json_result = Customers::getLocal($admin_userdata, array('loginname' => 'test2'))->delete(); $json_result = Customers::getLocal($admin_userdata, array(
'loginname' => 'test2'
))->delete();
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
$this->assertEquals('test2', $result['loginname']); $this->assertEquals('test2', $result['loginname']);
} }
public function testAdminCustomersUnlock() public function testAdminCustomersUnlock()
{ {
global $admin_userdata; global $admin_userdata;
@@ -353,7 +360,7 @@ class CustomersTest extends TestCase
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
$this->assertEquals(0, $result['loginfail_count']); $this->assertEquals(0, $result['loginfail_count']);
} }
public function testAdminCustomersUnlockNotAllowed() public function testAdminCustomersUnlockNotAllowed()
{ {
global $admin_userdata; global $admin_userdata;
@@ -366,7 +373,7 @@ class CustomersTest extends TestCase
'loginname' => 'test1' 'loginname' => 'test1'
))->unlock(); ))->unlock();
} }
public function testAdminCustomersMoveNotAllowed() public function testAdminCustomersMoveNotAllowed()
{ {
global $admin_userdata; global $admin_userdata;
@@ -380,7 +387,7 @@ class CustomersTest extends TestCase
'adminid' => 1 'adminid' => 1
))->move(); ))->move();
} }
public function testAdminCustomersMoveTargetIsSource() public function testAdminCustomersMoveTargetIsSource()
{ {
global $admin_userdata; global $admin_userdata;
@@ -403,5 +410,5 @@ class CustomersTest extends TestCase
$this->assertEquals(2, $result['adminid']); $this->assertEquals(2, $result['adminid']);
} }
} }