Skip to content

Commit 2788472

Browse files
committed
Add tests
1 parent a1bc0e0 commit 2788472

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

tests/PHPStan/Rules/Classes/InstantiationRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,4 +499,9 @@ public function testBug10248(): void
499499
$this->analyse([__DIR__ . '/data/bug-10248.php'], []);
500500
}
501501

502+
public function testBug11815(): void
503+
{
504+
$this->analyse([__DIR__ . '/data/bug-11815.php'], []);
505+
}
506+
502507
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php // lint >= 8.0
2+
3+
declare(strict_types = 1);
4+
5+
class Dimensions
6+
{
7+
public function __construct(
8+
public int $width,
9+
public int $height,
10+
) {
11+
}
12+
}
13+
14+
class StoreProcessorResult
15+
{
16+
public function __construct(
17+
public string $path,
18+
public string $mimetype,
19+
public Dimensions $dimensions,
20+
public int $filesize,
21+
public true|null $identical = null,
22+
) {
23+
}
24+
}
25+
26+
/**
27+
* @return array{path: string, identical?: true}
28+
*/
29+
function getPath(): array
30+
{
31+
$data = ['path' => 'some/path'];
32+
if ((bool)rand(0, 1)) {
33+
$data['identical'] = true;
34+
}
35+
return $data;
36+
}
37+
38+
$data = getPath();
39+
$data['dimensions'] = new Dimensions(100, 100);
40+
$data['mimetype'] = 'image/png';
41+
$data['filesize'] = 123456;
42+
43+
$dto = new StoreProcessorResult(...$data);

0 commit comments

Comments
 (0)