本文整理汇总了PHP中PHP_CodeSniffer::getAllConfigData方法的典型用法代码示例。如果您正苦于以下问题:PHP PHP_CodeSniffer::getAllConfigData方法的具体用法?PHP PHP_CodeSniffer::getAllConfigData怎么用?PHP PHP_CodeSniffer::getAllConfigData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP_CodeSniffer
的用法示例。
在下文中一共展示了PHP_CodeSniffer::getAllConfigData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processLongArgument
/**
* Processes a long (--example) command line argument.
*
* @param string $arg The command line argument.
* @param int $pos The position of the argument on the command line.
* @param array $values An array of values determined from CLI args.
*
* @return array The updated CLI values.
* @see getCommandLineValues()
*/
public function processLongArgument($arg, $pos, $values)
{
switch ($arg) {
case 'help':
$this->printUsage();
exit(0);
break;
case 'version':
echo 'PHP_CodeSniffer version 1.3.5 (stable) ';
echo 'by Squiz Pty Ltd. (http://www.squiz.net)' . PHP_EOL;
exit(0);
break;
case 'config-set':
$key = $_SERVER['argv'][$pos + 1];
$value = $_SERVER['argv'][$pos + 2];
PHP_CodeSniffer::setConfigData($key, $value);
exit(0);
break;
case 'config-delete':
$key = $_SERVER['argv'][$pos + 1];
PHP_CodeSniffer::setConfigData($key, null);
exit(0);
break;
case 'config-show':
$data = PHP_CodeSniffer::getAllConfigData();
print_r($data);
exit(0);
break;
default:
if (substr($arg, 0, 7) === 'sniffs=') {
$values['sniffs'] = array();
$sniffs = substr($arg, 7);
$sniffs = explode(',', $sniffs);
// Convert the sniffs to class names.
foreach ($sniffs as $sniff) {
$parts = explode('.', $sniff);
$values['sniffs'][] = $parts[0] . '_Sniffs_' . $parts[1] . '_' . $parts[2] . 'Sniff';
}
} else {
if (substr($arg, 0, 12) === 'report-file=') {
$values['reportFile'] = realpath(substr($arg, 12));
// It may not exist and return false instead.
if ($values['reportFile'] === false) {
$values['reportFile'] = substr($arg, 12);
}
if (is_dir($values['reportFile']) === true) {
echo 'ERROR: The specified report file path "' . $values['reportFile'] . '" is a directory.' . PHP_EOL . PHP_EOL;
$this->printUsage();
exit(2);
}
$dir = dirname($values['reportFile']);
if (is_dir($dir) === false) {
echo 'ERROR: The specified report file path "' . $values['reportFile'] . '" points to a non-existent directory.' . PHP_EOL . PHP_EOL;
$this->printUsage();
exit(2);
}
} else {
if (substr($arg, 0, 13) === 'report-width=') {
$values['reportWidth'] = (int) substr($arg, 13);
} else {
if (substr($arg, 0, 7) === 'report=' || substr($arg, 0, 7) === 'report-') {
if ($arg[6] === '-') {
// This is a report with file output.
$split = strpos($arg, '=');
if ($split === false) {
$report = substr($arg, 7);
$output = null;
} else {
$report = substr($arg, 7, $split - 7);
$output = substr($arg, $split + 1);
if ($output === false) {
$output = null;
}
}
} else {
// This is a single report.
$report = substr($arg, 7);
$output = null;
}
$validReports = array('full', 'xml', 'checkstyle', 'csv', 'emacs', 'source', 'summary', 'svnblame', 'gitblame', 'hgblame');
if (in_array($report, $validReports) === false) {
echo 'ERROR: Report type "' . $report . '" not known.' . PHP_EOL;
exit(2);
}
$values['reports'][$report] = $output;
} else {
if (substr($arg, 0, 9) === 'standard=') {
$values['standard'] = substr($arg, 9);
} else {
if (substr($arg, 0, 11) === 'extensions=') {
//.........这里部分代码省略.........
示例2: processLongArgument
/**
* Processes a long (--example) command line argument.
*
* @param string $arg The command line argument.
* @param int $pos The position of the argument on the command line.
*
* @return void
*/
public function processLongArgument($arg, $pos)
{
switch ($arg) {
case 'help':
$this->printUsage();
exit(0);
case 'version':
echo 'PHP_CodeSniffer version ' . PHP_CodeSniffer::VERSION . ' (' . PHP_CodeSniffer::STABILITY . ') ';
echo 'by Squiz (http://www.squiz.net)' . PHP_EOL;
exit(0);
case 'colors':
$this->values['colors'] = true;
break;
case 'no-colors':
$this->values['colors'] = false;
break;
case 'config-set':
if (isset($this->_cliArgs[$pos + 1]) === false || isset($this->_cliArgs[$pos + 2]) === false) {
echo 'ERROR: Setting a config option requires a name and value' . PHP_EOL . PHP_EOL;
$this->printUsage();
exit(0);
}
$key = $this->_cliArgs[$pos + 1];
$value = $this->_cliArgs[$pos + 2];
$current = PHP_CodeSniffer::getConfigData($key);
try {
PHP_CodeSniffer::setConfigData($key, $value);
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
exit(2);
}
if ($current === null) {
echo "Config value \"{$key}\" added successfully" . PHP_EOL;
} else {
echo "Config value \"{$key}\" updated successfully; old value was \"{$current}\"" . PHP_EOL;
}
exit(0);
case 'config-delete':
if (isset($this->_cliArgs[$pos + 1]) === false) {
echo 'ERROR: Deleting a config option requires the name of the option' . PHP_EOL . PHP_EOL;
$this->printUsage();
exit(0);
}
$key = $this->_cliArgs[$pos + 1];
$current = PHP_CodeSniffer::getConfigData($key);
if ($current === null) {
echo "Config value \"{$key}\" has not been set" . PHP_EOL;
} else {
try {
PHP_CodeSniffer::setConfigData($key, null);
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
exit(2);
}
echo "Config value \"{$key}\" removed successfully; old value was \"{$current}\"" . PHP_EOL;
}
exit(0);
case 'config-show':
$data = PHP_CodeSniffer::getAllConfigData();
$this->printConfigData($data);
exit(0);
case 'runtime-set':
if (isset($this->_cliArgs[$pos + 1]) === false || isset($this->_cliArgs[$pos + 2]) === false) {
echo 'ERROR: Setting a runtime config option requires a name and value' . PHP_EOL . PHP_EOL;
$this->printUsage();
exit(0);
}
$key = $this->_cliArgs[$pos + 1];
$value = $this->_cliArgs[$pos + 2];
$this->_cliArgs[$pos + 1] = '';
$this->_cliArgs[$pos + 2] = '';
PHP_CodeSniffer::setConfigData($key, $value, true);
break;
default:
if (substr($arg, 0, 7) === 'sniffs=') {
$sniffs = explode(',', substr($arg, 7));
foreach ($sniffs as $sniff) {
if (substr_count($sniff, '.') !== 2) {
echo 'ERROR: The specified sniff code "' . $sniff . '" is invalid' . PHP_EOL . PHP_EOL;
$this->printUsage();
exit(2);
}
}
$this->values['sniffs'] = $sniffs;
} else {
if (substr($arg, 0, 10) === 'bootstrap=') {
$files = explode(',', substr($arg, 10));
foreach ($files as $file) {
$path = PHP_CodeSniffer::realpath($file);
if ($path === false) {
echo 'ERROR: The specified bootstrap file "' . $file . '" does not exist' . PHP_EOL . PHP_EOL;
$this->printUsage();
//.........这里部分代码省略.........
示例3: processLongArgument
/**
* Processes a long (--example) command line argument.
*
* @param string $arg The command line argument.
* @param int $pos The position of the argument on the command line.
*
* @return void
*/
public function processLongArgument($arg, $pos)
{
switch ($arg) {
case 'help':
$this->printUsage();
exit(0);
case 'version':
echo 'PHP_CodeSniffer version ' . PHP_CodeSniffer::VERSION . ' (' . PHP_CodeSniffer::STABILITY . ') ';
echo 'by Squiz (http://www.squiz.net)' . PHP_EOL;
exit(0);
case 'config-set':
$key = $this->_cliArgs[$pos + 1];
$value = $this->_cliArgs[$pos + 2];
PHP_CodeSniffer::setConfigData($key, $value);
exit(0);
case 'config-delete':
$key = $this->_cliArgs[$pos + 1];
PHP_CodeSniffer::setConfigData($key, null);
exit(0);
case 'config-show':
$data = PHP_CodeSniffer::getAllConfigData();
print_r($data);
exit(0);
case 'runtime-set':
$key = $this->_cliArgs[$pos + 1];
$value = $this->_cliArgs[$pos + 2];
$this->_cliArgs[$pos + 1] = '';
$this->_cliArgs[$pos + 2] = '';
PHP_CodeSniffer::setConfigData($key, $value, true);
break;
default:
if (substr($arg, 0, 7) === 'sniffs=') {
$sniffs = substr($arg, 7);
$this->values['sniffs'] = explode(',', $sniffs);
} else {
if (substr($arg, 0, 12) === 'report-file=') {
$this->values['reportFile'] = PHP_CodeSniffer::realpath(substr($arg, 12));
// It may not exist and return false instead.
if ($this->values['reportFile'] === false) {
$this->values['reportFile'] = substr($arg, 12);
}
if (is_dir($this->values['reportFile']) === true) {
echo 'ERROR: The specified report file path "' . $this->values['reportFile'] . '" is a directory.' . PHP_EOL . PHP_EOL;
$this->printUsage();
exit(2);
}
$dir = dirname($this->values['reportFile']);
if (is_dir($dir) === false) {
echo 'ERROR: The specified report file path "' . $this->values['reportFile'] . '" points to a non-existent directory.' . PHP_EOL . PHP_EOL;
$this->printUsage();
exit(2);
}
if ($dir === '.') {
// Passed report file is a filename in the current directory.
$this->values['reportFile'] = getcwd() . '/' . basename($this->values['reportFile']);
} else {
$dir = PHP_CodeSniffer::realpath(getcwd() . '/' . $dir);
if ($dir !== false) {
// Report file path is relative.
$this->values['reportFile'] = $dir . '/' . basename($this->values['reportFile']);
}
}
} else {
if (substr($arg, 0, 13) === 'report-width=') {
$this->values['reportWidth'] = (int) substr($arg, 13);
} else {
if (substr($arg, 0, 7) === 'report=' || substr($arg, 0, 7) === 'report-') {
if ($arg[6] === '-') {
// This is a report with file output.
$split = strpos($arg, '=');
if ($split === false) {
$report = substr($arg, 7);
$output = null;
} else {
$report = substr($arg, 7, $split - 7);
$output = substr($arg, $split + 1);
if ($output === false) {
$output = null;
} else {
$dir = dirname($output);
if ($dir === '.') {
// Passed report file is a filename in the current directory.
$output = getcwd() . '/' . basename($output);
} else {
$dir = PHP_CodeSniffer::realpath(getcwd() . '/' . $dir);
if ($dir !== false) {
// Report file path is relative.
$output = $dir . '/' . basename($output);
}
}
}
//end if
//.........这里部分代码省略.........
示例4: processLongArgument
/**
* Processes a long (--example) command line argument.
*
* @param string $arg The command line argument.
* @param int $pos The position of the argument on the command line.
* @param array $values An array of values determined from CLI args.
*
* @return array The updated CLI values.
* @see getCommandLineValues()
*/
public function processLongArgument($arg, $pos, $values)
{
switch ($arg) {
case 'help':
$this->printUsage();
exit(0);
break;
case 'version':
echo 'PHP_CodeSniffer version 1.1.0 (stable) ';
echo 'by Squiz Pty Ltd. (http://www.squiz.net)' . PHP_EOL;
exit(0);
break;
case 'config-set':
$key = $_SERVER['argv'][$pos + 1];
$value = $_SERVER['argv'][$pos + 2];
PHP_CodeSniffer::setConfigData($key, $value);
exit(0);
break;
case 'config-delete':
$key = $_SERVER['argv'][$pos + 1];
PHP_CodeSniffer::setConfigData($key, null);
exit(0);
break;
case 'config-show':
$data = PHP_CodeSniffer::getAllConfigData();
print_r($data);
exit(0);
break;
default:
if (substr($arg, 0, 7) === 'report=') {
$values['report'] = substr($arg, 7);
$validReports = array('full', 'xml', 'checkstyle', 'csv', 'summary');
if (in_array($values['report'], $validReports) === false) {
echo 'ERROR: Report type "' . $report . '" not known.' . PHP_EOL;
exit(2);
}
} else {
if (substr($arg, 0, 9) === 'standard=') {
$values['standard'] = substr($arg, 9);
} else {
if (substr($arg, 0, 11) === 'extensions=') {
$values['extensions'] = explode(',', substr($arg, 11));
} else {
if (substr($arg, 0, 7) === 'ignore=') {
// Split the ignore string on commas, unless the comma is escaped
// using 1 or 3 slashes (\, or \\\,).
$values['ignored'] = preg_split('/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/', substr($arg, 7));
} else {
if (substr($arg, 0, 10) === 'generator=') {
$values['generator'] = substr($arg, 10);
} else {
if (substr($arg, 0, 10) === 'tab-width=') {
$values['tabWidth'] = (int) substr($arg, 10);
} else {
$values = $this->processUnknownArgument('--' . $arg, $values);
}
}
}
}
}
}
//end if
break;
}
//end switch
return $values;
}
示例5: processLongArgument
/**
* Processes a long (--example) command line argument.
*
* @param string $arg The command line argument.
* @param int $pos The position of the argument on the command line.
* @param array $values An array of values determined from CLI args.
*
* @return array The updated CLI values.
* @see getCommandLineValues()
*/
public function processLongArgument($arg, $pos, $values)
{
switch ($arg) {
case 'help':
$this->printUsage();
exit(0);
case 'version':
echo 'PHP_CodeSniffer version ' . PHP_CodeSniffer::VERSION . ' (' . PHP_CodeSniffer::STABILITY . ') ';
echo 'by Squiz (http://www.squiz.net)' . PHP_EOL;
exit(0);
case 'config-set':
$key = $_SERVER['argv'][$pos + 1];
$value = $_SERVER['argv'][$pos + 2];
$current = PHP_CodeSniffer::getConfigData($key);
try {
PHP_CodeSniffer::setConfigData($key, $value);
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
exit(2);
}
if ($current === null) {
echo "Config value \"{$key}\" added successfully" . PHP_EOL;
} else {
echo "Config value \"{$key}\" updated successfully; old value was \"{$current}\"" . PHP_EOL;
}
exit(0);
case 'config-delete':
$key = $_SERVER['argv'][$pos + 1];
$current = PHP_CodeSniffer::getConfigData($key);
if ($current === null) {
echo "Config value \"{$key}\" has not been set" . PHP_EOL;
} else {
try {
PHP_CodeSniffer::setConfigData($key, null);
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
exit(2);
}
echo "Config value \"{$key}\" removed successfully; old value was \"{$current}\"" . PHP_EOL;
}
exit(0);
case 'config-show':
$data = PHP_CodeSniffer::getAllConfigData();
$this->printConfigData($data);
exit(0);
case 'runtime-set':
$key = $_SERVER['argv'][$pos + 1];
$value = $_SERVER['argv'][$pos + 2];
$_SERVER['argv'][$pos + 1] = '';
$_SERVER['argv'][$pos + 2] = '';
PHP_CodeSniffer::setConfigData($key, $value, true);
break;
default:
if (substr($arg, 0, 7) === 'sniffs=') {
$sniffs = explode(',', substr($arg, 7));
foreach ($sniffs as $sniff) {
if (substr_count($sniff, '.') !== 2) {
echo 'ERROR: The specified sniff code "' . $sniff . '" is invalid.' . PHP_EOL . PHP_EOL;
$this->printUsage();
exit(2);
}
}
$values['sniffs'] = $sniffs;
} else {
if (substr($arg, 0, 12) === 'report-file=') {
$values['reportFile'] = realpath(substr($arg, 12));
// It may not exist and return false instead.
if ($values['reportFile'] === false) {
$values['reportFile'] = substr($arg, 12);
}
if (is_dir($values['reportFile']) === true) {
echo 'ERROR: The specified report file path "' . $values['reportFile'] . '" is a directory.' . PHP_EOL . PHP_EOL;
$this->printUsage();
exit(2);
}
$dir = dirname($values['reportFile']);
if (is_dir($dir) === false) {
echo 'ERROR: The specified report file path "' . $values['reportFile'] . '" points to a non-existent directory.' . PHP_EOL . PHP_EOL;
$this->printUsage();
exit(2);
}
if ($dir === '.') {
// Passed report file is a filename in the current directory.
$values['reportFile'] = getcwd() . '/' . basename($values['reportFile']);
} else {
$dir = realpath(getcwd() . '/' . $dir);
if ($dir !== false) {
// Report file path is relative.
$values['reportFile'] = $dir . '/' . basename($values['reportFile']);
}
//.........这里部分代码省略.........