Skip to content

Commit 01259f5

Browse files
herndlmondrejmirtes
authored andcommitted
Add test cases for #150
1 parent 944b629 commit 01259f5

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

tests/Type/WebMozartAssert/AssertTypeSpecifyingExtensionTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function dataFileAsserts(): iterable
2020
yield from $this->gatherAssertTypes(__DIR__ . '/data/type.php');
2121

2222
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-18.php');
23+
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-150.php');
2324
}
2425

2526
/**

tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ public function testBug130(): void
237237
$this->analyse([__DIR__ . '/data/bug-130.php'], []);
238238
}
239239

240+
public function testBug150(): void
241+
{
242+
$this->analyse([__DIR__ . '/data/bug-150.php'], []);
243+
}
244+
240245
public static function getAdditionalConfigFiles(): array
241246
{
242247
return [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace WebmozartAssertBug150;
4+
5+
use Webmozart\Assert\Assert;
6+
use function PHPStan\Testing\assertType;
7+
8+
class Bug150
9+
{
10+
11+
public function doFoo($data): void
12+
{
13+
Assert::isArray($data);
14+
Assert::keyExists($data, 'sniffs');
15+
Assert::isArray($data['sniffs']);
16+
assertType("array&hasOffsetValue('sniffs', array)", $data);
17+
18+
foreach ($data['sniffs'] as $sniffName) {
19+
Assert::string($sniffName);
20+
Assert::classExists($sniffName);
21+
assertType('class-string', $sniffName);
22+
Assert::implementsInterface($sniffName, SniffInterface::class);
23+
assertType('class-string<WebmozartAssertBug150\SniffInterface>', $sniffName);
24+
}
25+
}
26+
27+
}
28+
29+
interface SniffInterface {}

0 commit comments

Comments
 (0)