Repository navigation
fix: remove null array offsets from InputDataContainer - #21
Closed
csemazharul wants to merge 1 commit into
Closed
csemazharul wants to merge 1 commit into
csemazharul wants to merge 1 commit into
Conversation
PHP 8.5 deprecates null as an array offset, including inside isset(). PR #20 guarded one read with `$key &&`, which left the unset attribute key paths deprecated and made falsy keys fall through, so `same:0` compared a field to itself and passed on a mismatch. Keep attributeKey non-null and check $key with `!== null`. Flatten getAttributeValue() to early returns. Raise the minimum PHP version to 7.4 and update rector.php and CLAUDE.md to match. Closes #19 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #19
Problem
PHP 8.5 deprecates
nullas an array offset, including insideisset(). On 1.2.3, everyValidatorrun hit this inInputDataContainer::getAttributeValue(), and the notice leaked into REST responses in Bit CRM. PHP 8.4 does not emit it, despite the issue title.PR #20 fixed the main path with
$key && isset($data[$key]), but two problems remained:nulloffset when no attribute key had been set.$key &&treats0and'0'as no key, sosame:0compared the field to itself and passed on a mismatch.Changes
attributeKeynow defaults to'', andsetAttributeKey()turnsnullinto''. PHP already treated anulloffset as'', so stored data is unchanged.$keyis checked with!== null, which restores falsy keys.getAttributeValue()is flattened to early returns, with no behaviour change.tests/InputDataContainerTest.php.composer.json, withrector.phpandCLAUDE.mdupdated to match.Before merging or releasing
same:0bug.getAttributeKey()now returns''instead ofnullbefore a key is set. Nothing insrc/relies onnull, but an outside caller checking=== nullwould notice.Testing
src/src/on PHP 8.5getAttributeValue()rewrite, old vs newThe CI matrix stops at PHP 8.4, so CI does not exercise the PHP 8.5 deprecation. The new deprecation tests pass trivially on older versions.
Not addressed
samehas two older bugs, also present in 1.2.3, which this PR leaves unchanged:same:passwordpasses whenpasswordis absent, because the lookup falls back to the field's own value.a.b,same:othercompares the field to itself.🤖 Generated with Claude Code