for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
<?php
declare(strict_types = 1);
namespace Zenify\CodingStandard\Tests\Sniffs\Classes\FinalInterface;
use PHPUnit\Framework\TestCase;
use Zenify\CodingStandard\Tests\CodeSnifferRunner;
use ZenifyCodingStandard\Sniffs\Classes\FinalInterfaceSniff;
final class FinalInterfaceSniffTest extends TestCase
{
public function testDetection()
$codeSnifferRunner = new CodeSnifferRunner(FinalInterfaceSniff::NAME);
$this->assertSame(1, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/wrong.php'));
$this->assertSame(0, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/correct.php'));
$this->assertSame(0, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/correct2.php'));
$this->assertSame(0, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/correct3.php'));
$this->assertSame(0, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/correct4.php'));
}
public function testFixing()
$fixedContent = $codeSnifferRunner->getFixedContent(__DIR__ . '/wrong.php');
$this->assertSame(file_get_contents(__DIR__ . '/wrong-fixed.php'), $fixedContent);