Skip to content

Commit 1896814

Browse files
committed
Code revised with reactor
Applied rules: * ForRepeatedCountToOwnVariableRector * IssetOnPropertyObjectToPropertyExistsRector
1 parent bceff0d commit 1896814

12 files changed

Lines changed: 36 additions & 26 deletions

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4752,7 +4752,7 @@ public function createTestSuite($args)
47524752
{
47534753
$result = array();
47544754
$this->_setArgs($args);
4755-
$action = isset($this->args, self::$actionParamName) ? $this->args[self::$actionParamName] : 'create';
4755+
$action = $this->args !== null ? $this->args[self::$actionParamName] : 'create';
47564756

47574757
$checkFunctions = array(
47584758
'authenticate',
@@ -6934,7 +6934,7 @@ public function createTestCaseSteps($args)
69346934

69356935
$step_id = 0;
69366936
$stepSet = null;
6937-
$action = isset($this->args, self::$actionParamName) ? $this->args[self::$actionParamName] : 'create';
6937+
$action = $this->args !== null ? $this->args[self::$actionParamName] : 'create';
69386938

69396939
//
69406940
// id,step_number,actions,expected_results,active,execution_type

lib/functions/attachments.inc.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ function checkAttachmentID(&$db, $id, $attachmentInfo)
111111
{
112112
$isValid = false;
113113
if ($attachmentInfo) {
114-
$sLastAttachmentInfos = isset($_SESSION['s_lastAttachmentInfos']) ? $_SESSION['s_lastAttachmentInfos'] : null;
115-
for ($i = 0; $i < count($sLastAttachmentInfos); $i ++) {
114+
$sLastAttachmentInfos = isset($_SESSION['s_lastAttachmentInfos']) ? $_SESSION['s_lastAttachmentInfos'] : null;
115+
$counter = count($sLastAttachmentInfos);
116+
for ($i = 0; $i < $counter; $i ++) {
116117
$info = $sLastAttachmentInfos[$i];
117118
if ($info['id'] == $id) {
118119
$isValid = true;

lib/functions/code_testing/dBug.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,9 @@ public function varIsDBResource($var, $db = "mysql")
334334
$this->makeTableHeader("resource", $db . " result", $numfields + 1);
335335
echo "<tr><td class=\"dBug_resourceKey\">&nbsp;</td>";
336336
for ($i = 0; $i < $numfields; $i ++) {
337-
$field_header = "";
338-
for ($j = 0; $j < count($arrFields); $j ++) {
337+
$field_header = "";
338+
$counter = count($arrFields);
339+
for ($j = 0; $j < $counter; $j ++) {
339340
$db_func = $db . "_field_" . $arrFields[$j];
340341
if (function_exists($db_func)) {
341342
$fheader = call_user_func($db_func, $var, $i) . " ";

lib/functions/metastring.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ public function localize($locale = null)
181181

182182
$subjects = array();
183183
$replacements = array();
184-
$params = (array) $this->helper->params;
185-
for ($i = 0; $i < count($params); $i ++) {
184+
$params = (array) $this->helper->params;
185+
$counter = count($params);
186+
for ($i = 0; $i < $counter; $i ++) {
186187
$param = $params[$i];
187188
if (is_array($param)) {
188189
$item = null;

lib/functions/object.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ abstract class tlObject implements iSerialization
9999
*/
100100
public function __construct()
101101
{
102-
if (! isset($this->tables)) {
102+
if ($this->tables === null) {
103103
$this->tables = self::getDBTables();
104104
$this->views = self::getDBViews();
105105
}
@@ -642,7 +642,8 @@ public static function createObjectsFromDB(&$db, $ids, $className,
642642
$items = self::bulkCreateObjectsFromDB($db, $ids, $className,
643643
$returnAsMap, $detailLevel);
644644
} else {
645-
for ($i = 0; $i < count((array) $ids); $i ++) {
645+
$counter = count((array) $ids);
646+
for ($i = 0; $i < $counter; $i ++) {
646647
$id = $ids[$i];
647648
$item = self::createObjectFromDB($db, $id, $className,
648649
self::TLOBJ_O_SEARCH_BY_ID, $detailLevel);

lib/functions/string_api.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ function string_nl2br($p_string, $p_wrap = 100)
7474

7575
// fix up eols within <pre> tags
7676
$pre2 = array();
77-
preg_match_all("/<pre[^>]*?>(.|\n)*?<\/pre>/", $p_string, $pre1);
78-
for ($x = 0; $x < count($pre1[0]); $x ++) {
77+
preg_match_all("/<pre[^>]*?>(.|\n)*?<\/pre>/", $p_string, $pre1);
78+
$counter = count($pre1[0]);
79+
for ($x = 0; $x < $counter; $x ++) {
7980
$pre2[$x] = preg_replace("/<br[^>]*?>/", "", $pre1[0][$x]);
8081
// this may want to be replaced by html_entity_decode (or equivalent)
8182
// if other encoded characters are a problem

lib/functions/testproject.class.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,8 +1407,9 @@ public function exportKeywordsToXML($testproject_id, $bNoXMLHeader = false)
14071407
if (! $bNoXMLHeader) {
14081408
$xmlCode .= TL_XMLEXPORT_HEADER . "\n";
14091409
}
1410-
$xmlCode .= "<keywords>";
1411-
for ($idx = 0; $idx < count($kwIDs); $idx ++) {
1410+
$xmlCode .= "<keywords>";
1411+
$counter = count($kwIDs);
1412+
for ($idx = 0; $idx < $counter; $idx ++) {
14121413
$keyword = new tlKeyword($kwIDs[$idx]);
14131414
$keyword->readFromDb($this->db);
14141415
$keyword->writeToXML($xmlCode, true);
@@ -1426,8 +1427,9 @@ public function exportKeywordsToXML($testproject_id, $bNoXMLHeader = false)
14261427
private function exportKeywordsToCSV($testproject_id, $delim = ';')
14271428
{
14281429
$kwIDs = $this->getKeywordIDsFor($testproject_id);
1429-
$csv = null;
1430-
for ($idx = 0; $idx < count($kwIDs); $idx ++) {
1430+
$csv = null;
1431+
$counter = count($kwIDs);
1432+
for ($idx = 0; $idx < $counter; $idx ++) {
14311433
$keyword = new tlKeyword($kwIDs[$idx]);
14321434
$keyword->readFromDb($this->db);
14331435
$keyword->writeToCSV($csv, $delim);

lib/functions/tlAttachmentRepository.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,10 @@ public function deleteAttachmentsFor($fkid, $fkTableName)
518518
$stdTableUsedAsFolder = str_replace(DB_TABLE_PREFIX, '', $fkTableName);
519519
$statusOK = true;
520520
$attachmentIDs = (array) $this->getAttachmentIDsFor($fkid,
521-
$stdTableUsedAsFolder);
521+
$stdTableUsedAsFolder);
522+
$counter = count($attachmentIDs);
522523

523-
for ($i = 0; $i < count($attachmentIDs); $i ++) {
524+
for ($i = 0; $i < $counter; $i ++) {
524525
$id = $attachmentIDs[$i];
525526
$statusOK = ($this->deleteAttachment($id) && $statusOK);
526527
}

lib/functions/tlRole.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,9 @@ protected function readRights(&$db)
506506

507507
protected function buildRightsArray($rightInfo)
508508
{
509-
$rights = null;
510-
for ($i = 0; $i < count($rightInfo); $i ++) {
509+
$rights = null;
510+
$counter = count($rightInfo);
511+
for ($i = 0; $i < $counter; $i ++) {
511512
$id = $rightInfo[$i];
512513
$right = new tlRight($id['right_id']);
513514
$right->name = $id['description'];

lib/functions/tlUser.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,9 +1180,9 @@ public static function getByIDs(&$db, $ids,
11801180

11811181
if (null == $ids) {
11821182
return null;
1183-
}
1184-
1185-
for ($idx = 0; $idx < count($ids); $idx ++) {
1183+
}
1184+
$counter = count($ids);
1185+
for ($idx = 0; $idx < $counter; $idx ++) {
11861186
$id = $ids[$idx];
11871187
$user = tlDBObject::createObjectFromDB($db, $id, __CLASS__,
11881188
self::TLOBJ_O_SEARCH_BY_ID, $detailLevel);

0 commit comments

Comments
 (0)