Skip to content

Commit 88f2806

Browse files
committed
Cleaned up code - some files were refactored with refactor
The following adjustments were made: - Split multiple inline assigns to each own lines default value, to prevent undefined array issues (SplitDoubleAssignRector) - Assign outcome of ternary condition to variable, where applicable (TernaryConditionVariableAssignmentRector) - Change array_push() to direct variable assign (ChangeArrayPushToArrayAssignRector) - Switch negated ternary condition rector (SwitchNegatedTernaryRector) - Change count() in for function to own variable (ForRepeatedCountToOwnVariableRector) - Make if conditions more explicit (ExplicitBoolCompareRector)
1 parent 9176331 commit 88f2806

131 files changed

Lines changed: 560 additions & 476 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

config.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,7 @@
22482248
/**
22492249
* Converted and derived variables (Users should not modify this section)
22502250
*/
2251-
define('REFRESH_SPEC_TREE', $tlCfg->spec_cfg->automatic_tree_refresh ? 1 : 0);
2251+
define('REFRESH_SPEC_TREE', $tlCfg->spec_cfg->automatic_tree_refresh !== 0 ? 1 : 0);
22522252
define('TL_SORT_TABLE_ENGINE', $g_sort_table_engine);
22532253
define("TL_REPOSITORY_MAXFILESIZE",
22542254
1024 * 1024 * $tlCfg->repository_max_filesize);

firstLogin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
$message = '';
3535
if (! is_null($args->doEditUser)) {
36-
if (strcmp($args->password, $args->password2)) {
36+
if (strcmp($args->password, $args->password2) !== 0) {
3737
$message = lang_get('passwd_dont_match');
3838
} else {
3939
$user = new tlUser();

install/installNewDB.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@
474474
}
475475
}
476476

477-
if ($update_pwd) {
477+
if ($update_pwd !== 0) {
478478
echo "Password Conversion ...";
479479
// @author Francisco Mancardi - 20050918
480480
// Found error upgrading from 1.0.4 to 1.6 on RH

lib/api/rest/v1/tlRestApi.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ public function getProjectTestPlans($idCard)
362362

363363
if (! is_null($tproject)) {
364364
$items = $this->tprojectMgr->get_all_testplans($tproject[0]['id']);
365-
$op['items'] = (! empty($items)) ? $items : null;
365+
$op['items'] = (empty($items)) ? null : $items;
366366
} else {
367367
$op['message'] = "No Test Project identified by '" . $idCard . "'!";
368368
$op['status'] = 'error';

lib/api/rest/v2/tlRestApi.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ public function getProjectTestPlans($idCard)
479479

480480
if (! is_null($tproject)) {
481481
$items = $this->tprojectMgr->get_all_testplans($tproject['id']);
482-
$op['items'] = (! empty($items)) ? $items : null;
482+
$op['items'] = (empty($items)) ? null : $items;
483483
} else {
484484
$op['message'] = "No Test Project identified by '" . $idCard . "'!";
485485
$op['status'] = 'error';
@@ -1513,7 +1513,7 @@ public function getPlanBuilds($idCard)
15131513

15141514
if (! is_null($tplan)) {
15151515
$items = $this->tplanMgr->get_builds($tplan['id']);
1516-
$op['items'] = (! empty($items)) ? $items : null;
1516+
$op['items'] = (empty($items)) ? null : $items;
15171517
} else {
15181518
$op['message'] = "No Test Plan identified by '" . $idCard . "'!";
15191519
$op['status'] = 'error';
@@ -1692,7 +1692,7 @@ public function updateBuild($id)
16921692
$oio = intval($build['is_open']);
16931693
$nio = intval($item->is_open);
16941694
if ($oio != $nio) {
1695-
if ($nio) {
1695+
if ($nio !== 0) {
16961696
$this->buildMgr->setOpen($id);
16971697
} else {
16981698
$this->buildMgr->setClosed($id);

lib/api/rest/v3/RestApi.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ public function getProjectTestPlans(Response $response, $idCard)
440440

441441
if (! is_null($tproj)) {
442442
$items = $this->tprojectMgr->get_all_testplans($tproj['id']);
443-
$op['items'] = (! empty($items)) ? $items : null;
443+
$op['items'] = (empty($items)) ? null : $items;
444444
} else {
445445
$op['message'] = "No Test Project identified by '" . $idCard . "'!";
446446
$op['status'] = 'error';
@@ -466,7 +466,7 @@ public function getPlanBuilds(Response $response, $idCard)
466466

467467
if (! is_null($tplan)) {
468468
$items = $this->tplanMgr->get_builds($tplan['id']);
469-
$op['items'] = (! empty($items)) ? $items : null;
469+
$op['items'] = (empty($items)) ? null : $items;
470470
} else {
471471
$op['message'] = "No Test Plan identified by API KEY:" .
472472
$idCard['tplanApiKey'] . "";
@@ -836,7 +836,7 @@ public function updateBuild(Request $request, Response $response, $args)
836836
$oio = intval($build['is_open']);
837837
$nio = intval($item->is_open);
838838
if ($oio != $nio) {
839-
if ($nio) {
839+
if ($nio !== 0) {
840840
$this->buildMgr->setOpen($id);
841841
} else {
842842
$this->buildMgr->setClosed($id);

lib/api/xmlrpc/v1/sample_clients/php/clientTestSuiteTestCaseStepsManagement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
for ($idx = 1; $idx < $qtySteps; $idx ++) {
3232
$action = 'FULL STOP NOW!!!! - intensity=';
3333
$expected_results = '%s Red Lights ON';
34-
if ($idx & 1) {
34+
if (($idx & 1) !== 0) {
3535
$action = 'Start Server with power=';
3636
$expected_results = 'GREEN Lantern %s ON';
3737
}

lib/api/xmlrpc/v1/xmlrpc.class.php

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ protected function userHasRight($rightToCheck,
591591
}
592592

593593
$tprojectid = intval($tprojectid);
594-
$tplanid = ! is_null($tplanid) ? intval($tplanid) : - 1;
594+
$tplanid = is_null($tplanid) ? - 1 : intval($tplanid);
595595

596596
if ($tprojectid <= 0 && $tplanid > 0) {
597597
// get test project from test plan
@@ -1577,7 +1577,7 @@ protected function _checkTCIDAndTPIDValid($platformInfo = null,
15771577
{
15781578
$tplan_id = $this->args[self::$testPlanIDParamName];
15791579
$tcase_id = $this->args[self::$testCaseIDParamName];
1580-
$platform_id = ! is_null($platformInfo) ? key($platformInfo) : null;
1580+
$platform_id = is_null($platformInfo) ? null : key($platformInfo);
15811581

15821582
$filters = [
15831583
'exec_status' => "ALL",
@@ -1882,7 +1882,7 @@ public function getLastExecutionResult($args)
18821882
$targetID;
18831883
$resultInfo[0] = $this->dbObj->fetchFirstRow($sql);
18841884

1885-
if ($options->getBugs) {
1885+
if ($options->getBugs !== 0) {
18861886
$resultInfo[0]['bugs'] = [];
18871887
$sql = " SELECT DISTINCT bug_id FROM {$this->tables['execution_bugs']} " .
18881888
" WHERE execution_id = " . $targetID;
@@ -2029,7 +2029,7 @@ public function getAllExecutionsResults($args)
20292029
$sql = "SELECT * FROM {$this->tables['executions']} WHERE id=" .
20302030
$tcExecId;
20312031
$resultInfo[$tcExecId] = $this->dbObj->fetchFirstRow($sql);
2032-
if ($options->getBugs) {
2032+
if ($options->getBugs !== 0) {
20332033
$resultInfo[$tcExecId]['bugs'] = [];
20342034
$sql = " SELECT DISTINCT bug_id FROM
20352035
{$this->tables['execution_bugs']}
@@ -4052,8 +4052,9 @@ public function addTestCaseToTestPlan($args)
40524052
// Other version than requested done is already linked
40534053
$doLink = false;
40544054
if ($this->_isParamPresent(self::$overwriteParamName) &&
4055-
$this->args[self::$overwriteParamName]) {
4056-
$doLink = $doDeleteLinks = true;
4055+
$this->args[self::$overwriteParamName]) {
4056+
$doLink = true;
4057+
$doDeleteLinks = true;
40574058
}
40584059

40594060
reset($rs);
@@ -5480,15 +5481,15 @@ protected function checkPlatformIdentity($tplanID, $platformInfo = null,
54805481
$messagePrefix);
54815482
$status = $name_exists | $id_exists;
54825483

5483-
if (! $status) {
5484+
if ($status === 0) {
54845485
$pname = self::$platformNameParamName . ' OR ' .
54855486
self::$platformIDParamName;
54865487
$msg = $messagePrefix .
54875488
sprintf(MISSING_REQUIRED_PARAMETER_STR, $pname);
54885489
$this->errors[] = new IXR_Error(MISSING_REQUIRED_PARAMETER, $msg);
54895490
}
54905491

5491-
if ($status) {
5492+
if ($status !== 0) {
54925493
// get test plan name is useful for error messages
54935494
$tplanInfo = $this->tplanMgr->get_by_id($tplanID);
54945495
if (is_null($platformInfo)) {
@@ -9099,17 +9100,15 @@ public function updateBuildCustomFieldsValues($args)
90999100
$cfieldMgr->design_values_to_db($hash,
91009101
$args[self::$buildIDParamName], null, null, 'build');
91019102
// Add the result for each custom field to the returned array
9102-
array_push($ret,
9103-
[
9104-
'status' => 'ok',
9105-
'msg' => 'Custom Field:' . $cfName . ' processed '
9106-
]);
9103+
$ret[] = [
9104+
'status' => 'ok',
9105+
'msg' => 'Custom Field:' . $cfName . ' processed '
9106+
];
91079107
} else {
9108-
array_push($ret,
9109-
[
9110-
'status' => 'ko',
9111-
'msg' => 'Custom Field:' . $cfName . ' skipped '
9112-
]);
9108+
$ret[] = [
9109+
'status' => 'ko',
9110+
'msg' => 'Custom Field:' . $cfName . ' skipped '
9111+
];
91139112
}
91149113
}
91159114
// Return the result after all of the fields have been processed
@@ -9663,7 +9662,7 @@ public function getExecutionSet($args)
96639662
$sql .= ")";
96649663

96659664
$sql .= " ORDER BY id ";
9666-
$sql .= ($opt->getOrderDescending) ? " DESC" : " ASC";
9665+
$sql .= ($opt->getOrderDescending !== 0) ? " DESC" : " ASC";
96679666

96689667
$rs = $this->dbObj->fetchRowsIntoMap($sql, 'id');
96699668
if (is_null($rs)) {

lib/cfields/cfieldsEdit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
break;
6464
}
6565

66-
if ($do_control_combo_display) {
66+
if ($do_control_combo_display !== 0) {
6767
$keys2loop = $cfield_mgr->get_application_areas();
6868
foreach ($keys2loop as $ui_mode) {
6969
$cfieldCfg->cf_enable_on[$ui_mode]['value'] = 0;

lib/cfields/cfieldsExport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
$gui->page_title = lang_get('export_cfields');
2525
$gui->do_it = 1;
2626
$gui->nothing_todo_msg = '';
27-
$gui->goback_url = ! is_null($args->goback_url) ? $args->goback_url : '';
27+
$gui->goback_url = is_null($args->goback_url) ? '' : $args->goback_url;
2828
$gui->export_filename = is_null($args->export_filename) ? 'customFields.xml' : $args->export_filename;
2929
$gui->exportTypes = [
3030
'XML' => 'XML'

0 commit comments

Comments
 (0)