From b9b798ad481312321e912674cd16f9a6619bbda6 Mon Sep 17 00:00:00 2001 From: Radek Prochazka Date: Tue, 28 Jul 2026 09:07:04 +0200 Subject: [PATCH] fix: avoid "null as array offset" deprecation on PHP 8.5 in RW Co-Authored-By: Claude Fable 5 --- src/AbraFlexi/RW.php | 4 ++-- tests/src/AbraFlexi/RWTest.php | 34 +++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/AbraFlexi/RW.php b/src/AbraFlexi/RW.php index 72b94d7b..61623a36 100644 --- a/src/AbraFlexi/RW.php +++ b/src/AbraFlexi/RW.php @@ -211,7 +211,7 @@ public function assignResultIDs($candidates): void { foreach ($this->chained as $chid => $chained) { $chainedEvidence = $chained->getEvidence(); - $chainedExtid = $chained->getRecordID(); + $chainedExtid = $chained->getRecordID() ?? ''; if (\is_array($chainedExtid)) { // if there are more IDs foreach ($chainedExtid as $extId) { // find external ID in format ext:..... @@ -253,7 +253,7 @@ public function extractResultIDs($resultInfo) if (\array_key_exists('request-id', $insertResult)) { $extid = $insertResult['request-id']; } else { - $extid = null; + $extid = ''; } $evidence = explode('/', $insertResult['ref'])[3]; diff --git a/tests/src/AbraFlexi/RWTest.php b/tests/src/AbraFlexi/RWTest.php index 2f98b882..384b82b1 100644 --- a/tests/src/AbraFlexi/RWTest.php +++ b/tests/src/AbraFlexi/RWTest.php @@ -100,17 +100,29 @@ protected function tearDown(): void // $this->markTestIncomplete('This test has not been implemented yet.'); // } // - // /** - // * @covers \AbraFlexi\RW::extractResultIDs - // * - // * @todo Implement testextractResultIDs(). - // */ - // public function testextractResultIDs(): void - // { - // $this->assertEquals('', $this->object->extractResultIDs()); - // // Remove the following lines when you implement this test. - // $this->markTestIncomplete('This test has not been implemented yet.'); - // } + /** + * @covers \AbraFlexi\RW::extractResultIDs + */ + public function testextractResultIDs(): void + { + $resultInfo = [ + [ + 'id' => 123, + 'request-id' => 'ext:originalId:1', + 'ref' => '/c/demo/faktura-vydana/123.json', + ], + [ + 'id' => 124, + 'ref' => '/c/demo/faktura-vydana/124.json', + ], + ]; + + $this->assertSame( + ['faktura-vydana' => ['ext:originalId:1' => 123, '' => 124]], + $this->object->extractResultIDs($resultInfo), + ); + } + // // /** // * @covers \AbraFlexi\RW::getLastInsertedId