fix: PHP 8.5 "Using null as an array offset" deprecation in RW - #111
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthrough
ChangesExternal ID normalization
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/AbraFlexi/RW.php (1)
214-214: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression coverage for the null chained-ID path.
The new
null-to-''behavior inassignResultIDs()is not covered by the added test. Add a PHPUnit case wheregetRecordID()returnsnulland verify that the chained object is matched through the empty-string candidate key.As per coding guidelines, updated classes should include applicable PHPUnit coverage and be well-tested.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/AbraFlexi/RW.php` at line 214, Add PHPUnit regression coverage for assignResultIDs() where chained->getRecordID() returns null, asserting the chained object is matched using the empty-string candidate key. Reuse the existing test fixtures and expectations for chained ID assignment, changing only the ID setup needed to exercise the null-to-empty-string path.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/AbraFlexi/RW.php`:
- Around line 253-257: Normalize both missing and explicitly null request IDs to
an empty string in the $extid assignment within src/AbraFlexi/RW.php lines
253-260, using null coalescing or an equivalent null check. Add coverage in
tests/src/AbraFlexi/RWTest.php lines 108-123 for an upstream response with
request-id set to null, verifying it is grouped under the empty-string key.
---
Nitpick comments:
In `@src/AbraFlexi/RW.php`:
- Line 214: Add PHPUnit regression coverage for assignResultIDs() where
chained->getRecordID() returns null, asserting the chained object is matched
using the empty-string candidate key. Reuse the existing test fixtures and
expectations for chained ID assignment, changing only the ID setup needed to
exercise the null-to-empty-string path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 0c8694af-4f21-4af0-a188-fb2fd3ae2dd5
📒 Files selected for processing (2)
src/AbraFlexi/RW.phptests/src/AbraFlexi/RWTest.php
|
@fesak001 Thank you for your Fable tokens! :D
|

PHP 8.5 deprecates using
nullas an array offset (Using null as an array offset is deprecated, use an empty string instead). The deprecation is emitted for writes, reads,isset()and??alike.Two places in
RW.phpuse a possibly-null value as an array key:extractResultIDs()sets$extid = nullwhen an insert result carries norequest-id, then writes$candidates[$evidence][$extid]. We hit this in production on PHP 8.5.8 (hundreds of log entries per day when inserting invoices).assignResultIDs()uses$chained->getRecordID()as a lookup key, andgetRecordID()may returnnull.Since PHP has always coerced a
nulloffset to''(which is exactly what the deprecation message suggests), replacingnullwith''keeps the behavior identical on all PHP versions, including the interplay between the two methods (a record inserted withoutrequest-idis still found under the same key).Also implements the previously stubbed
testextractResultIDs()to cover both branches (with and withoutrequest-id).Tested with PHPUnit on PHP 8.5.8,
php-cs-fixerclean.Summary by CodeRabbit
Bug Fixes
Tests