From 1221fcf0842f779480735caeed7cae4ef236e528 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Wed, 13 May 2015 12:13:21 -0500 Subject: [PATCH] lint: Fix a few lint reported issues --- include/ajax.draft.php | 2 +- include/class.forms.php | 10 +++++----- include/class.ticket.php | 2 +- include/class.user.php | 2 +- setup/test/run-tests.php | 1 + setup/test/tests/stubs.php | 1 + 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/ajax.draft.php b/include/ajax.draft.php index 5f36b4704..9fa61635d 100644 --- a/include/ajax.draft.php +++ b/include/ajax.draft.php @@ -96,7 +96,7 @@ class DraftAjaxAPI extends AjaxController { // Paste uploads in Chrome will have a name of 'blob' if ($file[0]['name'] == 'blob') - $file[0]['name'] = 'screenshot-'.Misc::randcode(4); + $file[0]['name'] = 'screenshot-'.Misc::randCode(4); if (isset($file[0]['tmp_name'])) { $ids = $draft->attachments->upload($file); diff --git a/include/class.forms.php b/include/class.forms.php index d78f8f66c..4a0f2f72e 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -430,7 +430,7 @@ class FormField { return $this->_errors; } function addError($message, $index=false) { - if ($field) + if ($index) $this->_errors[$index] = $message; else $this->_errors[] = $message; @@ -2758,7 +2758,7 @@ class ChoicesWidget extends Widget { echo $def_val; ?> —</option> <?php } - $this->emitChoices($choices, $values); ?> + $this->emitChoices($choices, $values, $have_def, $def_key); ?> </select> <?php if ($config['multiselect']) { @@ -2773,10 +2773,10 @@ class ChoicesWidget extends Widget { } } - function emitChoices($choices, $values=array()) { + function emitChoices($choices, $values=array(), $have_def=false, $def_key=null) { reset($choices); if (is_array(current($choices)) || current($choices) instanceof Traversable) - return $this->emitComplexChoices($choices, $values); + return $this->emitComplexChoices($choices, $values, $have_def, $def_key); foreach ($choices as $key => $name) { if (!$have_def && $key == $def_key) @@ -2788,7 +2788,7 @@ class ChoicesWidget extends Widget { } } - function emitComplexChoices($choices, $values=array()) { + function emitComplexChoices($choices, $values=array(), $have_def=false, $def_key=null) { foreach ($choices as $label => $group) { ?> <optgroup label="<?php echo $label; ?>"><?php foreach ($group as $key => $name) { diff --git a/include/class.ticket.php b/include/class.ticket.php index 94389a5e8..9198bf4b4 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1836,7 +1836,7 @@ implements RestrictedAccess, Threadable, TemplateVariable { return new FormattedDate($this->getCloseDate()); break; case 'last_update': - return new FormattedDate($upd); + return new FormattedDate($this->last_update); case 'user': return $this->getOwner(); default: diff --git a/include/class.user.php b/include/class.user.php index 960588dae..1b4e309d8 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -685,7 +685,7 @@ implements TemplateVariable { if (!($mails = Mail_RFC822::parseAddressList($this->address)) || PEAR::isError($mails)) return ''; - if (!$list && count($mails) > 1) + if (count($mails) > 1) return ''; $info = $mails[0]; diff --git a/setup/test/run-tests.php b/setup/test/run-tests.php index f42c121d7..30d81e225 100644 --- a/setup/test/run-tests.php +++ b/setup/test/run-tests.php @@ -8,6 +8,7 @@ $selected_test = (isset($argv[1])) ? $argv[1] : false; require_once 'bootstrap.php'; require_once "tests/class.test.php"; +$root = get_osticket_root_path(); $fails = array(); require_once INCLUDE_DIR . 'class.i18n.php'; diff --git a/setup/test/tests/stubs.php b/setup/test/tests/stubs.php index 620f763a5..24670dbde 100644 --- a/setup/test/tests/stubs.php +++ b/setup/test/tests/stubs.php @@ -37,6 +37,7 @@ class mysqli_result { class ReflectionClass { function getMethods() {} function getConstants() {} + function newInstanceArgs() {} } class DomNode { -- GitLab