Skip to content

Commit 146cba9

Browse files
committed
Cleaned up code - some adjustments to selected files
The following adjustments were made: - Files should end with a newline (PHP:S113) - Mergeable "if" statements should be combined (PHP:S1066) - Boolean literals should not be redundant (PHP:S1125) - Lines should not end with trailing whitespaces (PHP:S1131) - Use empty() to check whether the array is empty or not (PHP:S1155) - Unused local variables should be removed (PHP:S1481) - PHP keywords and constants "true", "false", "null" should be lower case (PHP:S1781) - "elseif" keyword should be used in place of "else if" keywords (PHP:S1793) - Unused assignments should be removed (PHP:S1854) - "require_once" and "include_once" should be used instead of "require" and "include" (PHP:S2003)
1 parent e09856d commit 146cba9

24 files changed

Lines changed: 239 additions & 279 deletions

lib/plan/buildEdit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
*/
10-
require '../../config.inc.php';
10+
require_once '../../config.inc.php';
1111
require_once 'common.php';
1212
require_once 'web_editor.php';
1313
$editorCfg = getWebEditorCfg('build');

lib/plan/buildView.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
*/
11-
require '../../config.inc.php';
11+
require_once '../../config.inc.php';
1212
require_once 'common.php';
1313
testlinkInitPage($db,false,false);
1414

@@ -94,11 +94,10 @@ function initEnv(&$dbHandler)
9494
if ($hasCF) {
9595
$cfields = (array)$build_mgr->getCustomFieldsValues($idk,$gui->tproject_id);
9696
foreach ($cfields as $cfd) {
97-
if ($initCFCol) {
98-
if (!isset($col2hide[$cfd['name']])) {
97+
if ($initCFCol && !isset($col2hide[$cfd['name']]))
98+
{
9999
$gui->cfieldsColumns[] = $cfd['label'];
100100
$gui->cfieldsType[] = $cfd['type'];
101-
}
102101
}
103102
$gui->buildSet[$idk][$cfd['label']] = ['value' => $cfd['value'], 'data-order' => $cfd['value']];
104103
if ($cfd['type'] == 'date') {

lib/plan/newest_tcversions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
*/
9-
require '../../config.inc.php';
9+
require_once '../../config.inc.php';
1010
require_once 'common.php';
1111

1212
testlinkInitPage($db,false,false);

lib/plan/planAddTCNavigator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
*/
2020

21-
require '../../config.inc.php';
21+
require_once '../../config.inc.php';
2222
require_once 'common.php';
2323
require_once 'treeMenu.inc.php';
2424

lib/plan/planImport.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @internal revisions
2020
*
2121
**/
22-
require '../../config.inc.php';
22+
require_once '../../config.inc.php';
2323
require_once 'common.php';
2424
require_once 'xml.inc.php';
2525

@@ -219,7 +219,7 @@ function importTestPlanLinksFromXML(&$dbHandler,&$tplanMgr,$targetFile,$contextO
219219
}
220220

221221
$xml = @simplexml_load_file_wrapper($targetFile);
222-
if($xml !== FALSE)
222+
if($xml !== false)
223223
{
224224
$tcaseMgr = new testcase($dbHandler);
225225
$tcaseSet = array();
@@ -252,7 +252,7 @@ function importTestPlanLinksFromXML(&$dbHandler,&$tplanMgr,$targetFile,$contextO
252252
{
253253
$tables = tlObjectWithDB::getDBTables(array('testplan_tcversions'));
254254
$platformSet = $tplanMgr->getPlatforms($contextObj->tplan_id,array('outputFormat' => 'mapAccessByName'));
255-
$targetHasPlatforms = (count($platformSet) > 0);
255+
$targetHasPlatforms = (!empty($platformSet));
256256

257257
$xmlLinks = $xml->executables->children();
258258
$loops2do = count($xmlLinks);
@@ -337,7 +337,7 @@ function importTestPlanLinksFromXML(&$dbHandler,&$tplanMgr,$targetFile,$contextO
337337
$dummy = $tcaseMgr->get_basic_info($tcaseSet[$externalID],
338338
array('number' => $version));
339339

340-
if( count($dummy) > 0 )
340+
if(!empty($dummy))
341341
{
342342
// Check :
343343
// for same test plan there is a different version already linked ?
@@ -468,7 +468,7 @@ function processPlatforms(&$platMgr,&$tplanMgr,$universe,$xmlSubset,$lbl,$tplanI
468468
$targetName = trim((string)$children[$idx]->name);
469469
if( isset($universe[$targetName]) )
470470
{
471-
$status_ok = $status_ok && true;
471+
$status_ok = true;
472472
$idSet[$universe[$targetName]] = $targetName;
473473
}
474474
else

lib/plan/planMilestonesCommands.class.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ class planMilestonesCommands
1818
private $auditContext;
1919
private $viewAction = 'lib/plan/planMilestonesView.php';
2020

21-
function __construct(&$db)
21+
public function __construct(&$db)
2222
{
2323
$this->db = $db;
2424
$this->milestone_mgr = new milestone_mgr($db);
2525
$this->submit_button_label = lang_get('btn_save');
2626
}
2727

28-
function setAuditContext($auditContext)
28+
private function setAuditContext($auditContext)
2929
{
3030
$this->auditContext = $auditContext;
3131
}
@@ -38,7 +38,7 @@ function: create
3838
returns:
3939
4040
*/
41-
function create(&$argsObj)
41+
private function create(&$argsObj)
4242
{
4343
$guiObj = new stdClass();
4444
$guiObj->main_descr = lang_get('testplan') . TITLE_SEP;
@@ -62,7 +62,7 @@ function: edit
6262
returns:
6363
6464
*/
65-
function edit(&$argsObj)
65+
private function edit(&$argsObj)
6666
{
6767
$guiObj = new stdClass();
6868
$dummy = $this->milestone_mgr->get_by_id($argsObj->id);
@@ -100,7 +100,7 @@ function: doCreate
100100
returns:
101101
102102
*/
103-
function doCreate(&$argsObj,$basehref)
103+
public function doCreate(&$argsObj,$basehref)
104104
{
105105
$date_format_cfg = config_get('date_format');
106106
$guiObj = new stdClass();
@@ -190,7 +190,7 @@ function: doUpdate
190190
returns:
191191
192192
*/
193-
function doUpdate(&$argsObj,$basehref)
193+
public function doUpdate(&$argsObj,$basehref)
194194
{
195195
$date_format_cfg = config_get('date_format');
196196
$obj=new stdClass();
@@ -289,7 +289,7 @@ function: doDelete
289289
returns: object with info useful to manage user interface
290290
291291
*/
292-
function doDelete(&$argsObj,$basehref)
292+
public function doDelete(&$argsObj,$basehref)
293293
{
294294
$dummy = $this->milestone_mgr->get_by_id($argsObj->id);
295295
$milestone = $dummy[$argsObj->id];

lib/platforms/platformsAssign.php

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
3-
* TestLink Open Source Project - http://testlink.sourceforge.net/
4-
* This script is distributed under the GNU General Public License 2 or later.
3+
* TestLink Open Source Project - http://testlink.sourceforge.net/
4+
* This script is distributed under the GNU General Public License 2 or later.
55
*
66
* Platform link/unlink from a test plan
7-
*
7+
*
88
* @package TestLink
99
* @author eloff
10-
* @copyright 2005-2022, TestLink community
10+
* @copyright 2005-2022, TestLink community
1111
* @filesource platformsAssign.php
1212
* @link http://www.testlink.org
1313
*
@@ -93,41 +93,30 @@
9393
$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
9494

9595
/**
96-
* Initializes option transfer items, by appending a text with number linked TC:s
96+
* Initializes option transfer items, by appending a text with number linked TC:s
9797
* for every assigned platform.
98-
* It also builds a js map platform_name => linked_count.
99-
* This map is used to show warning dialog only when trying to unlink
98+
* It also builds a js map platform_name => linked_count.
99+
* This map is used to show warning dialog only when trying to unlink
100100
* platforms with assigned TCs
101101
*/
102-
function init_option_panels(&$tplan_mgr, &$platform_mgr,
103-
&$opt_cfg, &$args)
102+
function init_option_panels(&$tplan_mgr, &$platform_mgr,&$opt_cfg, &$args)
104103
{
105-
106-
/*
107-
$opx = [
108-
'enable_on_design' => false,
109-
'enable_on_execution' => true,
110-
'is_open' => true
111-
];
112-
*/
113-
114104
$opt_cfg->from->map = $platform_mgr->getAllAsMap(config_get('platforms')->allowedOnAssign);
115105

116106
$optLTT = null;
117107
$map = $platform_mgr->getLinkedToTestplanAsMap($args->tplan_id,
118108
$optLTT);
119109
$platform_count_js = "platform_count_map = new Array();\n";
120-
if (!is_null($map)) {
110+
if (!is_null($map)) {
121111
foreach ($map as $plat_id => &$plat_name) {
122112
$count = $tplan_mgr->count_testcases($args->tplan_id,
123113
$plat_id);
124-
$plat_name .= sprintf(lang_get('platform_linked_count'),
114+
$plat_name .= sprintf(lang_get('platform_linked_count'),
125115
$count);
126-
$platform_count_js .=
127-
"platform_count_map['$plat_name'] = $count;\n";
116+
$platform_count_js .= "platform_count_map['$plat_name'] = $count;\n";
128117

129-
// Removal of duplicates is NOT handled
130-
// automatically since we just have modified
118+
// Removal of duplicates is NOT handled
119+
// automatically since we just have modified
131120
// their names adding a usage counter.
132121
unset($opt_cfg->from->map[$plat_id]);
133122
}
@@ -138,7 +127,7 @@ function init_option_panels(&$tplan_mgr, &$platform_mgr,
138127
}
139128

140129
/**
141-
*
130+
*
142131
*
143132
*/
144133
function init_args(&$opt_cfg)
@@ -166,7 +155,7 @@ function init_args(&$opt_cfg)
166155
$args->platformsToAdd = explode(",", $pParams[$added]);
167156
}
168157

169-
if( $pParams[$removed] != "" )
158+
if( $pParams[$removed] != "" )
170159
{
171160
$args->platformsToRemove = explode(",", $pParams[$removed]);
172161
}

0 commit comments

Comments
 (0)