Skip to content

Commit e9d80c6

Browse files
committed
fix phpstan
1 parent ac2023f commit e9d80c6

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

tests/system/Entity/EntityTest.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,7 @@ public function testHasChangedPrefersJsonSerializableOverToArray(): void
20252025
];
20262026
};
20272027

2028-
$entity->data = new class ('original') implements JsonSerializable {
2028+
$data = new class ('original') implements JsonSerializable {
20292029
public function __construct(private string $value)
20302030
{
20312031
}
@@ -2040,14 +2040,19 @@ public function setValue(string $value): void
20402040
$this->value = $value;
20412041
}
20422042

2043+
/**
2044+
* @return array<string, string>
2045+
*/
20432046
public function toArray(): array
20442047
{
20452048
return ['array' => 'same'];
20462049
}
20472050
};
2051+
2052+
$entity->data = $data;
20482053
$entity->syncOriginal();
20492054

2050-
$entity->data->setValue('modified');
2055+
$data->setValue('modified');
20512056

20522057
$this->assertTrue($entity->hasChanged('data'));
20532058
}
@@ -2363,15 +2368,20 @@ public function testHasChangedPrefersToArrayOverTraversable(): void
23632368
];
23642369
};
23652370

2366-
$entity->items = new class (['iterator' => 'original']) extends ArrayObject {
2371+
$items = new class (['iterator' => 'original']) extends ArrayObject {
2372+
/**
2373+
* @return array<string, string>
2374+
*/
23672375
public function toArray(): array
23682376
{
23692377
return ['array' => 'same'];
23702378
}
23712379
};
2380+
2381+
$entity->items = $items;
23722382
$entity->syncOriginal();
23732383

2374-
$entity->items->exchangeArray(['iterator' => 'modified']);
2384+
$items->exchangeArray(['iterator' => 'modified']);
23752385

23762386
$this->assertFalse($entity->hasChanged('items'));
23772387
}
@@ -2384,15 +2394,20 @@ public function testHasChangedPrefersToArrayOverDateTimeInterface(): void
23842394
];
23852395
};
23862396

2387-
$entity->date = new class ('2024-01-01 00:00:00') extends DateTime {
2397+
$date = new class ('2024-01-01 00:00:00') extends DateTime {
2398+
/**
2399+
* @return array<string, string>
2400+
*/
23882401
public function toArray(): array
23892402
{
23902403
return ['date' => 'same'];
23912404
}
23922405
};
2406+
2407+
$entity->date = $date;
23932408
$entity->syncOriginal();
23942409

2395-
$entity->date->modify('+1 day');
2410+
$date->modify('+1 day');
23962411

23972412
$this->assertFalse($entity->hasChanged('date'));
23982413
}

0 commit comments

Comments
 (0)