Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply CountOnNullRector rule via rector #127

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Command/HelpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function execute()
$ret = $app->aggregate();

// show "General commands" title if there are more than one groups
if (count($ret['groups']) > 1 || $this->options->dev) {
if ((is_array($ret['groups']) || $ret['groups'] instanceof \Countable ? count($ret['groups']) : 0) > 1 || $this->options->dev) {
$this->logger->writeln(' '.$formatter->format('General Commands', 'strong_white'));
}
$this->layoutCommands($ret['commands']);
Expand Down
2 changes: 1 addition & 1 deletion src/CommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ public function executeWrapper(array $args)
// Validating arguments
$argInfos = $this->getArgInfoList();

for ($i = 0; $i < count($argInfos); $i++ ) {
for ($i = 0; $i < (is_array($argInfos) || $argInfos instanceof \Countable ? count($argInfos) : 0); $i++ ) {
$argInfo = $argInfos[$i];
if (isset($args[$i])) {
$arg = $args[$i];
Expand Down
4 changes: 2 additions & 2 deletions src/Completion/BashGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public function generateCompleteFunction(Buffer $buf, CommandBase $cmd, $compPre
// local argument_min_length=0
$argInfos = $cmd->getArgInfoList();
// $buf->appendLine("local argument_min_length=" . count($argInfos));
$buf->appendLine(local_bash_var('argument_min_length', count($argInfos)));
$buf->appendLine(local_bash_var('argument_min_length', is_array($argInfos) || $argInfos instanceof \Countable ? count($argInfos) : 0));


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

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

// $buf->appendLine('echo argument_index: [$argument_index]');
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Table/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function addRow($row) {

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/Debug/LineIndicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function indicateFile($file, $line)
{
$lines = file($file);
$fromIndex = max($line - 1 - $this->contextLines, 0);
$toIndex = min($line - 1 + $this->contextLines, count($lines));
$toIndex = min($line - 1 + $this->contextLines, is_array($lines) || $lines instanceof \Countable ? count($lines) : 0);

if ($fromIndex === $toIndex) {
$indexRange = [ $fromIndex ];
Expand Down
2 changes: 1 addition & 1 deletion src/ExceptionPrinter/DevelopmentExceptionPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function dumpCodeBlock(Exception $e)
$this->logger->info("Thrown from $file at line $line:\n");

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