Skip to content

Commit

Permalink
Regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Feb 5, 2025
1 parent 471b818 commit fb02c76
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/PHPStan/Rules/Comparison/ElseIfConstantConditionRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,20 @@ public function testBug11674(): void
]);
}

public function testBug6947(): void
{
if (PHP_VERSION_ID < 80000) {
$this->markTestSkipped('Test requires PHP 8.0');
}

$this->treatPhpDocTypesAsCertain = true;
$this->analyse([__DIR__ . '/data/bug-6947.php'], [
[
'Elseif condition is always false.',
11,
'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.',
],
]);
}

}
17 changes: 17 additions & 0 deletions tests/PHPStan/Rules/Comparison/data/bug-6947.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php declare(strict_types = 1);

namespace Bug6947;

abstract class HelloWorld
{
public function sayHello(): void
{
if (is_string($this->getValue())) {

} elseif (is_array($this->getValue())) {

}
}

abstract public function getValue():int|float|string|null;
}

0 comments on commit fb02c76

Please sign in to comment.