chamilo/chamilo-lms

View on GitHub
public/main/inc/lib/chat.lib.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid unused local variables such as '$time'.
Open

        foreach ($chatHistory as $userId => $time) {
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

The method send uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $messagesan = $message;
            }
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

The property $window_list is not named in camelCase.
Open

class Chat extends Model
{
    public $columns = [
        'id',
        'from_user',
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The parameter $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

Variable "to_user_id" is not in valid camel caps format
Open

            if (!empty($fromUserId) && !empty($to_user_id)) {

Member variable "window_list" is not in valid camel caps format
Open

    public $window_list = [];

Variable "to_user_id" is not in valid camel caps format
Open

            $_SESSION['openChatBoxes'][$to_user_id] = api_strtotime($now, 'UTC');

Variable "to_user_id" is not in valid camel caps format
Open

            $_SESSION['chatHistory'][$to_user_id]['user_info']['online'] = $user_info['user_is_online'];

Variable "user_info" is not in valid camel caps format
Open

            $_SESSION['chatHistory'][$to_user_id]['user_info']['avatar'] = $user_info['avatar_small'];

Variable "to_user_id" is not in valid camel caps format
Open

            $_SESSION['chatHistory'][$to_user_id]['items'][] = $item;

Variable "to_user_id" is not in valid camel caps format
Open

            $_SESSION['chatHistory'][$to_user_id]['user_info']['avatar'] = $user_info['avatar_small'];

Variable "to_user_id" is not in valid camel caps format
Open

        $to_user_id,

Variable "to_user_id" is not in valid camel caps format
Open

            unset($_SESSION['tsChatBoxes'][$to_user_id]);

Variable "user_info" is not in valid camel caps format
Open

            $user_info = api_get_user_info($to_user_id, true);

Variable "user_info" is not in valid camel caps format
Open

            $_SESSION['chatHistory'][$to_user_id]['user_info']['user_id'] = $user_info['user_id'];

Variable "user_info" is not in valid camel caps format
Open

            $_SESSION['chatHistory'][$to_user_id]['user_info']['online'] = $user_info['user_is_online'];

Variable "attempt_status" is not in valid camel caps format
Open

            foreach ($currentExercises as $attempt_status) {

Variable "to_user_id" is not in valid camel caps format
Open

                $_SESSION['chatHistory'][$to_user_id] = [];

Variable "to_user_id" is not in valid camel caps format
Open

            $_SESSION['chatHistory'][$to_user_id]['user_info']['user_id'] = $user_info['user_id'];

Variable "window_list" is not in valid camel caps format
Open

        Session::write('window_list', $this->window_list);

Variable "to_user_id" is not in valid camel caps format
Open

            $this->saveWindow($to_user_id);

Variable "to_user_id" is not in valid camel caps format
Open

            $params['to_user'] = (int) $to_user_id;

Variable "window_list" is not in valid camel caps format
Open

        $this->window_list[$userId] = true;

Variable "to_user_id" is not in valid camel caps format
Open

            $user_info = api_get_user_info($to_user_id, true);

Variable "to_user_id" is not in valid camel caps format
Open

            $_SESSION['chatHistory'][$to_user_id]['user_info']['user_name'] = $user_info['complete_name'];

Variable "attempt_status" is not in valid camel caps format
Open

                if (true == $attempt_status) {

Variable "window_list" is not in valid camel caps format
Open

        $this->window_list = Session::read('window_list');

Variable "window_list" is not in valid camel caps format
Open

        Session::write('window_list', $this->window_list);

Variable "to_user_id" is not in valid camel caps format
Open

            if (!isset($_SESSION['chatHistory'][$to_user_id])) {

Variable "to_user_id" is not in valid camel caps format
Open

        $relation = SocialManager::get_relation_between_contacts($fromUserId, $to_user_id);

Variable "user_info" is not in valid camel caps format
Open

            $_SESSION['chatHistory'][$to_user_id]['user_info']['user_name'] = $user_info['complete_name'];

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $attempt_status is not named in camelCase.
Open

    public function isChatBlockedByExercises()
    {
        $currentExercises = Session::read('current_exercises');
        if (!empty($currentExercises)) {
            foreach ($currentExercises as $attempt_status) {
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $user_info is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $user_info is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $user_info is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $user_info is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $attempt_status is not named in camelCase.
Open

    public function isChatBlockedByExercises()
    {
        $currentExercises = Session::read('current_exercises');
        if (!empty($currentExercises)) {
            foreach ($currentExercises as $attempt_status) {
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $user_info is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $to_user_id is not named in camelCase.
Open

    public function send(
        $fromUserId,
        $to_user_id,
        $message,
        $printResult = true,
Severity: Minor
Found in public/main/inc/lib/chat.lib.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status