1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-23 05:50:54 +01:00

Parse JSON as an associate array.

Summary:
It seems that in some situations, JSHint does not set the `evidence`
property. In such cases, PHP fails with `Undefined property:
stdClass::$evidence`. It would be safer to access the error object as an
associative array rather than as `stdClass`.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D8993
This commit is contained in:
Joshua Spence 2014-05-05 21:18:43 -07:00 committed by epriestley
parent 8523b98f39
commit 9a13c87ac4

View file

@ -84,7 +84,7 @@ final class ArcanistJSHintLinter extends ArcanistExternalLinter {
}
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
$errors = json_decode($stdout);
$errors = json_decode($stdout, true);
if (!is_array($errors)) {
// Something went wrong and we can't decode the output. Exit abnormally.
@ -98,13 +98,13 @@ final class ArcanistJSHintLinter extends ArcanistExternalLinter {
foreach ($errors as $err) {
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($err->line);
$message->setChar($err->col);
$message->setCode($err->code);
$message->setName('JSHint'.$err->code);
$message->setDescription($err->reason);
$message->setSeverity($this->getLintMessageSeverity($err->code));
$message->setOriginalText($err->evidence);
$message->setLine(idx($err, 'line'));
$message->setChar(idx($err, 'col'));
$message->setCode(idx($err, 'code'));
$message->setName('JSHint'.idx($err, 'code'));
$message->setDescription(idx($err, 'reason'));
$message->setSeverity($this->getLintMessageSeverity(idx($err, 'code')));
$message->setOriginalText(idx($err, 'evidence'));
$messages[] = $message;
}