本文整理汇总了PHP中ArcanistLintMessage::setChar方法的典型用法代码示例。如果您正苦于以下问题:PHP ArcanistLintMessage::setChar方法的具体用法?PHP ArcanistLintMessage::setChar怎么用?PHP ArcanistLintMessage::setChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArcanistLintMessage
的用法示例。
在下文中一共展示了ArcanistLintMessage::setChar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$lines = phutil_split_lines($stderr, false);
$messages = array();
foreach ($lines as $line) {
$matches = explode(':', $line, 6);
if (count($matches) === 6) {
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[3]);
$message->setChar($matches[4]);
$code = "E00";
$message->setCode($code);
$message->setName($this->getLinterName());
$message->setDescription(ucfirst(trim($matches[5])));
$severity = $this->getLintMessageSeverity($code);
$message->setSeverity($severity);
$messages[] = $message;
}
if (count($matches) === 3) {
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[1]);
$code = "E01";
$message->setCode($code);
$message->setName($this->getLinterName());
$message->setDescription(ucfirst(trim($matches[2])));
$severity = $this->getLintMessageSeverity($code);
$message->setSeverity($severity);
$messages[] = $message;
}
}
return $messages;
}
示例2: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$report_dom = new DOMDocument();
$ok = @$report_dom->loadXML($stdout);
if (!$ok) {
return false;
}
$files = $report_dom->getElementsByTagName('file');
$messages = array();
foreach ($files as $file) {
foreach ($file->childNodes as $child) {
if (!$child instanceof DOMElement) {
continue;
}
$data = $this->getData($path);
$lines = explode("\n", $data);
$name = $child->getAttribute('reason');
$severity = $child->getAttribute('severity') == 'warning' ? ArcanistLintSeverity::SEVERITY_WARNING : ArcanistLintSeverity::SEVERITY_ERROR;
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($child->getAttribute('line'));
$message->setChar($child->getAttribute('char'));
$message->setCode('CSSLint');
$message->setDescription($child->getAttribute('reason'));
$message->setSeverity($severity);
if ($child->hasAttribute('line') && $child->getAttribute('line') > 0) {
$line = $lines[$child->getAttribute('line') - 1];
$text = substr($line, $child->getAttribute('char') - 1);
$message->setOriginalText($text);
}
$messages[] = $message;
}
}
return $messages;
}
示例3: lintPath
public function lintPath($path)
{
libxml_use_internal_errors(true);
libxml_clear_errors();
if (simplexml_load_string($this->getData($path))) {
// XML appears to be valid.
return;
}
foreach (libxml_get_errors() as $error) {
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($error->line);
$message->setChar($error->column ? $error->column : null);
$message->setCode($this->getLintMessageFullCode($error->code));
$message->setName('LibXML Error');
$message->setDescription(trim($error->message));
switch ($error->level) {
case LIBXML_ERR_NONE:
$message->setSeverity(ArcanistLintSeverity::SEVERITY_DISABLED);
break;
case LIBXML_ERR_WARNING:
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
break;
case LIBXML_ERR_ERROR:
case LIBXML_ERR_FATAL:
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
break;
default:
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE);
break;
}
$this->addLintMessage($message);
}
}
示例4: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$lines = phutil_split_lines($stdout, false);
$messages = array();
foreach ($lines as $line) {
$matches = null;
// stdin:2: W802 undefined name 'foo' # pyflakes
// stdin:3:1: E302 expected 2 blank lines, found 1 # pep8
$regexp = '/^(.*?):(\\d+):(?:(\\d+):)? (\\S+) (.*)$/';
if (!preg_match($regexp, $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
if (!empty($matches[3])) {
$message->setChar($matches[3]);
}
$message->setCode($matches[4]);
$message->setName($this->getLinterName() . ' ' . $matches[3]);
$message->setDescription($matches[5]);
$message->setSeverity($this->getLintMessageSeverity($matches[4]));
$messages[] = $message;
}
return $messages;
}
示例5: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$ok = $err == 0;
$lines = phutil_split_lines($stdout, false);
$messages = array();
foreach ($lines as $line) {
$matches = null;
if (!preg_match('/^(.*?):(\\d+):((\\d+):)? (\\S+): ((\\s|\\w)+): (.*)$/', $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
if ($matches[4] != '') {
$message->setChar($matches[4]);
}
$message->setCode($this->getLinterName());
$message->setName($matches[6]);
$message->setDescription($matches[8]);
$message->setSeverity($this->getLintMessageSeverity($matches[5]));
$messages[] = $message;
}
return $messages;
}
示例6: parseLinterOutput
protected function parseLinterOutput($output)
{
$json = json_decode($output, true);
$files = $json['files'];
$severityMap = array();
$severityMap['refactor'] = 'warning';
$severityMap['convention'] = 'warning';
$severityMap['warning'] = 'warning';
$severityMap['error'] = 'error';
$severityMap['fatal'] = 'error';
$messages = array();
foreach ($files as $file) {
foreach ($file['offenses'] as $offense) {
$message = new ArcanistLintMessage();
$message->setPath($file['path']);
$message->setLine($offense['location']['line']);
$message->setChar($offense['location']['column']);
$message->setCode('RUBY');
$message->setName($offense['cop_name']);
$message->setDescription($offense['message']);
$message->setseverity('error');
$messages[] = $message;
}
}
return $messages;
}
示例7: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$xml_result = new SimpleXMLElement($stdout);
$messages = array();
foreach ($xml_result->file->issue as $issue) {
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($this->intValOrNull($issue['line']));
$message->setChar($this->intValOrNull($issue['char']));
$message->setName($issue['reason']);
$message->setDescription("Evidence: " . $issue['evidence']);
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
$message->setCode(ArcanistLintSeverity::SEVERITY_ERROR);
$messages[] = $message;
}
return $messages;
}
示例8: newFromDictionary
public static function newFromDictionary(array $dict)
{
$message = new ArcanistLintMessage();
$message->setPath($dict['path']);
$message->setLine($dict['line']);
$message->setChar($dict['char']);
$message->setCode($dict['code']);
$message->setSeverity($dict['severity']);
$message->setName($dict['name']);
$message->setDescription($dict['description']);
if (isset($dict['original'])) {
$message->setOriginalText($dict['original']);
}
if (isset($dict['replacement'])) {
$message->setReplacementText($dict['replacement']);
}
return $message;
}
示例9: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$lines = phutil_split_lines($stdout, false);
$messages = array();
foreach ($lines as $line) {
$matches = explode(':', $line, 4);
if (count($matches) === 4) {
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[1]);
$message->setChar($matches[2]);
$message->setCode($this->getLinterName());
$message->setDescription(ucfirst(trim($matches[3])));
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE);
$messages[] = $message;
}
}
return $messages;
}
示例10: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$lines = phutil_split_lines($stderr, false);
$messages = array();
foreach ($lines as $line) {
$matches = null;
$match = preg_match('/^(?:(?<path>.+): )?' . 'line (?<line>\\d+), col (?<column>\\d+), ' . '(?<description>.*)$/', $line, $matches);
if ($match) {
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches['line']);
$message->setChar($matches['column']);
$message->setCode($this->getLinterName());
$message->setDescription(ucfirst($matches['description']));
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
$messages[] = $message;
}
}
return $messages;
}
示例11: lintPath
public function lintPath($path)
{
list($err, $_, $stderr) = exec_manual("gofmt -w -s %s", $this->getEngine()->getFilePathOnDisk($path));
if ($err) {
$lines = explode("\n", $stderr);
foreach ($lines as $line) {
$matches = null;
if (!preg_match('/[^:]+:(\\d+):(\\d+): (.*)$/', $line, $matches)) {
continue;
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[1]);
$message->setChar($matches[2]);
$message->setName($this->getLinterName() . " Parse error");
$message->setDescription($matches[3]);
$this->addLintMessage($message);
}
}
}
示例12: lintPath
public function lintPath($path)
{
$flake8_bin = $this->getFlake8Path();
$options = $this->getFlake8Options();
$f = new ExecFuture("%C %C -", $flake8_bin, $options);
$f->write($this->getData($path));
list($err, $stdout, $stderr) = $f->resolve();
if ($err === 2) {
throw new Exception("flake8 failed to run correctly:\n" . $stderr);
}
$lines = explode("\n", $stdout);
$messages = array();
foreach ($lines as $line) {
$matches = null;
// stdin:2: W802 undefined name 'foo' # pyflakes
// stdin:3:1: E302 expected 2 blank lines, found 1 # pep8
if (!preg_match('/^(.*?):(\\d+):(?:(\\d+):)? (\\S+) (.*)$/', $line, $matches)) {
continue;
}
foreach ($matches as $key => $match) {
$matches[$key] = trim($match);
}
if (substr($matches[4], 0, 1) == 'E') {
$severity = ArcanistLintSeverity::SEVERITY_ERROR;
} else {
$severity = ArcanistLintSeverity::SEVERITY_WARNING;
}
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches[2]);
if (!empty($matches[3])) {
$message->setChar($matches[3]);
}
$message->setCode($matches[4]);
$message->setName($this->getLinterName() . ' ' . $matches[3]);
$message->setDescription($matches[5]);
$message->setSeverity($severity);
$this->addLintMessage($message);
}
}
示例13: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$json = phutil_json_decode($stdout);
$messages = array();
foreach ($json as $fix) {
if ($fix === null) {
return;
}
$message = new ArcanistLintMessage();
$message->setCode($this->getLinterName());
$message->setPath($path);
$message->setLine($fix['startLine']);
$message->setChar($fix['startColumn']);
$message->setName($fix['hint']);
$message->setOriginalText($fix['from']);
$message->setReplacementText($fix['to']);
/* Some improvements may slightly change semantics, so attach
all necessary notes too. */
$notes = '';
foreach ($fix['note'] as $note) {
$notes .= ' **NOTE**: ' . trim($note, '"') . '.';
}
$message->setDescription(pht('In module `%s`, declaration `%s`.%s', $fix['module'], $fix['decl'], $notes));
switch ($fix['severity']) {
case 'Error':
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
break;
case 'Warning':
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
break;
default:
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE);
break;
}
$messages[] = $message;
}
return $messages;
}
示例14: newFromDictionary
public static function newFromDictionary(array $dict)
{
$message = new ArcanistLintMessage();
$message->setPath($dict['path']);
$message->setLine($dict['line']);
$message->setChar($dict['char']);
$message->setCode($dict['code']);
$message->setSeverity($dict['severity']);
$message->setName($dict['name']);
$message->setDescription($dict['description']);
if (isset($dict['original'])) {
$message->setOriginalText($dict['original']);
}
if (isset($dict['replacement'])) {
$message->setReplacementText($dict['replacement']);
}
$message->setGranularity(idx($dict, 'granularity'));
$message->setOtherLocations(idx($dict, 'locations', array()));
if (isset($dict['bypassChangedLineFiltering'])) {
$message->bypassChangedLineFiltering($dict['bypassChangedLineFiltering']);
}
return $message;
}
示例15: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$lines = phutil_split_lines($stderr, false);
$messages = array();
foreach ($lines as $line) {
$matches = null;
$match = preg_match('/^(?P<name>\\w+): (?P<description>.+) ' . 'in (?P<path>.+|-) ' . 'on line (?P<line>\\d+), column (?P<column>\\d+):$/', $line, $matches);
if ($match) {
switch ($matches['name']) {
case 'RuntimeError':
$code = self::LINT_RUNTIME_ERROR;
break;
case 'ArgumentError':
$code = self::LINT_ARGUMENT_ERROR;
break;
case 'FileError':
$code = self::LINT_FILE_ERROR;
break;
case 'NameError':
$code = self::LINT_NAME_ERROR;
break;
case 'OperationError':
$code = self::LINT_OPERATION_ERROR;
break;
case 'ParseError':
$code = self::LINT_PARSE_ERROR;
break;
case 'SyntaxError':
$code = self::LINT_SYNTAX_ERROR;
break;
default:
throw new RuntimeException(pht('Unrecognized lint message code "%s".', $code));
}
$code = $this->getLintCodeFromLinterConfigurationKey($matches['name']);
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($matches['line']);
$message->setChar($matches['column']);
$message->setCode($this->getLintMessageFullCode($code));
$message->setSeverity($this->getLintMessageSeverity($code));
$message->setName($this->getLintMessageName($code));
$message->setDescription(ucfirst($matches['description']));
$messages[] = $message;
}
}
if ($err && !$messages) {
return false;
}
return $messages;
}