Apply CountOnNullRector rule via rector #127
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Applying the
CountOnNullRectorrule via the rector.6/6 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 6 files with changes ==================== 1) src/ExceptionPrinter/DevelopmentExceptionPrinter.php:125 ---------- begin diff ---------- @@ @@ $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])); ----------- end diff ----------- Applied rules: * CountOnNullRector (https://3v4l.org/Bndc9) 2) src/Debug/LineIndicator.php:22 ---------- begin diff ---------- @@ @@ { $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 ]; ----------- end diff ----------- Applied rules: * CountOnNullRector (https://3v4l.org/Bndc9) 3) src/Component/Table/Table.php:164 ---------- begin diff ---------- @@ @@ $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]); } ----------- end diff ----------- Applied rules: * CountOnNullRector (https://3v4l.org/Bndc9) 4) src/Completion/BashGenerator.php:377 ---------- begin diff ---------- @@ @@ // 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(' @@ @@ $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]'); ----------- end diff ----------- Applied rules: * CountOnNullRector (https://3v4l.org/Bndc9) 5) src/CommandBase.php:795 ---------- begin diff ---------- @@ @@ // 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]; ----------- end diff ----------- Applied rules: * CountOnNullRector (https://3v4l.org/Bndc9) 6) src/Command/HelpCommand.php:198 ---------- begin diff ---------- @@ @@ $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']); ----------- end diff ----------- Applied rules: * CountOnNullRector (https://3v4l.org/Bndc9)