for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SilverStripe\Logging\Tests\DetailedErrorFormatterTest;
use Exception;
use SilverStripe\Dev\TestOnly;
/**
* WARNING: This file is sensitive to whitespace changes
*/
class ErrorGenerator implements TestOnly
{
* Generate an exception with a trace depeth of at least 4
*
* @param int $depth
* @return Exception
* @throws Exception
public function mockException($depth = 0)
switch ($depth) {
case 0:
try {
$this->mockException(1);
} catch (\Exception $ex) {
return $ex;
}
return null;
break;
break
The break statement is not necessary if it is preceded for example by a return statement:
switch ($x) { case 1: return 'foo'; break; // This break is not necessary and can be left off. }
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.
case 4:
throw new Exception('Error');
default:
return $this->mockException($depth + 1);
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.