Skip to content

Commit 2df1a59

Browse files
committed
1 parent f6b34f2 commit 2df1a59

6 files changed

+70
-0
lines changed

tests/PHPStan/Rules/Comparison/BooleanOrConstantConditionRuleTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -438,4 +438,11 @@ public function testBug6551(): void
438438
$this->analyse([__DIR__ . '/data/bug-6551.php'], []);
439439
}
440440

441+
public function testBug4004(): void
442+
{
443+
$this->treatPhpDocTypesAsCertain = true;
444+
$this->reportAlwaysTrueInLastCondition = true;
445+
$this->analyse([__DIR__ . '/data/bug-4004.php'], []);
446+
}
447+
441448
}

tests/PHPStan/Rules/Comparison/IfConstantConditionRuleTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,16 @@ public function testBug4302(): void
150150
$this->analyse([__DIR__ . '/data/bug-4302.php'], []);
151151
}
152152

153+
public function testBug7491(): void
154+
{
155+
$this->treatPhpDocTypesAsCertain = true;
156+
$this->analyse([__DIR__ . '/data/bug-7491.php'], []);
157+
}
158+
159+
public function testBug2499(): void
160+
{
161+
$this->treatPhpDocTypesAsCertain = true;
162+
$this->analyse([__DIR__ . '/data/bug-2499.php'], []);
163+
}
164+
153165
}

tests/PHPStan/Rules/Comparison/UnreachableIfBranchesRuleTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,10 @@ public function testBug8562(): void
130130
$this->analyse([__DIR__ . '/data/bug-8562.php'], []);
131131
}
132132

133+
public function testBug7491(): void
134+
{
135+
$this->treatPhpDocTypesAsCertain = true;
136+
$this->analyse([__DIR__ . '/data/bug-7491.php'], []);
137+
}
138+
133139
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Bug2499;
4+
5+
function (): void {
6+
$value = 123;
7+
8+
if ($value = $_GET['name'] and is_string($value)) {
9+
echo $value;
10+
}
11+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Bug4004;
4+
5+
function (): void {
6+
$pupKey = '';
7+
$privateR = '';
8+
9+
$original = "I just wanna tell you how I'm feeling\nGotta make you understand";
10+
$encrypted = '';
11+
$decrypted = '';
12+
13+
if (! @\openssl_public_encrypt($original, $encrypted, $pupKey, OPENSSL_PKCS1_OAEP_PADDING)) {
14+
throw new \Exception('Unable to encrypt data, invalid key provided?');
15+
}
16+
17+
if (! @\openssl_private_decrypt($encrypted, $decrypted, $privateR, OPENSSL_PKCS1_OAEP_PADDING) || $decrypted !== $original) {
18+
throw new \Exception();
19+
}
20+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Bug7491;
4+
5+
function test(string $text = ''): bool {
6+
$world = preg_match('/\b(world)$/i', $text, $matches) === false ? '' : ($matches[1] ?? '');
7+
if ($world == '') {
8+
echo "Not found\n";
9+
return false;
10+
} else {
11+
echo "Found '$world'\n";
12+
return true;
13+
}
14+
}

0 commit comments

Comments
 (0)