symfony/symfony — pull request #2521 by mrtorrent (2011-10-30 22:09:12+00:00)
Title: Set error code when number cannot be parsed. Fixes #2389

The stub implementation of NumberFormatter never sets an error code and instead always returns the "no-error" code. This causes unexpected results when a transformer gives it bad arguments, such as transforming the input value to boolean false and causing exceptions further down the line, as in #2389.

Instead, it should set an error code when appropriate and return it when requested so that a TransformationFailedException can be raised and the input value left unaltered.

There may be other instances where an error should be set. This covers the common use case of non-numeric input.

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2389