-- Wil Moore III <[email protected]> wrote (on Wednesday, 08 September 2010, 10:34 AM -0700): > David Muir wrote: > > It's also what we get from ignoring invalid settings. > David, I agree 100%. Going forward, it would be nice if there were a way to > toggle whether exceptions are thrown or not for invalid settings/parameters. > Further, the exception message should indicate what options are available.
An unknown option is not an exceptional situation, plain and simple. It can be safely discarded without affecting operations. We ran into issues in Zend_Cache due to the fact that it was throwing exceptions on unknown options. Basically, it wouldn't work with configuration -- where you may use wholly different frontend and/or backend adapters in one environment than you'd use in another. As a result, an exception would be thrown when options were merged from one environment to another. We ended up removing the exception-throwing code to make these operations possible. For ZF2, what we *will* be doing is better documenting available options, and standardizing how options are represented: * All option keys will be lowercase and underscore_separated. * All components will include an "options" page detailing all options, and the values they accept. The only time unknown options are an issue is when you have mis-spelled or otherwise introduced a typographical error into an option key. The above changes should address most such issues by making it easier to verify whether you've specified a valid key. Having a switch for debugging these issues means additional overhead within the framework and in maintenance -- and may not even assist you! If you are relying on option merging as described above, once you "flip the switch" to throw exceptions, you may never get to the code you're trying to debug in the first place! -- Matthew Weier O'Phinney Project Lead | [email protected] Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
