本文整理汇总了PHP中PHP_CodeSniffer_Reporting::startTiming方法的典型用法代码示例。如果您正苦于以下问题:PHP PHP_CodeSniffer_Reporting::startTiming方法的具体用法?PHP PHP_CodeSniffer_Reporting::startTiming怎么用?PHP PHP_CodeSniffer_Reporting::startTiming使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP_CodeSniffer_Reporting
的用法示例。
在下文中一共展示了PHP_CodeSniffer_Reporting::startTiming方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Run the coding style check
*
* @return int
*/
public function process()
{
$this->setDefaultValues();
\PHP_CodeSniffer_Reporting::startTiming();
$phpcs = new \PHP_CodeSniffer_CLI();
$phpcs->checkRequirements();
$values = $phpcs->getCommandLineValues();
foreach ($this->defaultValues as $k => $v) {
if (empty($values[$k])) {
$values[$k] = $v;
}
}
return $phpcs->process($values);
}
示例2: runphpcbf
/**
* Run the PHPCBF script.
*
* @return array
*/
public function runphpcbf()
{
if (defined('PHP_CODESNIFFER_CBF') === false) {
define('PHP_CODESNIFFER_CBF', true);
}
if (is_file(dirname(__FILE__) . '/../CodeSniffer/Reporting.php') === true) {
include_once dirname(__FILE__) . '/../CodeSniffer/Reporting.php';
} else {
include_once 'PHP/CodeSniffer/Reporting.php';
}
PHP_CodeSniffer_Reporting::startTiming();
$this->checkRequirements();
$this->dieOnUnknownArg = false;
// Override some of the command line settings that might break the fixes.
$cliValues = $this->getCommandLineValues();
$cliValues['verbosity'] = 0;
$cliValues['showProgress'] = false;
$cliValues['generator'] = '';
$cliValues['explain'] = false;
$cliValues['interactive'] = false;
$cliValues['showSources'] = false;
$cliValues['reportFile'] = null;
$cliValues['reports'] = array();
$suffix = '';
if (isset($cliValues['suffix']) === true) {
$suffix = $cliValues['suffix'];
}
$allowPatch = true;
if (isset($cliValues['no-patch']) === true || empty($cliValues['files']) === true) {
// They either asked for this,
// or they are using STDIN, which can't use diff.
$allowPatch = false;
}
if ($suffix === '' && $allowPatch === true) {
// Using the diff/patch tools.
$diffFile = getcwd() . '/phpcbf-fixed.diff';
$cliValues['reports'] = array('diff' => $diffFile);
if (file_exists($diffFile) === true) {
unlink($diffFile);
}
} else {
// Replace the file without the patch command
// or writing to a file with a new suffix.
$cliValues['reports'] = array('cbf' => null);
$cliValues['phpcbf-suffix'] = $suffix;
}
$numErrors = $this->process($cliValues);
if ($suffix === '' && $allowPatch === true) {
if (file_exists($diffFile) === false) {
// Nothing to fix.
if ($numErrors === 0) {
// And no errors reported.
$exit = 0;
} else {
// Errors we can't fix.
$exit = 2;
}
} else {
if (filesize($diffFile) < 10) {
// Empty or bad diff file.
if ($numErrors === 0) {
// And no errors reported.
$exit = 0;
} else {
// Errors we can't fix.
$exit = 2;
}
} else {
$cmd = "patch -p0 -ui \"{$diffFile}\"";
$output = array();
$retVal = null;
exec($cmd, $output, $retVal);
if ($retVal === 0) {
// Everything went well.
$filesPatched = count($output);
echo "Patched {$filesPatched} file";
if ($filesPatched > 1) {
echo 's';
}
echo PHP_EOL;
$exit = 1;
} else {
print_r($output);
echo "Returned: {$retVal}" . PHP_EOL;
$exit = 3;
}
}
//end if
unlink($diffFile);
}
//end if
} else {
// File are being patched manually, so we can't tell
// how many errors were fixed.
$exit = 1;
//.........这里部分代码省略.........