Skip to content

Commit d34fd3d

Browse files
Add non regression tests
1 parent 14dc54c commit d34fd3d

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,11 @@ public function testBug12748(): void
986986
$this->analyse([__DIR__ . '/data/bug-12748.php'], []);
987987
}
988988

989+
public function testBug3803(): void
990+
{
991+
$this->analyse([__DIR__ . '/data/bug-3803.php'], []);
992+
}
993+
989994
public function testBug11019(): void
990995
{
991996
$this->analyse([__DIR__ . '/data/bug-11019.php'], []);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug3803;
4+
5+
/** @param array<string> $chars */
6+
function fun(array $chars) : void{
7+
$string = "";
8+
foreach($chars as $k => $v){
9+
$string[$k] = $v;
10+
}
11+
if($string === "wheee"){
12+
var_dump("yes");
13+
}
14+
}
15+
16+
fun(["w", "h", "e", "e", "e"]);

tests/PHPStan/Rules/Variables/UnsetRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public function testBug4289(): void
6565
$this->analyse([__DIR__ . '/data/bug-4289.php'], []);
6666
}
6767

68+
public function testBug4204(): void
69+
{
70+
$this->analyse([__DIR__ . '/data/bug-4204.php'], []);
71+
}
72+
6873
public function testBug5223(): void
6974
{
7075
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-5223.php'], [
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug4204;
4+
5+
interface Block
6+
{
7+
public function getSettings(): mixed;
8+
}
9+
10+
class HelloWorld
11+
{
12+
/**
13+
* @param array<int, object> $blocks
14+
*/
15+
public function sayHello(array $blocks): void
16+
{
17+
foreach ($blocks as $block) {
18+
$settings = $block->getSettings();
19+
20+
if (isset($settings['name'])) {
21+
// switch name with code key
22+
$settings['code'] = $settings['name'];
23+
unset($settings['name']);
24+
}
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)