Skip to content

Commit 5f4d4f1

Browse files
author
Timothy Elias
committed
[BUGFIX] Fix PHP 8.4 and phpUnit deprecations
- Implicitly marking parameter as nullable is deprecated, the explicit nullable type must be used instead - Metadata found in doc-comment for method [Class]::method (). Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12
1 parent ab74564 commit 5f4d4f1

7 files changed

Lines changed: 27 additions & 62 deletions

File tree

Classes/Driver/AmazonS3Driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class AmazonS3Driver extends AbstractHierarchicalFilesystemDriver implements Str
186186
* @param array $configuration
187187
* @param S3Client $s3Client
188188
*/
189-
public function __construct(array $configuration = [], $s3Client = null, EventDispatcherInterface $eventDispatcher = null)
189+
public function __construct(array $configuration = [], $s3Client = null, ?EventDispatcherInterface $eventDispatcher = null)
190190
{
191191
parent::__construct($configuration);
192192
$this->eventDispatcher = $eventDispatcher ?? GeneralUtility::makeInstance(EventDispatcherInterface::class);

Classes/S3Adapter/AbstractS3Adapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AbstractS3Adapter
3232
* AbstractS3Adapter constructor.
3333
* @param S3Client $s3Client
3434
*/
35-
public function __construct(S3Client $s3Client = null)
35+
public function __construct(?S3Client $s3Client = null)
3636
{
3737
$this->s3Client = $s3Client;
3838
}

Tests/Unit/Driver/AmazonS3DriverTest.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Aws\Api\DateTimeResult;
1818
use Aws\Result;
1919
use Aws\S3\S3Client;
20+
use PHPUnit\Framework\Attributes\Test;
2021
use PHPUnit\Framework\TestCase;
2122
use Prophecy\Argument;
2223
use Prophecy\PhpUnit\ProphecyTrait;
@@ -114,9 +115,7 @@ public function tearDown(): void
114115
parent::tearDown();
115116
}
116117

117-
/**
118-
* @test
119-
*/
118+
#[Test]
120119
public function testPublicUrlGetter()
121120
{
122121
$assertedMappings = [
@@ -131,25 +130,19 @@ public function testPublicUrlGetter()
131130
}
132131
}
133132

134-
/**
135-
* @test
136-
*/
133+
#[Test]
137134
public function testDefaultFolderGetter()
138135
{
139136
$this->assertEquals('/', $this->driver->getDefaultFolder());
140137
}
141138

142-
/**
143-
* @test
144-
*/
139+
#[Test]
145140
public function testRootLevelFolderGetter()
146141
{
147142
$this->assertEquals('/', $this->driver->getRootLevelFolder());
148143
}
149144

150-
/**
151-
* @test
152-
*/
145+
#[Test]
153146
public function testGetFileInfoByIdentifier()
154147
{
155148
$fileIdentifier = 'foo/bar/test.file';
@@ -182,9 +175,7 @@ public function testGetFileInfoByIdentifier()
182175
$this->assertEquals($this->driver->getStorageUid(), $info['storage']);
183176
}
184177

185-
/**
186-
* @test
187-
*/
178+
#[Test]
188179
public function testGetFileInfoByIdentifierWithLimitedProperties()
189180
{
190181
$fileIdentifier = 'foo/bar/test.file';
@@ -206,9 +197,7 @@ public function testGetFileInfoByIdentifierWithLimitedProperties()
206197
}
207198

208199

209-
/**
210-
* @test
211-
*/
200+
#[Test]
212201
public function testGetFileInfoByIdentifierWithPseudoMimeType()
213202
{
214203
$fileIdentifier = 'foo/bar/test.youtube';

Tests/Unit/Index/ExtractorTest.php

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use AUS\AusDriverAmazonS3\Driver\AmazonS3Driver;
1717
use AUS\AusDriverAmazonS3\Index\Extractor;
18+
use PHPUnit\Framework\Attributes\Test;
1819
use PHPUnit\Framework\TestCase;
1920
use Prophecy\PhpUnit\ProphecyTrait;
2021
use TYPO3\CMS\Core\Resource\File;
@@ -44,9 +45,7 @@ public function setUp(): void
4445
$this->extractor = new Extractor();
4546
}
4647

47-
/**
48-
* @test
49-
*/
48+
#[Test]
5049
public function testCanProcessImageFileType()
5150
{
5251
$storage = $this->prophesize(ResourceStorage::class);
@@ -59,9 +58,7 @@ public function testCanProcessImageFileType()
5958
$this->assertEquals(true, $this->extractor->canProcess($file->reveal()));
6059
}
6160

62-
/**
63-
* @test
64-
*/
61+
#[Test]
6562
public function testCanNotProcessOtherDriverType()
6663
{
6764
$storage = $this->prophesize(ResourceStorage::class);
@@ -74,9 +71,7 @@ public function testCanNotProcessOtherDriverType()
7471
$this->assertEquals(false, $this->extractor->canProcess($file->reveal()));
7572
}
7673

77-
/**
78-
* @test
79-
*/
74+
#[Test]
8075
public function testCanNotProcessUnknownFileType()
8176
{
8277
$storage = $this->prophesize(ResourceStorage::class);
@@ -89,9 +84,7 @@ public function testCanNotProcessUnknownFileType()
8984
$this->assertEquals(false, $this->extractor->canProcess($file->reveal()));
9085
}
9186

92-
/**
93-
* @test
94-
*/
87+
#[Test]
9588
public function testCanNotProcessApplicationFileType()
9689
{
9790
$storage = $this->prophesize(ResourceStorage::class);
@@ -104,9 +97,7 @@ public function testCanNotProcessApplicationFileType()
10497
$this->assertEquals(false, $this->extractor->canProcess($file->reveal()));
10598
}
10699

107-
/**
108-
* @test
109-
*/
100+
#[Test]
110101
public function testCanNotProcessVideoFileType()
111102
{
112103
$storage = $this->prophesize(ResourceStorage::class);
@@ -119,9 +110,7 @@ public function testCanNotProcessVideoFileType()
119110
$this->assertEquals(false, $this->extractor->canProcess($file->reveal()));
120111
}
121112

122-
/**
123-
* @test
124-
*/
113+
#[Test]
125114
public function testCanNotProcessAudioFileType()
126115
{
127116
$storage = $this->prophesize(ResourceStorage::class);
@@ -134,9 +123,7 @@ public function testCanNotProcessAudioFileType()
134123
$this->assertEquals(false, $this->extractor->canProcess($file->reveal()));
135124
}
136125

137-
/**
138-
* @test
139-
*/
126+
#[Test]
140127
public function testCanNotProcessTextFileType()
141128
{
142129
$storage = $this->prophesize(ResourceStorage::class);
@@ -149,9 +136,7 @@ public function testCanNotProcessTextFileType()
149136
$this->assertEquals(false, $this->extractor->canProcess($file->reveal()));
150137
}
151138

152-
/**
153-
* @test
154-
*/
139+
#[Test]
155140
public function testExtractMetaDataIfRequired()
156141
{
157142
$file = $this->prophesize(File::class);
@@ -166,9 +151,7 @@ public function testExtractMetaDataIfRequired()
166151
);
167152
}
168153

169-
/**
170-
* @test
171-
*/
154+
#[Test]
172155
public function testExtractNoMetaDataIfNotRequired()
173156
{
174157
$file = $this->prophesize(File::class);

Tests/Unit/S3Adapter/MetaInfoDownloadAdapterTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use AUS\AusDriverAmazonS3\Driver\AmazonS3Driver;
1717
use AUS\AusDriverAmazonS3\S3Adapter\MetaInfoDownloadAdapter;
1818
use Aws\Api\DateTimeResult;
19+
use PHPUnit\Framework\Attributes\Test;
1920
use PHPUnit\Framework\TestCase;
2021
use Prophecy\PhpUnit\ProphecyTrait;
2122
use Prophecy\Prophecy\ObjectProphecy;
@@ -55,9 +56,7 @@ public function setUp(): void
5556
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][FileInfo::class]['mimeTypeGuessers'][MimeTypeCompatibilityTypeGuesser::class] = MimeTypeCompatibilityTypeGuesser::class . '->guessMimeType';
5657
}
5758

58-
/**
59-
* @test
60-
*/
59+
#[Test]
6160
public function getMetaInfoFromResponseTest()
6261
{
6362
// prepare test data
@@ -95,9 +94,7 @@ public function getMetaInfoFromResponseTest()
9594
$this->assertEquals(42, $metaInfo['storage']);
9695
}
9796

98-
/**
99-
* @test
100-
*/
97+
#[Test]
10198
public function getMetaInfoFromResponseWithPseudoMimeTypeTest()
10299
{
103100
// prepare test data

Tests/Unit/S3Adapter/MultipartUploaderAdapterTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace AUS\AusDriverAmazonS3\Tests\Unit\S3Adapter;
66

77
use AUS\AusDriverAmazonS3\S3Adapter\MultipartUploaderAdapter;
8+
use PHPUnit\Framework\Attributes\Test;
89
use PHPUnit\Framework\TestCase;
910

1011
class MultipartUploaderAdapterTest extends TestCase
@@ -17,9 +18,7 @@ public function setUp(): void
1718
$this->multipartUploaderAdapter = new MultipartUploaderAdapter();
1819
}
1920

20-
/**
21-
* @test
22-
*/
21+
#[Test]
2322
public function detectContentTypeTest()
2423
{
2524
$fixtures = dirname(__FILE__) . '/../Fixtures/MultipartUploaderAdapter/';

Tests/Unit/Service/MetaDataUpdateServiceTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use AUS\AusDriverAmazonS3\Driver\AmazonS3Driver;
1717
use AUS\AusDriverAmazonS3\Index\Extractor;
1818
use AUS\AusDriverAmazonS3\Service\MetaDataUpdateService;
19+
use PHPUnit\Framework\Attributes\Test;
1920
use PHPUnit\Framework\TestCase;
2021
use Prophecy\PhpUnit\ProphecyTrait;
2122
use Prophecy\Prophecy\ObjectProphecy;
@@ -32,9 +33,7 @@ class MetaDataUpdateServiceTest extends TestCase
3233
{
3334
use ProphecyTrait;
3435

35-
/**
36-
* @test
37-
*/
36+
#[Test]
3837
public function testRecordUpdatedOrCreatedDoNotHandleUnknownFileType()
3938
{
4039
$file = $this->prophesize(File::class)->reveal();
@@ -49,9 +48,7 @@ public function testRecordUpdatedOrCreatedDoNotHandleUnknownFileType()
4948
]);
5049
}
5150

52-
/**
53-
* @test
54-
*/
51+
#[Test]
5552
public function testRecordUpdatedOrCreatedDoNotHandleApplicationFileType()
5653
{
5754
$file = $this->prophesize(File::class)->reveal();

0 commit comments

Comments
 (0)