本文整理汇总了PHP中PHP_CodeSniffer_File::refreshTokenListeners方法的典型用法代码示例。如果您正苦于以下问题:PHP PHP_CodeSniffer_File::refreshTokenListeners方法的具体用法?PHP PHP_CodeSniffer_File::refreshTokenListeners怎么用?PHP PHP_CodeSniffer_File::refreshTokenListeners使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP_CodeSniffer_File
的用法示例。
在下文中一共展示了PHP_CodeSniffer_File::refreshTokenListeners方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fixFile
/**
* Attempt to fix the file by processing it until no fixes are made.
*
* @return boolean
*/
public function fixFile()
{
$fixable = $this->_currentFile->getFixableCount();
if ($fixable === 0) {
// Nothing to fix.
return false;
}
$this->enabled = true;
$loops = 0;
while ($loops < 50) {
ob_start();
if ($loops === 0) {
// First time through, don't reparse the file, saving time.
$contents = null;
} else {
// Only needed once file content has changed.
$contents = $this->getContents();
/*
@ob_end_clean();
$debugContent = str_replace("\n", "\033[30;1m\\n\n\033[0m", $contents);
$debugContent = str_replace("\t", "\033[30;1m»\t\033[0m", $debugContent);
$debugContent = str_replace(' ', "\033[30;1m·\033[0m", $debugContent);
echo $debugContent;
*/
}
$this->_currentFile->refreshTokenListeners();
$this->_currentFile->start($contents);
ob_end_clean();
/*
Possibly useful as a fail-safe, but may mask problems with the actual
fixes being performed.
$newContents = $this->getContents();
if ($newContents === $contents) {
break;
}
*/
$loops++;
if ($this->_numFixes === 0) {
// Nothing left to do.
break;
} else {
if (PHP_CODESNIFFER_VERBOSITY > 1) {
echo "\tFixed {$this->_numFixes} violations, starting over" . PHP_EOL;
}
}
}
//end while
$this->enabled = false;
if ($this->_numFixes > 0) {
if (PHP_CODESNIFFER_VERBOSITY > 1) {
@ob_end_clean();
echo "\tReached maximum number of loops with {$this->_numFixes} violations left unfixed" . PHP_EOL;
ob_start();
}
return false;
}
return true;
}
示例2: fixFile
/**
* Attempt to fix the file by processing it until no fixes are made.
*
* @return boolean
*/
public function fixFile()
{
$fixable = $this->_currentFile->getFixableCount();
if ($fixable === 0) {
// Nothing to fix.
return false;
}
$stdin = false;
$cliValues = $this->_currentFile->phpcs->cli->getCommandLineValues();
if (empty($cliValues['files']) === true) {
$stdin = true;
}
$this->enabled = true;
$this->_loops = 0;
while ($this->_loops < 50) {
ob_start();
// Only needed once file content has changed.
$contents = $this->getContents();
if (PHP_CODESNIFFER_VERBOSITY > 2) {
@ob_end_clean();
echo '---START FILE CONTENT---' . PHP_EOL;
$lines = explode($this->_currentFile->eolChar, $contents);
$max = strlen(count($lines));
foreach ($lines as $lineNum => $line) {
$lineNum++;
echo str_pad($lineNum, $max, ' ', STR_PAD_LEFT) . '|' . $line . PHP_EOL;
}
echo '--- END FILE CONTENT ---' . PHP_EOL;
ob_start();
}
$this->_currentFile->refreshTokenListeners();
$this->_currentFile->start($contents);
ob_end_clean();
$this->_loops++;
if (PHP_CODESNIFFER_CBF === true && $stdin === false) {
echo "\r" . str_repeat(' ', 80) . "\r";
echo "\t=> Fixing file: {$this->_numFixes}/{$fixable} violations remaining [made {$this->_loops} pass";
if ($this->_loops > 1) {
echo 'es';
}
echo ']... ';
}
if ($this->_numFixes === 0) {
// Nothing left to do.
break;
} else {
if (PHP_CODESNIFFER_VERBOSITY > 1) {
echo "\t* fixed {$this->_numFixes} violations, starting loop " . ($this->_loops + 1) . ' *' . PHP_EOL;
}
}
}
//end while
$this->enabled = false;
if ($this->_numFixes > 0) {
if (PHP_CODESNIFFER_VERBOSITY > 1) {
@ob_end_clean();
echo "\t*** Reached maximum number of loops with {$this->_numFixes} violations left unfixed ***" . PHP_EOL;
ob_start();
}
return false;
}
return true;
}
示例3: fixFile
/**
* Attempt to fix the file by processing it until no fixes are made.
*
* @return boolean
*/
public function fixFile()
{
$fixable = $this->_currentFile->getFixableCount();
if ($fixable === 0) {
// Nothing to fix.
return false;
}
$this->enabled = true;
$loops = 0;
while ($loops < 50) {
ob_start();
// Only needed once file content has changed.
$contents = $this->getContents();
/*
Useful for debugging fixed contents.
@ob_end_clean();
$debugContent = PHP_CodeSniffer::prepareForOutput($contents);
echo $debugContent;
ob_start();
*/
$this->_currentFile->refreshTokenListeners();
$this->_currentFile->start($contents);
ob_end_clean();
/*
Possibly useful as a fail-safe, but may mask problems with the actual
fixes being performed.
$newContents = $this->getContents();
if ($newContents === $contents) {
break;
}
*/
$loops++;
if (PHP_CODESNIFFER_CBF === true) {
echo "\r" . str_repeat(' ', 80) . "\r";
echo "\t=> Fixing file: {$this->_numFixes}/{$fixable} violations remaining [made {$loops} pass";
if ($loops > 1) {
echo 'es';
}
echo ']... ';
}
if ($this->_numFixes === 0) {
// Nothing left to do.
break;
} else {
if (PHP_CODESNIFFER_VERBOSITY > 1) {
echo "\t* fixed {$this->_numFixes} violations, starting loop " . ($loops + 1) . ' *' . PHP_EOL;
}
}
}
//end while
$this->enabled = false;
if ($this->_numFixes > 0) {
if (PHP_CODESNIFFER_VERBOSITY > 1) {
@ob_end_clean();
echo "\t*** Reached maximum number of loops with {$this->_numFixes} violations left unfixed ***" . PHP_EOL;
ob_start();
}
return false;
}
return true;
}