for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace BestIt\Helper;
use PHP_CodeSniffer_File;
/**
* Class FixerHelper
*
* @package BestIt\Helper
* @author Nick Lubisch <[email protected]>
*/
class FixerHelper
{
* Removes the given line.
* @param PHP_CodeSniffer_File $file The php cs file.
* @param int $line The line which is to be removed
* @return void
public static function removeLine(PHP_CodeSniffer_File $file, $line)
foreach ($file->getTokens() as $tagPtr => $tagToken) {
if ($tagToken['line'] !== $line) {
continue;
}
$file->fixer->replaceToken($tagPtr, '');
* Removes lines by given start and end.
* @param PHP_CodeSniffer_File $file The php cs file
* @param int $startLine The first line which is to be removed
* @param int $endLine The last line which is to be removed
public static function removeLines(PHP_CodeSniffer_File $file, $startLine, $endLine)
for ($line = $startLine; $line <= $endLine; $line++) {
self::removeLine($file, $line);