Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector\Fixture;

use PHPUnit\Framework\TestCase;

final class DynamicBool extends TestCase
{
public function testIsHeaderLine(string $line, bool $expected): void
{
$this->assertEquals($expected, $this->returnsBool($line));
}

public function returnsBool(): bool {
return rand(0,1) ? true : false;
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector\Fixture;

use PHPUnit\Framework\TestCase;

final class DynamicBool extends TestCase
{
public function testIsHeaderLine(string $line, bool $expected): void
{
$this->assertSame($expected, $this->returnsBool($line));
}

public function returnsBool(): bool {
return rand(0,1) ? true : false;
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Scalar\InterpolatedString;
use PHPStan\Type\BooleanType;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\FloatType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\StringType;
Expand Down Expand Up @@ -143,7 +145,11 @@ private function isScalarType(Type $valueNodeType): bool
}
}

return false;
if ($valueNodeType instanceof ConstantBooleanType) {
return false;
}

return $valueNodeType instanceof BooleanType;
}

private function isScalarOrEnumValue(Expr $expr): bool
Expand Down
Loading