Skip to content

Commit 96f6aec

Browse files
committed
Remove constructor from ResourceInformation
1 parent 478e190 commit 96f6aec

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

phpstan.neon

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ parameters:
22
level: 8
33
paths:
44
- src
5+
ignoreErrors:
6+
- '#Property .+::[\$a-zA-Z]+ is never written, only read\.#'
57
includes:
68
- vendor/phpstan/phpstan-strict-rules/rules.neon
7-
- phpstan-baseline.neon
9+
- phpstan-baseline.neon

src/Struct/Generic/ResourceInformation.php

+7-10
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@
99
*/
1010
class ResourceInformation implements ResourceInformationInterface
1111
{
12-
public function __construct(
13-
private readonly int $id,
14-
private readonly string $name,
15-
private readonly string $url,
16-
private readonly int $typeId,
17-
private readonly int $folderId,
18-
private readonly int $mandatorId,
19-
private readonly int $lastModified,
20-
) {
21-
}
12+
private int $id;
13+
private string $name;
14+
private string $url;
15+
private int $typeId;
16+
private int $folderId;
17+
private int $mandatorId;
18+
private int $lastModified;
2219

2320
public function getId(): int
2421
{

tests/Struct/Generic/ResourceInformationTest.php

+16-9
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,24 @@ class ResourceInformationTest extends StructTestCase
88
{
99
private ResourceInformation $subject;
1010

11+
private array $expectedValues = [
12+
'id' => 123,
13+
'name' => 'some name',
14+
'url' => 'some url',
15+
'typeId' => 5,
16+
'folderId' => 9,
17+
'mandatorId' => 989,
18+
'lastModified' => 44455,
19+
];
20+
1121
public function setUp(): void
1222
{
13-
$this->subject = new ResourceInformation(
14-
123,
15-
'some name',
16-
'some url',
17-
5,
18-
9,
19-
989,
20-
44455
21-
);
23+
$this->subject = new ResourceInformation();
24+
$reflection = new \ReflectionClass($this->subject);
25+
26+
foreach ($reflection->getProperties() as $property) {
27+
$property->setValue($this->subject, $this->expectedValues[$property->getName()]);
28+
}
2229
}
2330

2431
public function testGetIdCanReturnInt(): void

0 commit comments

Comments
 (0)