Normalise currency codes in CurrencyHelper#41
Merged
Conversation
Trim and uppercase codes (and defaults) before lookup so lowercase or padded input resolves the correct currency class, guarding against the PHP 8.1 null-to-string deprecation when both code and default are null. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Jleagle
approved these changes
Jul 9, 2026
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.
Summary
CurrencyHelper::getCurrency()now trims and uppercases the incoming code before building the class name, so lowercase or whitespace-padded input ('usd ',"\tusd\n") resolves the correct currency class — this previously failed on case-sensitive filesystems where PSR-4 autoloading is path-sensitive.?:fallback so a null code with a null default no longer passes null totrim()(PHP 8.1 deprecation, TypeError in PHP 9) — keeps the guarantees from Guard string functions against null input (PHP 8.1 deprecation) #40 intact.listAllCurrencies()normalises constant values so returned array keys are always canonical.Test plan
tests/Currency/CurrencyTest.phpcovering case/whitespace normalisation, fallback to (lowercase/padded) defaults, and the throw paths for invalid, invalid-with-invalid-default, and null input.UnknownTest).getCurrency(null)witherror_reporting=E_ALLto confirm it throws cleanly with no string-function warnings.🤖 Generated with Claude Code