Skip to content

Commit

Permalink
Add test cases for #150
Browse files Browse the repository at this point in the history
  • Loading branch information
herndlm authored and ondrejmirtes committed Nov 3, 2022
1 parent 944b629 commit 01259f5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function dataFileAsserts(): iterable
yield from $this->gatherAssertTypes(__DIR__ . '/data/type.php');

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ public function testBug130(): void
$this->analyse([__DIR__ . '/data/bug-130.php'], []);
}

public function testBug150(): void
{
$this->analyse([__DIR__ . '/data/bug-150.php'], []);
}

public static function getAdditionalConfigFiles(): array
{
return [
Expand Down
29 changes: 29 additions & 0 deletions tests/Type/WebMozartAssert/data/bug-150.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php declare(strict_types=1);

namespace WebmozartAssertBug150;

use Webmozart\Assert\Assert;
use function PHPStan\Testing\assertType;

class Bug150
{

public function doFoo($data): void
{
Assert::isArray($data);
Assert::keyExists($data, 'sniffs');
Assert::isArray($data['sniffs']);
assertType("array&hasOffsetValue('sniffs', array)", $data);

foreach ($data['sniffs'] as $sniffName) {
Assert::string($sniffName);
Assert::classExists($sniffName);
assertType('class-string', $sniffName);
Assert::implementsInterface($sniffName, SniffInterface::class);
assertType('class-string<WebmozartAssertBug150\SniffInterface>', $sniffName);
}
}

}

interface SniffInterface {}

0 comments on commit 01259f5

Please sign in to comment.