Various fixes for PHPAnalyzer

This commit is contained in:
Frederic Guillot
2015-04-03 18:32:51 -04:00
parent 91a5ec0885
commit 5a29cccc95
30 changed files with 48 additions and 38 deletions

View File

@@ -10,6 +10,7 @@ use Pimple\Container;
* @package auth
* @author Frederic Guillot
*
* @property \Core\Session $session
* @property \Model\Acl $acl
* @property \Model\LastLogin $lastLogin
* @property \Model\User $user

View File

@@ -34,7 +34,7 @@ class GitHub extends Base
{
$user = $this->user->getByGitHubId($github_id);
if ($user) {
if (! empty($user)) {
$this->userSession->refresh($user);
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
return true;

View File

@@ -35,7 +35,7 @@ class Google extends Base
{
$user = $this->user->getByGoogleId($google_id);
if ($user) {
if (! empty($user)) {
$this->userSession->refresh($user);
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
return true;

View File

@@ -36,7 +36,7 @@ class Ldap extends Base
$user = $this->user->getByUsername($username);
if ($user) {
if (! empty($user)) {
// There is already a local user with that name
if ($user['is_ldap_user'] == 0) {
@@ -241,7 +241,7 @@ class Ldap extends Base
}
// User id not retrieved: LDAP_ACCOUNT_ID not properly configured
if (! $username && ! isset($info[0][LDAP_ACCOUNT_ID][0])) {
if (empty($username) && ! isset($info[0][LDAP_ACCOUNT_ID][0])) {
return false;
}

View File

@@ -32,7 +32,7 @@ class ReverseProxy extends Base
$login = $_SERVER[REVERSE_PROXY_USER_HEADER];
$user = $this->user->getByUsername($login);
if (! $user) {
if (empty($user)) {
$this->createUser($login);
$user = $this->user->getByUsername($login);
}

View File

@@ -157,7 +157,7 @@ class Action extends Base
$project = $this->getProject();
$action = $this->action->getById($this->request->getIntegerParam('action_id'));
if ($action && $this->action->remove($action['id'])) {
if (! empty($action) && $this->action->remove($action['id'])) {
$this->session->flash(t('Action removed successfully.'));
} else {
$this->session->flashError(t('Unable to remove this action.'));

View File

@@ -44,6 +44,7 @@ use Symfony\Component\EventDispatcher\Event;
* @property \Model\ProjectActivity $projectActivity
* @property \Model\ProjectDailySummary $projectDailySummary
* @property \Model\Subtask $subtask
* @property \Model\SubtaskForecast $subtaskForecast
* @property \Model\Swimlane $swimlane
* @property \Model\Task $task
* @property \Model\Link $link
@@ -336,7 +337,7 @@ abstract class Base
{
$task = $this->taskFinder->getDetails($this->request->getIntegerParam('task_id'));
if (! $task) {
if (empty($task)) {
$this->notfound();
}
@@ -355,7 +356,7 @@ abstract class Base
$project_id = $this->request->getIntegerParam('project_id', $project_id);
$project = $this->project->getById($project_id);
if (! $project) {
if (empty($project)) {
$this->session->flashError(t('Project not found.'));
$this->response->redirect('?controller=project');
}

View File

@@ -117,7 +117,7 @@ class Board extends Base
$project = $this->project->getByToken($token);
// Token verification
if (! $project) {
if (empty($project)) {
$this->forbidden(true);
}
@@ -311,7 +311,7 @@ class Board extends Base
$this->checkCSRFParam();
$column = $this->board->getColumn($this->request->getIntegerParam('column_id'));
if ($column && $this->board->removeColumn($column['id'])) {
if (! empty($column) && $this->board->removeColumn($column['id'])) {
$this->session->flash(t('Column removed successfully.'));
} else {
$this->session->flashError(t('Unable to remove this column.'));

View File

@@ -21,7 +21,7 @@ class Category extends Base
{
$category = $this->category->getById($this->request->getIntegerParam('category_id'));
if (! $category) {
if (empty($category)) {
$this->session->flashError(t('Category not found.'));
$this->response->redirect('?controller=category&action=index&project_id='.$project_id);
}

View File

@@ -20,7 +20,7 @@ class Comment extends Base
{
$comment = $this->comment->getById($this->request->getIntegerParam('comment_id'));
if (! $comment) {
if (empty($comment)) {
$this->notfound();
}

View File

@@ -37,7 +37,7 @@ class Link extends Base
{
$link = $this->link->getById($this->request->getIntegerParam('link_id'));
if (! $link) {
if (empty($link)) {
$this->notfound();
}

View File

@@ -22,7 +22,7 @@ class Subtask extends Base
{
$subtask = $this->subtask->getById($this->request->getIntegerParam('subtask_id'));
if (! $subtask) {
if (empty($subtask)) {
$this->notfound();
}

View File

@@ -23,7 +23,7 @@ class Swimlane extends Base
{
$swimlane = $this->swimlane->getById($this->request->getIntegerParam('swimlane_id'));
if (! $swimlane) {
if (empty($swimlane)) {
$this->session->flashError(t('Swimlane not found.'));
$this->response->redirect('?controller=swimlane&action=index&project_id='.$project_id);
}

View File

@@ -22,13 +22,13 @@ class Task extends Base
$project = $this->project->getByToken($this->request->getStringParam('token'));
// Token verification
if (! $project) {
if (empty($project)) {
$this->forbidden(true);
}
$task = $this->taskFinder->getDetails($this->request->getIntegerParam('task_id'));
if (! $task) {
if (empty($task)) {
$this->notfound(true);
}

View File

@@ -21,7 +21,7 @@ class Tasklink extends Base
{
$link = $this->taskLink->getById($this->request->getIntegerParam('link_id'));
if (! $link) {
if (empty($link)) {
$this->notfound();
}

View File

@@ -97,7 +97,7 @@ class User extends Base
{
$user = $this->user->getById($this->request->getIntegerParam('user_id'));
if (! $user) {
if (empty($user)) {
$this->notfound();
}

View File

@@ -10,6 +10,7 @@ use Pimple\Container;
* @package integration
* @author Frederic Guillot
*
* @property \Model\ProjectActivity $projectActivity
* @property \Model\Task $task
* @property \Model\TaskFinder $taskFinder
* @property \Model\User $user

View File

@@ -78,7 +78,7 @@ class BitbucketWebhook extends Base
$task = $this->taskFinder->getById($task_id);
if (! $task) {
if (empty($task)) {
return false;
}

View File

@@ -86,7 +86,7 @@ class GithubWebhook extends Base
$task = $this->taskFinder->getById($task_id);
if (! $task) {
if (empty($task)) {
continue;
}
@@ -142,7 +142,7 @@ class GithubWebhook extends Base
$task = $this->taskFinder->getByReference($payload['issue']['number']);
$user = $this->user->getByUsername($payload['comment']['user']['login']);
if ($task && $user) {
if (! empty($task) && ! empty($user)) {
$event = array(
'project_id' => $this->project_id,
@@ -198,7 +198,7 @@ class GithubWebhook extends Base
{
$task = $this->taskFinder->getByReference($issue['number']);
if ($task) {
if (! empty($task)) {
$event = array(
'project_id' => $this->project_id,
'task_id' => $task['id'],
@@ -227,7 +227,7 @@ class GithubWebhook extends Base
{
$task = $this->taskFinder->getByReference($issue['number']);
if ($task) {
if (! empty($task)) {
$event = array(
'project_id' => $this->project_id,
'task_id' => $task['id'],
@@ -257,7 +257,7 @@ class GithubWebhook extends Base
$user = $this->user->getByUsername($issue['assignee']['login']);
$task = $this->taskFinder->getByReference($issue['number']);
if ($user && $task) {
if (! empty($user) && ! empty($task)) {
$event = array(
'project_id' => $this->project_id,
@@ -288,7 +288,7 @@ class GithubWebhook extends Base
{
$task = $this->taskFinder->getByReference($issue['number']);
if ($task) {
if (! empty($task)) {
$event = array(
'project_id' => $this->project_id,
@@ -320,7 +320,7 @@ class GithubWebhook extends Base
{
$task = $this->taskFinder->getByReference($issue['number']);
if ($task) {
if (! empty($task)) {
$event = array(
'project_id' => $this->project_id,
@@ -352,7 +352,7 @@ class GithubWebhook extends Base
{
$task = $this->taskFinder->getByReference($issue['number']);
if ($task) {
if (! empty($task)) {
$event = array(
'project_id' => $this->project_id,

View File

@@ -122,7 +122,7 @@ class GitlabWebhook extends Base
$task = $this->taskFinder->getById($task_id);
if (! $task) {
if (empty($task)) {
return false;
}
@@ -193,7 +193,7 @@ class GitlabWebhook extends Base
{
$task = $this->taskFinder->getByReference($issue['id']);
if ($task) {
if (! empty($task)) {
$event = array(
'project_id' => $this->project_id,
'task_id' => $task['id'],

View File

@@ -17,7 +17,7 @@ class Hipchat extends Base
* @param integer $project_id Project id
* @param integer $task_id Task id
* @param string $event_name Event name
* @param array $data Event data
* @param array $event Event data
*/
public function notify($project_id, $task_id, $event_name, array $event)
{

View File

@@ -17,7 +17,7 @@ class SlackWebhook extends Base
* @param integer $project_id Project id
* @param integer $task_id Task id
* @param string $event_name Event name
* @param array $data Event data
* @param array $event Event data
*/
public function notify($project_id, $task_id, $event_name, array $event)
{

View File

@@ -213,7 +213,7 @@ class Action extends Base
*
* @access public
* @param array $values Required parameters to save an action
* @return integer
* @return boolean|integer
*/
public function create(array $values)
{

View File

@@ -44,6 +44,10 @@ use Pimple\Container;
* @property \Model\TaskPosition $taskPosition
* @property \Model\TaskValidator $taskValidator
* @property \Model\Timetable $timetable
* @property \Model\TimetableDay $timetableDay
* @property \Model\TimetableExtra $timetableExtra
* @property \Model\TimetableOff $timetableOfff
* @property \Model\TimetableWeek $timetableWeek
* @property \Model\SubtaskTimeTracking $subtaskTimeTracking
* @property \Model\User $user
* @property \Model\UserSession $userSession

View File

@@ -62,10 +62,8 @@ class Timetable extends Base
* Get a serie of events based on the timetable and the provided event
*
* @access public
* @param integer $user_id
* @param array $events Time tracking data
* @param string $start ISO8601 date
* @param string $end ISO8601 date
* @param array $event
* @param array $timetable
* @return array
*/
public function calculateEventIntersect(array $event, array $timetable)

View File

@@ -162,6 +162,7 @@ function version_49($pdo)
$pdo->exec('ALTER TABLE subtasks ADD COLUMN position INTEGER DEFAULT 1');
$task_id = 0;
$position = 1;
$urq = $pdo->prepare('UPDATE subtasks SET position=? WHERE id=?');
$rq = $pdo->prepare('SELECT * FROM subtasks ORDER BY task_id, id ASC');

View File

@@ -155,6 +155,7 @@ function version_30($pdo)
$pdo->exec('ALTER TABLE subtasks ADD COLUMN position INTEGER DEFAULT 1');
$task_id = 0;
$position = 1;
$urq = $pdo->prepare('UPDATE subtasks SET position=? WHERE id=?');
$rq = $pdo->prepare('SELECT * FROM subtasks ORDER BY task_id, id ASC');

View File

@@ -157,6 +157,7 @@ function version_48($pdo)
// Migrate all subtasks position
$task_id = 0;
$position = 1;
$urq = $pdo->prepare('UPDATE subtasks SET position=? WHERE id=?');
$rq = $pdo->prepare('SELECT * FROM subtasks ORDER BY task_id, id ASC');

View File

@@ -10,6 +10,8 @@ use Pimple\Container;
* @package subscriber
* @author Frederic Guillot
*
* @property \Integration\SlackWebhook $slackWebhook
* @property \Integration\Hipchat $hipchat
* @property \Model\Board $board
* @property \Model\Config $config
* @property \Model\Comment $comment

View File

@@ -49,7 +49,7 @@ class NotificationSubscriber extends Base implements EventSubscriberInterface
$values = $this->getTemplateData($event);
$users = $this->notification->getUsersList($values['task']['project_id']);
if ($users) {
if (! empty($users)) {
$this->notification->sendEmails($this->templates[$event_name], $users, $values);
}
}