ZF-9417: Zend_View_Helper_Currency toString() for null and empty values

Description

I believe Zend_View_Helper_Currency should have some form of toString method in order to format null values. Currently if you supply null to the currency() method you receive the view helper as expected.

However when using database values where it may well be possible to retrieve a null value this can cause confusion and problems with the script. Whereas if null or a string was returned you wouldn't need to account for special conditions.

I think it would be nice if the currency view helper implemented a way to return null (or an empty string) itself (or in fact a default value if supplied). This way the logic wouldn't need to be carried out beforehand or after in the view script. The toString method would have the same signature as the currency method but return a string regardless of the values.

Comments

Closing as won't fix

Two things to note: You should never directly output content from a database into the view without checking it. And this means also null-values.

And there would be no way to call the toString method from the view helper directly. This would mean that you initiate the helper manually which would negotate the simple use which all view helpers actually provide ($this->currency, $this->url,...). $this->toString does not work... and $this->currency->toString would also not be ok because the currency view helper would then work different to all other view helpers.