Skip to content

Commit a27f5e8

Browse files
committed
PHP 8.1 syntax in tests too
1 parent 08dfbb9 commit a27f5e8

File tree

4 files changed

+10
-35
lines changed

4 files changed

+10
-35
lines changed

tests/Api/FilteredFieldResolverTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,11 @@ public function __isInitialized(): bool
6868
public function testLoad($value, $expected): void
6969
{
7070
$model = new class($value) {
71-
/**
72-
* @var mixed
73-
*/
74-
private $value;
75-
7671
/**
7772
* @param mixed $value
7873
*/
79-
public function __construct($value)
74+
public function __construct(private $value)
8075
{
81-
$this->value = $value;
8276
}
8377

8478
/**

tests/Api/Scalar/AbstractDecimalTypeTest.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,9 @@ private function createType(int $decimal, ?string $minimum, ?string $maximum): A
1818
return new class($decimal, $minimum, $maximum) extends AbstractDecimalType {
1919
public $name = 'TestDecimal';
2020

21-
private int $decimal;
22-
23-
private ?string $minimum;
24-
25-
private ?string $maximum;
26-
27-
public function __construct(int $decimal, ?string $minimum, ?string $maximum)
21+
public function __construct(private readonly int $decimal, private readonly ?string $minimum, private readonly ?string $maximum)
2822
{
2923
parent::__construct([]);
30-
$this->decimal = $decimal;
31-
$this->minimum = $minimum;
32-
$this->maximum = $maximum;
3324
}
3425

3526
protected function getScale(): int

tests/ORM/Query/Filter/AclFilterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ public function testExceptionWillReEnableFilter(): void
108108
$filter = new AclFilter($this->entityManager);
109109

110110
try {
111-
$filter->runWithoutAcl(function (): void {
111+
$filter->runWithoutAcl(function (): never {
112112
throw new Exception();
113113
});
114-
} catch (Exception $e) {
114+
} catch (Exception) {
115115
}
116116

117117
self::assertNotSame('', $filter->addFilterConstraint($targetEntity, 'test'), 'enabled even after exception');

tests/Service/ImageResizerTest.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,12 @@ class ImageResizerTest extends TestCase
1818
*/
1919
public function testResize(string $extension, int $wantedHeight, bool $useWebp, string $expected): void
2020
{
21-
switch ($extension) {
22-
case 'png':
23-
$mime = 'image/png';
24-
25-
break;
26-
case 'svg':
27-
$mime = 'image/svg+xml';
28-
29-
break;
30-
case 'tiff':
31-
$mime = 'image/tiff';
32-
33-
break;
34-
default:
35-
throw new Exception('Unsupported extension: ' . $extension);
36-
}
21+
$mime = match ($extension) {
22+
'png' => 'image/png',
23+
'svg' => 'image/svg+xml',
24+
'tiff' => 'image/tiff',
25+
default => throw new Exception('Unsupported extension: ' . $extension),
26+
};
3727

3828
$imagineImage = $this->createMock(ImageInterface::class);
3929
$imagineImage->expects(self::any())->method('thumbnail')->willReturnSelf();

0 commit comments

Comments
 (0)