Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build/baseline-pre-8.0.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
parameters:
ignoreErrors:
-
identifier: method.childReturnType
count: 2
path: ../tests/PHPStan/Command/Symfony/SymfonyOutputTest.php

-
message: '#^Call to function method_exists\(\) with ReflectionFunction and ''getClosureCalledCla…'' will always evaluate to false\.$#'
identifier: function.impossibleType
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Symfony/SymfonyOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function isDebug(): bool

public function isDecorated(): bool
{
return $this->symfonyOutput->isDecorated();
return (bool) $this->symfonyOutput->isDecorated(); // @phpstan-ignore cast.useless
}

}
47 changes: 47 additions & 0 deletions tests/PHPStan/Command/Symfony/SymfonyOutputTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php declare(strict_types = 1);

namespace PHPStan\Command\Symfony;

use Override;
use PHPStan\Command\OutputStyle;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\NullOutput;

final class SymfonyOutputTest extends TestCase
{

/**
* @return iterable<string, array{mixed, bool}>
*/
public static function dataIsDecorated(): iterable
{
yield 'preg_match hit' => [1, true];
yield 'preg_match miss' => [0, false];
yield 'already true' => [true, true];
yield 'already false' => [false, false];
}

#[DataProvider('dataIsDecorated')]
public function testIsDecoratedReturnsBool(mixed $symfonyValue, bool $expected): void
{
$symfonyOutput = new class($symfonyValue) extends NullOutput {

public function __construct(private mixed $value)
{
}

#[Override]
public function isDecorated(): mixed
{
return $this->value;
}

};

$output = new SymfonyOutput($symfonyOutput, $this->createStub(OutputStyle::class));

self::assertSame($expected, $output->isDecorated());
}

}
Loading