Skip to content

Commit 8b080dc

Browse files
committed
Add regression test for non-empty-string ImpossibleCheckTypeStaticMethodCallRule problems
1 parent 160574e commit 8b080dc

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ protected function getRule(): Rule
1818

1919
public function testExtension(): void
2020
{
21+
$this->analyse([__DIR__ . '/data/bug-85.php'], []);
22+
2123
$this->analyse([__DIR__ . '/data/impossible-check.php'], [
2224
[
2325
'Call to static method Webmozart\Assert\Assert::stringNotEmpty() with \'\' will always evaluate to false.',
@@ -29,6 +31,7 @@ public function testExtension(): void
2931
public static function getAdditionalConfigFiles(): array
3032
{
3133
return [
34+
__DIR__ . '/../../../vendor/phpstan/phpstan-strict-rules/rules.neon',
3235
__DIR__ . '/../../../extension.neon',
3336
];
3437
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PHPStan\Type\WebMozartAssert;
6+
7+
use Webmozart\Assert\Assert;
8+
9+
final class Bug85
10+
{
11+
12+
public function foo(string $cityCode): void
13+
{
14+
Assert::length($cityCode, 3);
15+
Assert::upper($cityCode);
16+
}
17+
18+
/**
19+
* @param mixed $url
20+
*/
21+
function bar($url): void
22+
{
23+
Assert::stringNotEmpty($url);
24+
Assert::contains($url, '/');
25+
Assert::startsWith($url, 'https://github.com/');
26+
}
27+
28+
public function baz(string $s): void
29+
{
30+
Assert::stringNotEmpty($s);
31+
Assert::uuid($s);
32+
}
33+
34+
}

0 commit comments

Comments
 (0)