Behat/Behat — pull request #254 by adlawson (2013-03-05 13:38:05+00:00)
Title: Prefer registered format dispatcher over autoloaded formatters

Fixes compatibility issues with certain autoloaders (Zend_Loader_Autoloader in particular)

The call to `class_exists()` falls back to the spl_autoloader unless passed with a second argument of `false`. This would be usual behaviour if the autoloader stack was full of PSR-0 style autoloaders.

In the case that my FeatureContext uses libraries that require alternative autoloaders (such as ZF1), calling `class_exists()` triggers an error:

PHP Warning: include_once(pretty.php): failed to open stream: No such file or directory in /path/to/project/lib/Zend/Loader.php on line 146

![Screen Shot 2013-03-05 at 13 35 38](https://f.cloud.github.com/assets/200351/221402/9ee53458-8599-11e2-9599-3248ee7da9ee.png)

You could argue that the autoloader should handle this more gracefully, but the fact is that `pretty.php` will never and should never exist. It should invoke the formatter registered with the name `pretty` instead of expecting the autoloader to gracefully fail.

My solution moves the call to the autoloader into the `elseif` condition if the named formatter is not registered.

Thanks,
Andrew.