Fixes and beautifies custom code according to Drupal Coding standards.

@command source:fix:php-standards

@aliases sfps fix phpcbf fix:phpcbf
543166
public function phpcbfFileSet() {
    $this->say('Fixing and beautifying code...');

    $bin = $this->getConfigValue('composer.bin');
    $result = $this->taskExec("$bin/phpcbf")
      ->dir($this->getConfigValue('repo.root'))
      ->run();

    $exit_code = $result->getExitCode();
    // - 0 indicates that no fixable errors were found.
    // - 1 indicates that all fixable errors were fixed correctly.
    // - 2 indicates that PHPCBF failed to fix some of the fixable errors.
    // - 3 is used for general script execution errors.
    switch ($exit_code) {
      case 0:
        $this->say('<info>No fixable errors were found, and so nothing was fixed.</info>');
        return 0;

      case 1:
        $this->say('<comment>Please note that exit code 1 does not indicate an error for PHPCBF.</comment>');
        $this->say('<info>All fixable errors were fixed correctly. There may still be errors that could not be fixed automatically.</info>');
        return 0;

      case 2:
        $this->logger->warning('PHPCBF failed to fix some of the fixable errors it found.');
        return $exit_code;

      default:
        throw new BltException("PHPCBF failed.");
    }
  }
632401
public static function initialise_cfg() {
        global $DB;
        $dbhash = false;
        try {
            $dbhash = $DB->get_field('config', 'value', array('name'=>'phpunittest'));
        } catch (Exception $e) {
            // not installed yet
            initialise_cfg();
            return;
        }
        if ($dbhash !== core_component::get_all_versions_hash()) {
            // do not set CFG - the only way forward is to drop and reinstall
            return;
        }
        // standard CFG init
        initialise_cfg();
    }
478917
function html_php()
	{
		
		?>
<div class="wp-box">
	<div class="title">
		<h3><?php _e("Export Field Groups to PHP",'acf'); ?></h3>
	</div>
	<table class="acf_input widefat">
		<tr>
			<td class="label">
<h3><?php _e("Instructions",'acf'); ?></h3>
<ol>
	<li><?php _e("Copy the PHP code generated",'acf'); ?></li>
	<li><?php _e("Paste into your functions.php file",'acf'); ?></li>
	<li><?php _e("To activate any Add-ons, edit and use the code in the first few lines.",'acf'); ?></li>
</ol>

<p><br /></p>

<h3><?php _e("Notes",'acf'); ?></h3>
<p><?php _e("Registered field groups <b>will not</b> appear in the list of editable field groups. This is useful for including fields in themes.",'acf'); ?></p>
<p><?php _e("Please note that if you export and register field groups within the same WP, you will see duplicate fields on your edit screens. To fix this, please move the original field group to the trash or remove the code from your functions.php file.",'acf'); ?></p>


<p><br /></p>

<h3><?php _e("Include in theme",'acf'); ?></h3>
<p><?php _e("The Advanced Custom Fields plugin can be included within a theme. To do so, move the ACF plugin inside your theme and add the following code to your functions.php file:",'acf'); ?></p>

<pre>
include_once('advanced-custom-fields/acf.php');
</pre>

<p><?php _e("To remove all visual interfaces from the ACF plugin, you can use a constant to enable lite mode. Add the following code to your functions.php file <b>before</b> the include_once code:",'acf'); ?></p>

<pre>
define( 'ACF_LITE', true );
</pre>
 
<p><br /></p>

<p><a href="">&laquo; <?php _e("Back to export",'acf'); ?></a></p>
			</td>
			<td>
				<textarea class="pre" readonly="true"><?php
		
		$acfs = array();
		
		if( isset($_POST['acf_posts']) )
		{
			$acfs = get_posts(array(
				'numberposts' 	=> -1,
				'post_type' 	=> 'acf',
				'orderby' 		=> 'menu_order title',
				'order' 		=> 'asc',
				'include'		=>	$_POST['acf_posts'],
				'suppress_filters' => false,
			));
		}
		if( $acfs )
		{
			?>
if(function_exists("register_field_group"))
{
<?php
			foreach( $acfs as $i => $acf )
			{
				// populate acfs
				$var = array(
					'id' => $acf->post_name,
					'title' => $acf->post_title,
					'fields' => apply_filters('acf/field_group/get_fields', array(), $acf->ID),
					'location' => apply_filters('acf/field_group/get_location', array(), $acf->ID),
					'options' => apply_filters('acf/field_group/get_options', array(), $acf->ID),
					'menu_order' => $acf->menu_order,
				);
				
				
				$var['fields'] = apply_filters('acf/export/clean_fields', $var['fields']);


				// create html
				$html = var_export($var, true);
				
				// change double spaces to tabs
				$html = str_replace("  ", "\t", $html);
				
				// correctly formats "=> array("
				$html = preg_replace('/([\t\r\n]+?)array/', 'array', $html);
				
				// Remove number keys from array
				$html = preg_replace('/[0-9]+ => array/', 'array', $html);
				
				// add extra tab at start of each line
				$html = str_replace("\n", "\n\t", $html);
				
				// add the WP __() function to specific strings for translation in theme
				//$html = preg_replace("/'label'(.*?)('.*?')/", "'label'$1__($2)", $html);
				//$html = preg_replace("/'instructions'(.*?)('.*?')/", "'instructions'$1__($2)", $html);
				
								
?>	register_field_group(<?php echo $html ?>);
<?php
			}
?>
}
<?php
		}
		else
		{
			_e("No field groups were selected",'acf');
		}
				?></textarea>
			</td>
		</tr>
	</table>
</div>
<script type="text/javascript">
(function($){
	
	var i = 0;
	
	$(document).on('click', 'textarea.pre', function(){
		
		if( i == 0 )
		{
			i++;
			
			$(this).focus().select();
			
			return false;
		}
				
	});
	
	$(document).on('keyup', 'textarea.pre', function(){
	
	    $(this).height( 0 );
	    $(this).height( this.scrollHeight );
	
	});

	$(document).ready(function(){
		
		$('textarea.pre').trigger('keyup');

	});

})(jQuery);
</script>
	<?php
	}
265896
public function main()
    {
        if (!class_exists('PHP_CodeSniffer')) {
            @include_once 'PHP/CodeSniffer.php';

            if (!class_exists('PHP_CodeSniffer')) {
                throw new BuildException(
                    "This task requires the PHP_CodeSniffer package installed and available on the include path",
                    $this->getLocation()
                );
            }
        }

        /**
         * Determine PHP_CodeSniffer version number
         */
        if (!$this->skipversioncheck) {
            if (defined('PHP_CodeSniffer::VERSION')) {
                preg_match('/\d\.\d\.\d/', PHP_CodeSniffer::VERSION, $version);
            } else {
                preg_match('/\d\.\d\.\d/', shell_exec('phpcs --version'), $version);
            }

            if (version_compare($version[0], '1.2.2') < 0) {
                throw new BuildException(
                    'PhpCodeSnifferTask requires PHP_CodeSniffer version >= 1.2.2',
                    $this->getLocation()
                );
            }
        }

        if (!isset($this->file) and count($this->filesets) == 0) {
            throw new BuildException("Missing either a nested fileset or attribute 'file' set");
        }

        if (count($this->formatters) == 0) {
            // turn legacy format attribute into formatter
            $fmt = new PhpCodeSnifferTaskFormatterElement();
            $fmt->setType($this->format);
            $fmt->setUseFile(false);
            $this->formatters[] = $fmt;
        }

        $fileList = $this->getFilesToParse();

        $cwd = getcwd();

        // Save command line arguments because it confuses PHPCS (version 1.3.0)
        $oldArgs = $_SERVER['argv'];
        $_SERVER['argv'] = [];
        $_SERVER['argc'] = 0;

        $codeSniffer = new PhpCodeSnifferTaskWrapper($this->verbosity, $this->tabWidth, $this->encoding);
        $codeSniffer->setAllowedFileExtensions($this->allowedFileExtensions);
        if ($this->allowedTypes) {
            PhpCodeSnifferTaskWrapper::$allowedTypes = $this->allowedTypes;
        }
        if (is_array($this->ignorePatterns)) {
            $codeSniffer->setIgnorePatterns($this->ignorePatterns);
        }
        foreach ($this->configData as $configData) {
            $codeSniffer::setConfigData($configData->getName(), $configData->getValue(), true);
        }

        /*
         * Verifying if standard is installed only after setting config data.
         * Custom standard paths could be provided via installed_paths config parameter.
         */
        foreach ($this->standards as $standard) {
            if (PHP_CodeSniffer::isInstalledStandard($standard) === false) {
                // They didn't select a valid coding standard, so help them
                // out by letting them know which standards are installed.
                $installedStandards = PHP_CodeSniffer::getInstalledStandards();
                $numStandards = count($installedStandards);
                $errMsg = '';

                if ($numStandards === 0) {
                    $errMsg = 'No coding standards are installed.';
                } else {
                    $lastStandard = array_pop($installedStandards);

                    if ($numStandards === 1) {
                        $errMsg = 'The only coding standard installed is ' . $lastStandard;
                    } else {
                        $standardList = implode(', ', $installedStandards);
                        $standardList .= ' and ' . $lastStandard;
                        $errMsg = 'The installed coding standards are ' . $standardList;
                    }
                }

                throw new BuildException(
                    'ERROR: the "' . $standard . '" coding standard is not installed. ' . $errMsg,
                    $this->getLocation()
                );
            }
        }

        if (!$this->showWarnings) {
            $codeSniffer->cli->warningSeverity = 0;
        }

        // nasty integration hack
        $values = $codeSniffer->cli->getDefaults();
        $_SERVER['argv'] = ['t'];
        $_SERVER['argc'] = 1;
        foreach ($this->formatters as $fe) {
            if ($fe->getUseFile()) {
                $_SERVER['argv'][] = '--report-' . $fe->getType() . '=' . $fe->getOutfile();
            } else {
                $_SERVER['argv'][] = '--report-' . $fe->getType();
            }

            $_SERVER['argc']++;
        }

        if ($this->cache) {
            ReportsPhingRemoveFromCache::setCache($this->cache);
            // add a fake report to remove from cache
            $_SERVER['argv'][] = '--report-phingRemoveFromCache';
            $_SERVER['argc']++;
        }

        $codeSniffer->process($fileList, $this->standards, $this->sniffs, $this->noSubdirectories);
        $_SERVER['argv'] = [];
        $_SERVER['argc'] = 0;

        if ($this->cache) {
            ReportsPhingRemoveFromCache::setCache(null);
            $this->cache->commit();
        }

        $this->printErrorReport($codeSniffer);

        // generate the documentation
        if ($this->docGenerator !== '' && $this->docFile !== null) {
            ob_start();

            $codeSniffer->generateDocs($this->standards, $this->sniffs, $this->docGenerator);

            $output = ob_get_contents();
            ob_end_clean();

            // write to file
            $outputFile = $this->docFile->getPath();
            $check = file_put_contents($outputFile, $output);

            if ($check === false) {
                throw new BuildException('Error writing doc to ' . $outputFile);
            }
        } elseif ($this->docGenerator !== '' && $this->docFile === null) {
            $codeSniffer->generateDocs($this->standards, $this->sniffs, $this->docGenerator);
        }

        if ($this->haltonerror && $codeSniffer->reporting->totalErrors > 0) {
            throw new BuildException('phpcodesniffer detected ' . $codeSniffer->reporting->totalErrors . ' error' . ($codeSniffer->reporting->totalErrors > 1 ? 's' : ''));
        }

        if ($this->haltonwarning && $codeSniffer->reporting->totalWarnings > 0) {
            throw new BuildException('phpcodesniffer detected ' . $codeSniffer->reporting->totalWarnings . ' warning' . ($codeSniffer->reporting->totalWarnings > 1 ? 's' : ''));
        }

        $_SERVER['argv'] = $oldArgs;
        $_SERVER['argc'] = count($oldArgs);
        chdir($cwd);
    }
1019595
public function clean()
	{
		// So the task doesn't complain,
		// make any 'missing' dirs to cleanup
		array_map(function ($dir) {
			if ( ! is_dir($dir))
			{
				`mkdir -p {$dir}`;
			}
		}, $this->cleanDirs);

		$this->_cleanDir($this->cleanDirs);
		$this->_deleteDir($this->cleanDirs);
	}

	/**
	 * Run unit tests and generate coverage reports
	 */
	public function coverage()
	{
		$this->_run(['phpdbg -qrr -- vendor/bin/phpunit -c build']);
	}

	/**
	 * Generate documentation with phpdox
	 */
	public function docs()
	{
		$this->_run(['vendor/bin/phpdox']);
	}

	/**
	 * Verify that source files are valid
	 */
	public function lint()
	{
		$files = $this->getAllSourceFiles();

		$chunks = array_chunk($files, (int)`getconf _NPROCESSORS_ONLN`);

		foreach($chunks as $chunk)
		{
			$this->parallelLint($chunk);
		}
	}

	/**
	 * Run the phpcs tool
	 *
	 * @param bool $report - if true, generates reports instead of direct output
	 */
	public function phpcs($report = FALSE)
	{
		$dir = __DIR__;

		$report_cmd_parts = [
			'vendor/bin/phpcs',
			"--standard=./build/CodeIgniter",
			"--report-checkstyle=./build/logs/phpcs.xml",
		];

		$normal_cmd_parts = [
			'vendor/bin/phpcs',
			"--standard=./build/CodeIgniter",
		];

		$cmd_parts = ($report) ? $report_cmd_parts : $normal_cmd_parts;

		$this->_run($cmd_parts);
	}
992844
private function handleLineNotEmpty(File $phpcsFile, int $whitespacePtr): void
    {
        $fixSpaceNotScndLine = $phpcsFile->addFixableError(
            self::ERROR_LINE_NOT_EMPTY,
            $whitespacePtr,
            static::CODE_LINE_NOT_EMPTY
        );

        if ($fixSpaceNotScndLine) {
            $phpcsFile->fixer->beginChangeset();
            $phpcsFile->fixer->replaceToken(
                $whitespacePtr,
                ''
            );
            $phpcsFile->fixer->endChangeset();
        }
    }
402429
public function runCs()
    {

        // run the code sniffer
        $this->_exec(
            sprintf(
                '%s/bin/phpcs -n --report-full --extensions=php --standard=phpcs.xml --report-checkstyle=%s/reports/phpcs.xml %s',
                $this->getVendorDir(),
                $this->getTargetDir(),
                $this->getSrcDir()
            )
        );
    }
1361206
public function html($code)
    {
        if ($this->sdopx->parsingType == Sdopx::PARSING_SQL) {
            if ($code != '') {
                if (trim($code) == '') {
                    $this->output[] = ' ';
                    return;
                } else {
                    if (preg_match('@^\s+([\w\W]+)\s+$@', $code, $mt)) {
                        $this->output[] = ' ' . trim($mt[1]) . ' ';
                    } else if (preg_match('@^\s+([\w\W]+)$@', $code, $mt)) {
                        $this->output[] = ' ' . trim($mt[1]);
                    } else if (preg_match('@^([\w\W]+)\s+$@', $code, $mt)) {
                        $this->output[] = trim($mt[1]) . ' ';
                    } else {
                        $this->output[] = $code;
                    }
                    return;
                }
            }
            return;
        }
        $this->output[] = $code;
    }
1020716
function compileSass(sassPaths, cb) {

        if (sassPaths.length > 0) {

            var path = pathModule.join(base, sassPaths.shift());

            sass.render({
              file: path,
              includePaths: options.includePaths || []
            },
            function(err, result) {
                if (err) {
                    cb(FOUND_ERROR, 'Error while compiling sass template "' + path + '". Error from "node-sass" plugin: ' + err);
                }

                if (options.autoprefixer) {
                  // Call autoprefixer on current built css
                  postcss([ autoprefixer(options.autoprefixer) ])
                    .process(result.css)
                    .then(function(prefixedResult) {
                      // escape any backticks that comeup in the compiled css
                      cb(FOUND_SUCCESS, prefixedResult.css.toString().replace(/\\([\s\S])|(`)/g,"\\$1$2"), sassPaths);
                    });
                } else {
                  // escape any backticks that comeup in the compiled css
                  cb(FOUND_SUCCESS, result.css.toString().replace(/\\([\s\S])|(`)/g,"\\$1$2"), sassPaths);
                }
            });
        }
        else {
            cb(CODE_EXIT);
        }
    }
1203021
protected function fixParts(File $phpCsFile, $classNameIndex, array $parts, $appendix) {
		$result = [];
		foreach ($parts as $key => $part) {
			if ($part !== 'self') {
				continue;
			}

			$parts[$key] = '$this';
			$result[$part] = '$this';
		}

		if (!$result) {
			return;
		}

		$message = [];
		foreach ($result as $part => $useStatement) {
			$message[] = $part . ' => ' . $useStatement;
		}

		$fix = $phpCsFile->addFixableError(implode(', ', $message), $classNameIndex, 'ReturnSelf');
		if ($fix) {
			$newContent = implode('|', $parts);
			$phpCsFile->fixer->replaceToken($classNameIndex, $newContent . $appendix);
		}
	}
800151
protected function fixHeaders()
    {
        if (count($this->immediateChildren)) {
            $this->setHeaderParameter('Content-Type', 'boundary',
                $this->getBoundary()
                );
            $this->headers->remove('Content-Transfer-Encoding');
        } else {
            $this->setHeaderParameter('Content-Type', 'boundary', null);
            $this->setEncoding($this->encoder->getName());
        }
    }
535090
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
	{
		$tokens     = $phpcsFile->getTokens();
		$singleLine = false;
		$comment    = trim($tokens[$stackPtr]['content']);

		// Hash comments are not allowed.
		if ($tokens[$stackPtr]['content']{0} === '#')
		{
			$phpcsFile->recordMetric($stackPtr, 'Inline comment style', '# ...');

			$error  = 'Perl-style Hash comments are prohibited. Use "// Comment."';
			$error .= ' or "/* comment */" instead.';
			$fix    = $phpcsFile->addFixableError($error, $stackPtr, 'WrongStyle');

			if ($fix === true)
			{
				$newComment = ltrim($tokens[$stackPtr]['content'], '# ');
				$newComment = '// ' . $newComment;
				$phpcsFile->fixer->replaceToken($stackPtr, $newComment);
			}
		}
		elseif ($tokens[$stackPtr]['content']{0} === '/' && $tokens[$stackPtr]['content']{1} === '/')
		{
			$phpcsFile->recordMetric($stackPtr, 'Inline comment style', '// ...');
			$singleLine = true;
		}
		elseif ($tokens[$stackPtr]['content']{0} === '/' && $tokens[$stackPtr]['content']{1} === '*')
		{
			$phpcsFile->recordMetric($stackPtr, 'Inline comment style', '/* ... */');
		}

		// Always have a space between // and the start of the comment text.
		// The exception to this is if the preceding line consists of a single open bracket.
		if ($tokens[$stackPtr]['content']{0} === '/' && $tokens[$stackPtr]['content']{1} === '/' && isset($tokens[$stackPtr]['content']{2})
			&& $tokens[$stackPtr]['content']{2} !== ' ' && isset($tokens[($stackPtr - 1)]['content']{0})
			&& $tokens[($stackPtr - 1)]['content']{0} !== '}'
		)
		{
			$error = 'Missing space between the // and the start of the comment text.';
			$fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSpace');

			if ($fix === true)
			{
				$newComment = ltrim($tokens[$stackPtr]['content'], '\//');
				$newComment = '// ' . $newComment;

				$phpcsFile->fixer->replaceToken($stackPtr, $newComment);
			}
		}

		/*
		 * New lines should always start with an upper case letter, unless
		 * the line is a continuation of a complete sentence,
		 * the term is code and is case sensitive.(@todo)
		 */
		if (($singleLine === true && isset($tokens[$stackPtr]['content']{3}) && $tokens[$stackPtr]['content']{2} === ' '
			&& $tokens[$stackPtr]['content']{3} !== strtoupper($tokens[$stackPtr]['content']{3})) || (isset($comment{2}) && $comment{0} === '*'
			&& $comment{1} === ' ' && $comment{2} !== strtoupper($comment{2}))
		)
		{
			$error = 'Comment must start with a capital letter; found "%s"';
			$previous = $phpcsFile->findPrevious(T_COMMENT, $stackPtr - 1);

			if ($singleLine === true)
			{
				$data       = array($comment{3});
				$newComment = ltrim($tokens[$stackPtr]['content'], '\// ');
				$newComment = '// ' . ucfirst($newComment);
			}
			else
			{
				$data       = array($comment{2});
				$padding    = (strlen($tokens[$stackPtr]['content']) - strlen($comment));
				$padding    = str_repeat("\t", $padding - 2);
				$newComment = ltrim($comment, '* ');
				$newComment = $padding . ' * ' . ucfirst($newComment) . $phpcsFile->eolChar;
			}

			// Check for a comment on the previous line.
			if ($tokens[$previous]['line'] === $tokens[$stackPtr]['line'] - 1 && '/*' !== substr(ltrim($tokens[$previous]['content']), 0, 2))
			{
				$test = trim($tokens[$previous]['content']);

				if ('.' === $test{(strlen($test) - 1)})
				{
					$fix = $phpcsFile->addFixableError($error, $stackPtr, 'LowerCaseAfterSentenceEnd', $data);

					if ($fix === true)
					{
						$phpcsFile->fixer->replaceToken($stackPtr, $newComment);
					}
				}
			}
			else
			{
				$fix = $phpcsFile->addFixableError($error, $stackPtr, 'LowerCaseStart', $data);

				if ($fix === true)
				{
					$phpcsFile->fixer->replaceToken($stackPtr, $newComment);
				}
			}
		}

		/*
		 * Comments should not be on the same line as the code to which they refer
		 * (which puts them after the code they reference).
		 * They should be on their own lines.
		 * @todo Add fixer
		 */
		$previous = $phpcsFile->findPrevious(T_SEMICOLON, $stackPtr);

		if (isset($tokens[$previous]['line']) && $tokens[$previous]['line'] === $tokens[$stackPtr]['line'])
		{
			$error = 'Please put your comment on a separate line *preceding* your code; found "%s"';
			$data = array($comment);
			$phpcsFile->addError($error, $stackPtr, 'SameLine', $data);
		}

		/*
		 * Always have a single blank line before a comment or block of comments.
		 * Don't allow preceding "code" - identified by a semicolon ;)
		 */
		if (isset($tokens[$previous]['line']) && $tokens[$previous]['line'] === $tokens[$stackPtr]['line'] - 1
			&& $tokens[($stackPtr - 1)]['content'] !== '}'
		)
		{
			$error = 'Please consider a blank line preceding your comment.';
			$fix = $phpcsFile->addFixableError($error, $stackPtr, 'BlankBefore');

			if ($fix === true)
			{
				$phpcsFile->fixer->addContent(($previous + 1), $phpcsFile->eolChar);
			}
		}

		/*
		 * Comment blocks that introduce large sections of code and are more than 2 lines long
		 * should use /* * / and should use * on each line with the same space/tab rules as doc
		 * blocks.
		 * If you need a large introduction consider whether this block should be separated into a
		 * method to reduce complexity and therefore providing a full docblock.
		 */
		$next = $phpcsFile->findNext(T_COMMENT, $stackPtr + 1);

		if ($singleLine === true && isset($tokens[$next]['line']) && $tokens[$next]['line'] === $tokens[$stackPtr]['line'] + 1
			&& $tokens[($stackPtr - 1)]['content'] !== '}'
		)
		{
			// The following line contains also a comment.
			$nextNext = $phpcsFile->findNext(T_COMMENT, $next + 1);

			if ($tokens[$nextNext]['line'] === $tokens[$next]['line'] + 1)
			{
				// Found 3 lines of // comments - too much.
				$error = 'Use the /* */ style for comments that span over multiple lines.';
				$phpcsFile->addError($error, $stackPtr, 'MultiLine');
			}
		}
	}
1134232
public function probePhpCsFixer()
    {
        $execFinder = new ExecutableFinder();
        $execFinder->setSuffixes(['.bat', '.cmd', '.sh', '']);

        $fixer = $execFinder->find('php-cs-fixer', 'php-cs-fixer');

        $builder = new ProcessBuilder([$fixer, '--version']);
        $builder
            ->setWorkingDirectory(getcwd())
            ->setTimeout(3600)
        ;

        $process = $builder->getProcess();
        $process->run();

        if (!$process->isSuccessful()) {
            throw new \RuntimeException('Please install php-cs-fixer');
        }

        return $fixer;
    }
202501
protected function fixStatement(File $phpcsFile, array $statement, int $stackPtr): void
    {
        if (strpos($statement['content'], '\\') === false) {
            return;
        }

        $partial = strpos($statement['content'], '\\') !== 0;

        $extractedUseStatement = ltrim($statement['content'], '\\');
        $className = substr($statement['content'], strrpos($statement['content'], '\\') + 1);

        $error = 'Use statement ' . $extractedUseStatement . ' for class ' . $className . ' should be in use block.';
        if ($partial) {
            // For now just warn about partial FQCN locally
            //$phpcsFile->addWarning($error, $stackPtr, 'Interface');
            return;
        }

        $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Statement');
        if (!$fix) {
            return;
        }

        $phpcsFile->fixer->beginChangeset();

        $addedUseStatement = $this->addUseStatement($phpcsFile, $className, $extractedUseStatement);

        for ($i = $statement['start']; $i < $statement['end']; ++$i) {
            $phpcsFile->fixer->replaceToken($i, '');
        }

        if ($addedUseStatement['alias'] !== null) {
            $phpcsFile->fixer->replaceToken($statement['end'], $addedUseStatement['alias']);
        }

        $phpcsFile->fixer->endChangeset();
    }
1356450
def fix_e262(self, result):
        """"""
        target = self.source[result['line'] - 1]
        offset = result['column']

        code = target[:offset].rstrip(' \t#')
        comment = target[offset:].lstrip(' \t#')

        fixed = code + ('  # ' + comment if comment.strip() else '\n')

        self.source[result['line'] - 1] = fixed
727873
private function fixLibXML( $html ) {
		// We don't include rules like '&#34;' => '&amp;quot;' because entities had already been
		// normalized by libxml. Using this function with input not sanitized by libxml is UNSAFE!
		$replacements = [
			'&quot;' => '&amp;quot;',
			'&amp;' => '&amp;amp;',
			'&lt;' => '&amp;lt;',
			'&gt;' => '&amp;gt;',
		];
		$html = strtr( $html, $replacements );

		// Just in case the conversion in getDoc() above used named
		// entities that aren't known to html_entity_decode().
		$html = \mb_convert_encoding( $html, 'UTF-8', 'HTML-ENTITIES' );
		return $html;
	}
268363
protected function fixDocCommentCloseTags(File $phpCsFile, int $index): void
    {
        $tokens = $phpCsFile->getTokens();

        $content = $tokens[$index]['content'];
        if ($content === '*/') {
            return;
        }

        $fix = $phpCsFile->addFixableError('Inline Doc Block comment end tag should be `*/`, got `' . $content . '`', $index, 'EndTag');
        if (!$fix) {
            return;
        }

        $phpCsFile->fixer->beginChangeset();

        $phpCsFile->fixer->replaceToken($index, '*/');

        $phpCsFile->fixer->endChangeset();
    }