Skip to content

Commit 90770c3

Browse files
committed
Apply CountOnNullRector rule via rector
1 parent 6e60794 commit 90770c3

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

src/Command/HelpCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public function execute()
199199
$ret = $app->aggregate();
200200

201201
// show "General commands" title if there are more than one groups
202-
if (count($ret['groups']) > 1 || $this->options->dev) {
202+
if ((is_array($ret['groups']) || $ret['groups'] instanceof \Countable ? count($ret['groups']) : 0) > 1 || $this->options->dev) {
203203
$this->logger->writeln(' '.$formatter->format('General Commands', 'strong_white'));
204204
}
205205
$this->layoutCommands($ret['commands']);

src/CommandBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ public function executeWrapper(array $args)
796796
// Validating arguments
797797
$argInfos = $this->getArgInfoList();
798798

799-
for ($i = 0; $i < count($argInfos); $i++ ) {
799+
for ($i = 0; $i < (is_array($argInfos) || $argInfos instanceof \Countable ? count($argInfos) : 0); $i++ ) {
800800
$argInfo = $argInfos[$i];
801801
if (isset($args[$i])) {
802802
$arg = $args[$i];

src/Completion/BashGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ public function generateCompleteFunction(Buffer $buf, CommandBase $cmd, $compPre
378378
// local argument_min_length=0
379379
$argInfos = $cmd->getArgInfoList();
380380
// $buf->appendLine("local argument_min_length=" . count($argInfos));
381-
$buf->appendLine(local_bash_var('argument_min_length', count($argInfos)));
381+
$buf->appendLine(local_bash_var('argument_min_length', is_array($argInfos) || $argInfos instanceof \Countable ? count($argInfos) : 0));
382382

383383

384384
$buf->append('
@@ -454,7 +454,7 @@ public function generateCompleteFunction(Buffer $buf, CommandBase $cmd, $compPre
454454
$buf->appendLine(' fi');
455455
$buf->appendLine(' # If the command requires at least $argument_min_length to run, we check the argument');
456456

457-
if (count($argInfos) > 0) {
457+
if ((is_array($argInfos) || $argInfos instanceof \Countable ? count($argInfos) : 0) > 0) {
458458
$buf->appendLine('if [[ $argument_min_length > 0 ]] ; then');
459459

460460
// $buf->appendLine('echo argument_index: [$argument_index]');

src/Component/Table/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function addRow($row) {
165165

166166
$lines = $attribute->handleTextOverflow($cell, $this->maxColumnWidth);
167167

168-
if (count($lines) == 1) {
168+
if ((is_array($lines) || $lines instanceof \Countable ? count($lines) : 0) == 1) {
169169
$lines[0] = $attribute->format($lines[0]);
170170
}
171171

src/Debug/LineIndicator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function indicateFile($file, $line)
2323
{
2424
$lines = file($file);
2525
$fromIndex = max($line - 1 - $this->contextLines, 0);
26-
$toIndex = min($line - 1 + $this->contextLines, count($lines));
26+
$toIndex = min($line - 1 + $this->contextLines, is_array($lines) || $lines instanceof \Countable ? count($lines) : 0);
2727

2828
if ($fromIndex === $toIndex) {
2929
$indexRange = [ $fromIndex ];

src/ExceptionPrinter/DevelopmentExceptionPrinter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function dumpCodeBlock(Exception $e)
126126
$this->logger->info("Thrown from $file at line $line:\n");
127127

128128
$lines = file($file);
129-
$indexRange = range(max($line - 4, 0), min($line + 3, count($lines)));
129+
$indexRange = range(max($line - 4, 0), min($line + 3, is_array($lines) || $lines instanceof \Countable ? count($lines) : 0));
130130
foreach($indexRange as $index) {
131131
if ($index == ($line - 1)) {
132132
$this->logger->warn(sprintf("> % 3d", $index + 1) . rtrim($lines[$index]));

0 commit comments

Comments
 (0)