Zend Framework

Zend_Currency::toCurrency() options

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.10.5
  • Fix Version/s: 1.10.6
  • Component/s: Zend_Currency
  • Labels:
    None

Description

I think there is a bug in Zend/Currency.php, Line: 140:

if (is_array($value) && isset($options['value'])) {

.. which should be :

if (isset($options['value'])) {

.. because if variable $value is strictly null it will never by an array and 'value' from the options array will be skipped and the one from $this->_options will be used.

Activity

Hide
Thomas Weidner added a comment -

The framework code works like expected.
Please give some reproduceable code for the problem you have.

Show
Thomas Weidner added a comment - The framework code works like expected. Please give some reproduceable code for the problem you have.
Hide
Aurimas Likas added a comment -

$currency = new Zend_Currency(
array(
'value' => 1000,
)
);

echo $currency->toCurrency(null, array('value' => 2000)); // 1000

I think it should return 2000. Though if it is expected behavior the statement in Line #139 remains pointless:

if ($value === null) {
if (is_array($value) && isset($options['value'])) {

because null !== array()

Show
Aurimas Likas added a comment - $currency = new Zend_Currency( array( 'value' => 1000, ) ); echo $currency->toCurrency(null, array('value' => 2000)); // 1000 I think it should return 2000. Though if it is expected behavior the statement in Line #139 remains pointless: if ($value === null) { if (is_array($value) && isset($options['value'])) { because null !== array()
Hide
Thomas Weidner added a comment -

Fixed with r22369

Show
Thomas Weidner added a comment - Fixed with r22369

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: