From 890cfa2d7d8ec5441e8fc8171a559ab37d3e8b03 Mon Sep 17 00:00:00 2001 From: david-scarratt-lrn Date: Thu, 9 May 2024 12:04:05 +1000 Subject: [PATCH] Remove code features unsupported by older versions of PHP LRN-43664 --- src/Services/PreHashStringFactory.php | 5 ++++- src/Services/PreHashStrings/LegacyPreHashString.php | 12 ++++++++---- tests/Request/InitTest.php | 12 ++++++++++++ tests/Services/LegacySignaturesTest.php | 2 +- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/Services/PreHashStringFactory.php b/src/Services/PreHashStringFactory.php index b5ae08f..5642e71 100644 --- a/src/Services/PreHashStringFactory.php +++ b/src/Services/PreHashStringFactory.php @@ -13,7 +13,10 @@ class PreHashStringFactory LegacyPreHashString::class, ]; - protected array $validServices; + /** + * @var array + */ + protected /* array */ $validServices; public function __construct() { diff --git a/src/Services/PreHashStrings/LegacyPreHashString.php b/src/Services/PreHashStrings/LegacyPreHashString.php index dd36839..c5d76bd 100644 --- a/src/Services/PreHashStrings/LegacyPreHashString.php +++ b/src/Services/PreHashStrings/LegacyPreHashString.php @@ -94,11 +94,15 @@ class LegacyPreHashString implements PreHashStringInterface 'domain', ]; - /** Service name to generate a pre-hash string for */ - protected string $service; + /** Service name to generate a pre-hash string for + * @var string + */ + protected /* string */ $service; - /** V1-compat strings need the secret to be part of the pre-hash string */ - protected bool $v1Compat; + /** V1-compat strings need the secret to be part of the pre-hash string + * @var bool + */ + protected /* bool */ $v1Compat; public function __construct(string $service, bool $v1Compat = false) { diff --git a/tests/Request/InitTest.php b/tests/Request/InitTest.php index b25cf7c..aaf496a 100644 --- a/tests/Request/InitTest.php +++ b/tests/Request/InitTest.php @@ -153,6 +153,9 @@ public function testNullRequestPacketAndActionGeneratesValidInit() $this->assertInstanceOf(Init::class, $initObject); } + /** + * @requires PHPUnit >= 9.6 + */ public function testMetaWithTelemetryOnlyAddsSdkProp() { list($service, $security, $secret, $request, $action) = ParamsFixture::getWorkingQuestionsApiParams(); @@ -170,6 +173,9 @@ public function testMetaWithTelemetryOnlyAddsSdkProp() $this->assertEquals(1, count((array) $generatedObject->meta)); } + /** + * @requires PHPUnit >= 9.6 + */ public function testRequestWithTelemetryPreservesOtherMetaProps() { list($service, $security, $secret, $request, $action) = ParamsFixture::getWorkingQuestionsApiParams(); @@ -195,6 +201,9 @@ public function testRequestWithTelemetryPreservesOtherMetaProps() $this->assertObjectHasProperty('sdk', $generatedObject->meta); } + /** + * @requires PHPUnit >= 9.6 + */ public function testRequestWithoutTelemetryPreservesEmptyMeta() { // We disable telemetry to be able to reliably test signature generation. Added telemetry @@ -210,6 +219,9 @@ public function testRequestWithoutTelemetryPreservesEmptyMeta() $this->assertObjectNotHasProperty('meta', $generatedObject); } + /** + * @requires PHPUnit >= 9.6 + */ public function testRequestWithoutTelemetryPreservesFilledMeta() { // We disable telemetry to be able to reliably test signature generation. Added telemetry diff --git a/tests/Services/LegacySignaturesTest.php b/tests/Services/LegacySignaturesTest.php index e6b1064..e0cbe1f 100644 --- a/tests/Services/LegacySignaturesTest.php +++ b/tests/Services/LegacySignaturesTest.php @@ -11,7 +11,7 @@ class LegacySignaturesTest extends AbstractTestCase { - private SignatureFactory $signatureFactory; + private $signatureFactory; public function setUp(): void {