Skip to content

Commit 6371a58

Browse files
herndlmondrejmirtes
authored andcommitted
Add allKeyExists tests
1 parent a00dad3 commit 6371a58

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tests/Type/WebMozartAssert/AssertTypeSpecifyingExtensionTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class AssertTypeSpecifyingExtensionTest extends TypeInferenceTestCase
1313
public function dataFileAsserts(): iterable
1414
{
1515
yield from $this->gatherAssertTypes(__DIR__ . '/data/array.php');
16+
yield from $this->gatherAssertTypes(__DIR__ . '/data/collection.php');
1617
yield from $this->gatherAssertTypes(__DIR__ . '/data/data.php');
1718
yield from $this->gatherAssertTypes(__DIR__ . '/data/string.php');
1819
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Type\WebMozartAssert;
4+
5+
use Webmozart\Assert\Assert;
6+
7+
class Foo
8+
{
9+
10+
/**
11+
* @param array<array{id?: int}> $a
12+
* @param array<int, array<string, mixed>> $b
13+
*
14+
*/
15+
public function allKeyExists(array $a, array $b, array $c): void
16+
{
17+
Assert::allKeyExists($a, 'id');
18+
\PHPStan\Testing\assertType('array<array{id: int}>', $a);
19+
20+
Assert::allKeyExists($b, 'id');
21+
\PHPStan\Testing\assertType('array<int, array<string, mixed>&hasOffset(\'id\')>', $b);
22+
23+
Assert::allKeyExists($c, 'id');
24+
\PHPStan\Testing\assertType('array<array&hasOffset(\'id\')>', $c);
25+
}
26+
27+
}

0 commit comments

Comments
 (0)