sebastianbergmann/phpcpd — pull request #93 by elkuku (2014-04-04 00:52:55+00:00)
Title: Return the number of clones instead of exiting.

Hello,
I'd like to use phpcpd from within another application and in conjunction with other QA tools like phpcs, phpunit etc. being installed using Composer.
I use the following code:
```php
class MyApplication...
{
someFunction()
{
$application = new \SebastianBergmann\PHPCPD\CLI\Application;

$application->setAutoExit(false);

$cloneCount = $application->run(
new ArrayInput(
['values' => [
JPATH_ROOT . '/cli',
JPATH_ROOT . '/src'
]]
)
);
// more code..
}
}
```
which works fine except the fact that if clones are found phpcpd will `exit()` so my application "dies"...

So the idea here is to return the number of clones found (or zero) instead of hard exiting. I know this a a bit "unorthodox", but it works. The only limit here would be that only 255 clones will be displayed as this is the maximum error status, but well ;)

Another (and of course "cleaner") option would be to return `1`, so the SymphonyApplication will exit with this status code (if `autoExit` isn't set to `false`).

BTW: here is a Travis log of our custom script invoking phpcs and phpunit using a similar technique described earlier: https://travis-ci.org/joomla/jissues/jobs/21904034
The scripts invoking those can be found here: https://github.com/joomla/jissues/tree/master/cli/Application/Command/Test
This is a Joomla! Application :wink: