Skip to content

Commit

Permalink
Fix type error when using paths intersection mode
Browse files Browse the repository at this point in the history
  • Loading branch information
julienfalque committed Jan 2, 2023
1 parent 72cf37c commit 9a8fb76
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Console/Command/FixCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$progressType = $resolver->getProgress();
$finder = $resolver->getFinder();
$finder = new \ArrayIterator(iterator_to_array($resolver->getFinder()));

if (null !== $stdErr && $resolver->configFinderIsOverridden()) {
$stdErr->writeln(
Expand All @@ -283,7 +283,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ('none' === $progressType || null === $stdErr) {
$progressOutput = new NullOutput();
} else {
$finder = new \ArrayIterator(iterator_to_array($finder));
$progressOutput = new ProcessOutput(
$stdErr,
$this->eventDispatcher,
Expand Down
4 changes: 4 additions & 0 deletions src/Console/ConfigurationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,10 @@ private function resolveOptionBooleanValue(string $optionName): bool
{
$value = $this->options[$optionName];

if (\is_bool($value)) {
return $value;
}

if (!\is_string($value)) {
throw new InvalidConfigurationException(sprintf('Expected boolean or string value for option "%s".', $optionName));
}
Expand Down
13 changes: 13 additions & 0 deletions tests/Console/Command/FixCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use PhpCsFixer\Console\Command\FixCommand;
use PhpCsFixer\Tests\TestCase;
use PhpCsFixer\ToolInfo;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Tester\CommandTester;

Expand All @@ -29,6 +30,18 @@
*/
final class FixCommandTest extends TestCase
{
public function testIntersectionPathMode(): void
{
$cmdTester = $this->doTestExecute([
'--path-mode' => 'intersection',
]);

static::assertSame(
Command::SUCCESS,
$cmdTester->getStatusCode()
);
}

public function testEmptyRulesValue(): void
{
$this->expectException(
Expand Down

0 comments on commit 9a8fb76

Please sign in to comment.