Skip to content

Commit 4bb9842

Browse files
committed
Applied rules:
* ExplicitPublicClassMethodRector * CountArrayToEmptyArrayComparisonRector
1 parent bfbbff7 commit 4bb9842

26 files changed

+80
-81
lines changed

lib/ajax/gettprojectnodes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function getAllTCasesID($idList, &$tcIDs)
220220
$suiteIDs[] = $row['id'];
221221
}
222222
}
223-
if (count($suiteIDs)) {
223+
if ($suiteIDs !== []) {
224224
$suiteIDs = implode(",", $suiteIDs);
225225
getAllTCasesID($suiteIDs, $tcIDs);
226226
}

lib/functions/code_testing/dBug.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private function getVariableName()
130130
}
131131

132132
// create the main table header
133-
function makeTableHeader($type, $header, $colspan = 2)
133+
public function makeTableHeader($type, $header, $colspan = 2)
134134
{
135135
if (! $this->bInitialized) {
136136
$header = $this->getVariableName() . " (" . $header . ")";
@@ -145,7 +145,7 @@ function makeTableHeader($type, $header, $colspan = 2)
145145
}
146146

147147
// create the table row header
148-
function makeTDHeader($type, $header)
148+
public function makeTDHeader($type, $header)
149149
{
150150
echo "<tr>
151151
<td valign=\"top\" onClick='dBug_toggleRow(this)' class=\"dBug_" . $type .
@@ -154,13 +154,13 @@ function makeTDHeader($type, $header)
154154
}
155155

156156
// close table row
157-
function closeTDRow()
157+
public function closeTDRow()
158158
{
159159
return "</td></tr>\n";
160160
}
161161

162162
// error
163-
function error($type)
163+
public function error($type)
164164
{
165165
$error = "Error: Variable cannot be a";
166166
// this just checks if the type starts with a vowel or "x" and displays either "a" or "an"
@@ -177,7 +177,7 @@ function error($type)
177177
}
178178

179179
// check variable type
180-
function checkType($var)
180+
public function checkType($var)
181181
{
182182
switch (gettype($var)) {
183183
case "resource":
@@ -204,20 +204,20 @@ function checkType($var)
204204
}
205205

206206
// if variable is a NULL type
207-
function varIsNULL()
207+
public function varIsNULL()
208208
{
209209
echo "NULL";
210210
}
211211

212212
// if variable is a boolean type
213-
function varIsBoolean($var)
213+
public function varIsBoolean($var)
214214
{
215215
$var = ($var == 1) ? "TRUE" : "FALSE";
216216
echo $var;
217217
}
218218

219219
// if variable is an array type
220-
function varIsArray($var)
220+
public function varIsArray($var)
221221
{
222222
$var_ser = serialize($var);
223223
array_push($this->arrHistory, $var_ser);
@@ -249,7 +249,7 @@ function varIsArray($var)
249249
}
250250

251251
// if variable is an object type
252-
function varIsObject($var)
252+
public function varIsObject($var)
253253
{
254254
$var_ser = serialize($var);
255255
array_push($this->arrHistory, $var_ser);
@@ -289,7 +289,7 @@ function varIsObject($var)
289289
}
290290

291291
// if variable is a resource type
292-
function varIsResource($var)
292+
public function varIsResource($var)
293293
{
294294
$this->makeTableHeader("resourceC", "resource", 1);
295295
echo "<tr>\n<td>\n";
@@ -318,7 +318,7 @@ function varIsResource($var)
318318
}
319319

320320
// if variable is a database resource type
321-
function varIsDBResource($var, $db = "mysql")
321+
public function varIsDBResource($var, $db = "mysql")
322322
{
323323
if ($db == "pgsql")
324324
$db = "pg";
@@ -368,7 +368,7 @@ function varIsDBResource($var, $db = "mysql")
368368
}
369369

370370
// if variable is an image/gd resource type
371-
function varIsGDResource($var)
371+
public function varIsGDResource($var)
372372
{
373373
$this->makeTableHeader("resource", "gd", 2);
374374
$this->makeTDHeader("resource", "Width");
@@ -381,13 +381,13 @@ function varIsGDResource($var)
381381
}
382382

383383
// if variable is an xml type
384-
function varIsXml($var)
384+
public function varIsXml($var)
385385
{
386386
$this->varIsXmlResource($var);
387387
}
388388

389389
// if variable is an xml resource type
390-
function varIsXmlResource($var)
390+
public function varIsXmlResource($var)
391391
{
392392
$xml_parser = xml_parser_create();
393393
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
@@ -433,7 +433,7 @@ function varIsXmlResource($var)
433433
}
434434

435435
// parse xml
436-
function xmlParse($xml_parser, $data, $bFinal)
436+
public function xmlParse($xml_parser, $data, $bFinal)
437437
{
438438
if (! xml_parse($xml_parser, $data, $bFinal)) {
439439
die(
@@ -444,7 +444,7 @@ function xmlParse($xml_parser, $data, $bFinal)
444444
}
445445

446446
// xml: inititiated when a start tag is encountered
447-
function xmlStartElement($parser, $name, $attribs)
447+
public function xmlStartElement($parser, $name, $attribs)
448448
{
449449
$this->xmlAttrib[$this->xmlCount] = $attribs;
450450
$this->xmlName[$this->xmlCount] = $name;
@@ -463,7 +463,7 @@ function xmlStartElement($parser, $name, $attribs)
463463
}
464464

465465
// xml: initiated when an end tag is encountered
466-
function xmlEndElement($parser, $name)
466+
public function xmlEndElement($parser, $name)
467467
{
468468
for ($i = 0; $i < $this->xmlCount; $i ++) {
469469
eval($this->xmlSData[$i]);
@@ -482,7 +482,7 @@ function xmlEndElement($parser, $name)
482482
}
483483

484484
// xml: initiated when text between tags is encountered
485-
function xmlCharacterData($parser, $data)
485+
public function xmlCharacterData($parser, $data)
486486
{
487487
$count = $this->xmlCount - 1;
488488
if (! empty($this->xmlCData[$count]))
@@ -492,7 +492,7 @@ function xmlCharacterData($parser, $data)
492492
}
493493

494494
// xml: initiated when a comment or other miscellaneous texts is encountered
495-
function xmlDefaultHandler($parser, $data)
495+
public function xmlDefaultHandler($parser, $data)
496496
{
497497
// strip '<!--' and '-->' off comments
498498
$data = str_replace(array(
@@ -506,7 +506,7 @@ function xmlDefaultHandler($parser, $data)
506506
$this->xmlDData[$count] = $data;
507507
}
508508

509-
function initJSandCSS()
509+
public function initJSandCSS()
510510
{
511511
echo <<<SCRIPTS
512512
<script language="JavaScript">

lib/functions/common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ function strings_stripSlashes($parameter, $bGPC = true)
586586

587587
if (is_array($parameter)) {
588588
$retParameter = null;
589-
if (count($parameter)) {
589+
if ($parameter !== []) {
590590
foreach ($parameter as $key => $value) {
591591
if (is_array($value)) {
592592
$retParameter[$key] = strings_stripSlashes($value, $bGPC);

lib/functions/csrf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ function smarty_csrf_filter($source, $smarty)
174174
*/
175175
function csrfguard_start()
176176
{
177-
if (count($_POST)) {
177+
if ($_POST !== []) {
178178
if (! isset($_POST['CSRFName'])) {
179179
redirect($_SESSION['basehref'] . 'error.php?code=1');
180180
exit();

lib/functions/print.inc.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ function renderReqForPrinting(&$db, $node, &$options, $reqLevel, $tprojectID)
286286
// since 1.9.18 => we need to use req version
287287
$attachSet = (array) $req_mgr->getAttachmentInfos($req['revision_id']);
288288

289-
if (count($attachSet)) {
289+
if ($attachSet !== []) {
290290
$output .= "<tr><td width=\"$firstColWidth\"><span class=\"label\">" .
291291
$labels['attached_files'] . "</span></td><td>";
292292

@@ -497,7 +497,7 @@ function renderReqSpecNodeForPrinting(&$db, &$node, &$options, $tocPrefix,
497497
}
498498

499499
$attachSet = (array) $req_spec_mgr->getAttachmentInfos($spec_id);
500-
if (count($attachSet)) {
500+
if ($attachSet !== []) {
501501
$output .= "<tr><td width=\"$firstColWidth\"><span class=\"label\">" .
502502
$labels['attached_files'] . "</span></td><td><ul>";
503503

@@ -1453,7 +1453,7 @@ function renderTestCaseForPrinting(&$db, &$node, &$options, $env, $context,
14531453
'" valign="top"><span class="label">' . $labels['reqs'] . '</span>';
14541454
$code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">';
14551455

1456-
if (count($requirements)) {
1456+
if ($requirements !== []) {
14571457
foreach ($requirements as $req) {
14581458
$code .= htmlspecialchars(
14591459
$req['req_doc_id'] . ": " . $req['title']) . " " .
@@ -1479,7 +1479,7 @@ function renderTestCaseForPrinting(&$db, &$node, &$options, $env, $context,
14791479
array(
14801480
'fields' => 'keyword_id,KW.keyword'
14811481
));
1482-
if (count($kwSet)) {
1482+
if ($kwSet !== []) {
14831483
foreach ($kwSet as $kw) {
14841484
$code .= htmlspecialchars($kw['keyword']) . "<br />";
14851485
}
@@ -1501,7 +1501,7 @@ function renderTestCaseForPrinting(&$db, &$node, &$options, $env, $context,
15011501
array(
15021502
'fields' => 'platform_id,PL.name'
15031503
));
1504-
if (count($itSet)) {
1504+
if ($itSet !== []) {
15051505
foreach ($itSet as $it) {
15061506
$code .= htmlspecialchars($it['name']) . "<br />";
15071507
}

lib/functions/requirement_spec_mgr.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1811,7 +1811,7 @@ public function getByDocID($doc_id, $tproject_id = null, $parent_id = null,
18111811
' GROUP BY RSPEC_REV.parent_id ';
18121812

18131813
$maxi = (array) $this->db->fetchRowsIntoMap($sql_max, 'rev_id');
1814-
if (count($maxi) > 0) {
1814+
if ($maxi !== []) {
18151815
$sql = " /* $debugMsg */ SELECT RSPEC.id,RSPEC.testproject_id,RSPEC.doc_id,NH_RSPEC.name AS title, " .
18161816
" RSPEC_REV.revision ";
18171817

lib/functions/roles.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ function checkForRights($rights, $roleQuestion, $bAND = 1)
276276
}
277277
} else {
278278
// for OR one of all must be present
279-
if (count($r)) {
279+
if ($r !== []) {
280280
$ret = 'yes';
281281
}
282282
}

lib/functions/testcase.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,7 +3253,7 @@ public function getExecStatus($id, $filters = null, $options = null)
32533253
$link_info = null;
32543254
$in_set = null;
32553255

3256-
if (count($rs)) {
3256+
if ($rs !== []) {
32573257
foreach ($rs as $idx => $elem) {
32583258
if ($elem['tcversion_number'] != $elem['version']) {
32593259
// Save to generate record for linked but not executed if needed
@@ -9645,7 +9645,7 @@ private function isLinkedTCVersion($tcVersionID, $tplanID)
96459645

96469646
$rs = (array) $this->db->get_recordset($sql);
96479647

9648-
return count($rs) > 0;
9648+
return $rs !== [];
96499649
}
96509650

96519651
/**

lib/functions/testplan.class.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ protected function helper_keywords_sql($filter, $options = null)
916916
array_shift($filter);
917917
}
918918

919-
if (count($filter)) {
919+
if ($filter !== []) {
920920
$sql['filter'] = " AND TK.keyword_id IN (" .
921921
implode(',', $filter) . ")";
922922
}
@@ -3826,7 +3826,7 @@ private function exportTestSuiteDataToXML($container, $tproject_id,
38263826

38273827
$cfMap = (array) $tsuiteMgr->get_linked_cfields_at_design(
38283828
$container['id'], null, null, $tproject_id);
3829-
if (count($cfMap) > 0) {
3829+
if ($cfMap !== []) {
38303830
$cfXML = $this->cfield_mgr->exportValueAsXML($cfMap);
38313831
}
38323832

@@ -4794,8 +4794,8 @@ public function getHitsSameStatusFullALOP($id, $statusSet, $buildSet = null,
47944794

47954795
// build results record set
47964796
$hitsFoundOn = array();
4797-
$hitsFoundOn['notRun'] = count($hits['notRun']) > 0;
4798-
$hitsFoundOn['otherStatus'] = count($hits['otherStatus']) > 0;
4797+
$hitsFoundOn['notRun'] = $hits['notRun'] !== [];
4798+
$hitsFoundOn['otherStatus'] = $hits['otherStatus'] !== [];
47994799

48004800
if ($hitsFoundOn['notRun'] && $hitsFoundOn['otherStatus']) {
48014801
$items = array_merge(array_keys($hits['notRun']),
@@ -4935,7 +4935,7 @@ public function getHitsStatusSetOnBuildPlatform($id, $platformID, $buildID,
49354935
array_keys($recordset));
49364936

49374937
$items = (array) $hits + (array) $notRunHits;
4938-
return count($items) > 0 ? $items : null;
4938+
return $items !== [] ? $items : null;
49394939
}
49404940

49414941
/**
@@ -4997,7 +4997,7 @@ public function getHitsStatusSetOnBuildALOP($id, $buildID, $statusSet)
49974997
array_keys($recordset));
49984998

49994999
$items = (array) $hits + (array) $notRunHits;
5000-
return count($items) > 0 ? $items : null;
5000+
return $items !== [] ? $items : null;
50015001
}
50025002

50035003
/**
@@ -5210,8 +5210,8 @@ public function getHitsSameStatusPartialALOP($id, $statusSet,
52105210

52115211
// build results recordset
52125212
$hitsFoundOn = array();
5213-
$hitsFoundOn['notRun'] = count($hits['notRun']) > 0;
5214-
$hitsFoundOn['otherStatus'] = count($hits['otherStatus']) > 0;
5213+
$hitsFoundOn['notRun'] = $hits['notRun'] !== [];
5214+
$hitsFoundOn['otherStatus'] = $hits['otherStatus'] !== [];
52155215

52165216
if ($get['notRun'] && $get['otherStatus']) {
52175217
if ($hitsFoundOn['notRun'] && $hitsFoundOn['otherStatus']) {
@@ -5403,8 +5403,8 @@ private function helperGetHitsSameStatusOnPlatform($mode, $id, $platformID,
54035403

54045404
// build results recordset
54055405
$hitsFoundOn = array();
5406-
$hitsFoundOn['notRun'] = count($hits['notRun']) > 0;
5407-
$hitsFoundOn['otherStatus'] = count($hits['otherStatus']) > 0;
5406+
$hitsFoundOn['notRun'] = $hits['notRun'] !== [];
5407+
$hitsFoundOn['otherStatus'] = $hits['otherStatus'] !== [];
54085408

54095409
// 20120919 - asimon - TICKET 5226: Filtering by test result did not always show the correct matches
54105410
// if($get['notRun'] && $get['otherStatus'])

lib/functions/testproject.class.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,7 @@ public function show(&$smarty, $guiObj, $template_dir, $id, $sqlResult = '',
886886
'testplan' => 'me',
887887
'requirement_spec' => 'me'
888888
);
889-
$gui->canDoExport = count(
890-
(array) $this->tree_manager->get_children($safeID, $exclusion)) > 0;
889+
$gui->canDoExport = (array) $this->tree_manager->get_children($safeID, $exclusion) !== [];
891890
if ($modded_item_id) {
892891
$gui->moddedItem = $this->get_by_id(intval($modded_item_id));
893892
}
@@ -2224,7 +2223,7 @@ public function get_all_testcases_id($idList, &$tcIDs, $options = null)
22242223
$suiteIDs[] = $row['id'];
22252224
}
22262225
}
2227-
if (count($suiteIDs)) {
2226+
if ($suiteIDs !== []) {
22282227
$suiteIDs = implode(",", $suiteIDs);
22292228
$this->get_all_testcases_id($suiteIDs, $tcIDs, $options);
22302229
}

0 commit comments

Comments
 (0)