Skip to content

Commit

Permalink
trigger an error if non-numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
demeritcowboy committed Mar 29, 2021
1 parent 027ef84 commit 7652b05
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CRM/Utils/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ protected static function formatUSLocaleNumericRounded($amount, int $numberOfPla
if (!extension_loaded('intl') || !is_numeric($amount)) {
// @todo - we should not attempt to format non-numeric strings. For now
// these will not fail but will give notices on php 7.4
self::missingIntlNotice();
if (!is_numeric($amount)) {
CRM_Core_Error::deprecatedWarning('Formatting non-numeric values is no longer supported: ' . htmlspecialchars($amount));
}
else {
self::missingIntlNotice();
}
return self::formatNumericByFormat($amount, '%!.' . $numberOfPlaces . 'i');
}
$money = Money::of($amount, CRM_Core_Config::singleton()->defaultCurrency, new CustomContext($numberOfPlaces), RoundingMode::HALF_UP);
Expand Down

0 comments on commit 7652b05

Please sign in to comment.