Skip to content

Commit c7328f5

Browse files
committed
Add regression tests for 118, 119 and 130
1 parent 3506d61 commit c7328f5

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

tests/Type/WebMozartAssert/ImpossibleCheckTypeMethodCallRuleTest.php

+15
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,21 @@ public function testBug85(): void
179179
$this->analyse([__DIR__ . '/data/bug-85.php'], []);
180180
}
181181

182+
public function testBug118(): void
183+
{
184+
$this->analyse([__DIR__ . '/data/bug-118.php'], []);
185+
}
186+
187+
public function testBug119(): void
188+
{
189+
$this->analyse([__DIR__ . '/data/bug-119.php'], []);
190+
}
191+
192+
public function testBug130(): void
193+
{
194+
$this->analyse([__DIR__ . '/data/bug-130.php'], []);
195+
}
196+
182197
public static function getAdditionalConfigFiles(): array
183198
{
184199
return [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WebmozartAssertBug118;
6+
7+
use DateTime;
8+
use Webmozart\Assert\Assert;
9+
10+
function test(float $a, DateTime $b): void
11+
{
12+
Assert::range($a, 0, 1);
13+
Assert::range($b, 123456789, 9876543321);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WebmozartAssertBug119;
6+
7+
use DateTime;
8+
use Webmozart\Assert\Assert;
9+
10+
function test(float $a, float $b, float $c, float $d, DateTime $e): void
11+
{
12+
Assert::greaterThan($a, 0);
13+
Assert::greaterThanEq($b, 0);
14+
Assert::lessThan($c, 0);
15+
Assert::lessThanEq($d, 0);
16+
Assert::greaterThanEq($e, 639828000);
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace PHPStan\Type\WebMozartAssert;
4+
5+
use Webmozart\Assert\Assert;
6+
7+
class Bug130
8+
{
9+
/** @var array<int, array{id: string, num_order: string}> */
10+
protected $orders = [];
11+
12+
public function setOrders(array $orders): self
13+
{
14+
Assert::allCount($orders, 2);
15+
Assert::allKeyExists($orders, 'id');
16+
Assert::allKeyExists($orders, 'num_order');
17+
18+
$this->orders = $orders;
19+
20+
return $this;
21+
}
22+
}

0 commit comments

Comments
 (0)