Skip to content

Commit 228f7a9

Browse files
committed
Added tests
1 parent 0bea0f2 commit 228f7a9

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

tests/PHPStan/Rules/Comparison/IfConstantConditionRuleTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,11 @@ public function testBug13384b(): void
194194
]);
195195
}
196196

197+
public function testBug7699(): void
198+
{
199+
$this->treatPhpDocTypesAsCertain = true;
200+
$this->analyse([__DIR__ . '/data/bug-7699.php'], []);
201+
}
202+
203+
197204
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Bug7699;
4+
5+
$selections = isset($_GET['x']) ? explode(',', $_GET['x']) : [];
6+
while ($selections && $id = array_shift($selections)) {
7+
if ($selections) {
8+
var_dump('x');
9+
}
10+
}

tests/PHPStan/Rules/Variables/IssetRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,4 +506,12 @@ public function testBug10640(): void
506506
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-10640.php'], []);
507507
}
508508

509+
public function testBug9503(): void
510+
{
511+
$this->treatPhpDocTypesAsCertain = true;
512+
513+
$this->analyse([__DIR__ . '/data/bug-9503.php'], []);
514+
}
515+
516+
509517
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Bug9503;
4+
5+
class HelloWorld
6+
{
7+
public function sayHello(string $str): bool
8+
{
9+
if (preg_match('~x(a)?(b)?~', $str, $matches) > 0) {
10+
if (isset($matches[2]) && preg_match('~x2(a)?(b)?~', $matches[2], $matches) > 0) {
11+
if (isset($matches[2])) {
12+
return true;
13+
}
14+
}
15+
}
16+
17+
return false;
18+
}
19+
}

0 commit comments

Comments
 (0)