chamilo/chamilo-lms

View on GitHub
public/main/course_copy/copy_course_session_selected.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid using undefined variables such as '$course_list_destination' which will lead to PHP notices.
Open

        Session::write('course_list_destination', $course_list_destination);

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

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

Avoid using undefined variables such as '$course_list_destination' which will lead to PHP notices.
Open

            $course_list_destination[] = $course['code'];

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

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

Missing class import via use statement (line '196', column '26').
Open

    $xajaxResponse = new xajaxResponse();

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Remove error control operator '@' on line 215.
Open

function searchCourses($idSession, $type)
{
    $xajaxResponse = new xajaxResponse();
    $return = null;
    $courseCode = api_get_course_id();

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

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

    } else {
        $html .= '<option value = "0">'.get_lang(
                'SelectASession'
            ).'</option>';
        foreach ($sessions as $session) {

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 method make_select_session_list uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

    } else {
        $output .= '<option value = "0">'.get_lang(
                'SelectASession'
            ).'</option>';
    }

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

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

            $courseTitle = str_replace("'", "\'", $course['title']);

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

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

$this_section = SECTION_COURSES;

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            ).'</option>';

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        ).'</td>';

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                'ThereIsNotStillASession'

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            ).'</option>';

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

$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);

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

            $category_name = '';

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            get_lang('Copy courseFromSessionToSessionExplanation')

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

$current_course_tool = TOOL_COURSE_MAINTENANCE;

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                'ThereIsNotStillASession'

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            $sessionId

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                'SelectASession'

Consider putting global function "displayForm" in a static class
Open

function displayForm()

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

                $category_name = ' ('.$session['category_name'].')';

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

            $output .= '<option value="'.$session['id'].'">'.$session['title'].' '.$category_name.'</option>';

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            'OriginCoursesFromSession'

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            'DestinationCoursesFromSession'

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

$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        ).':</b></td>';

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        ).'</a>';

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        ).':</b></td>';

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

$tbl_session_rel_course_rel_user = Database::get_main_table(

Consider putting global function "make_select_session_list" in a static class
Open

function make_select_session_list($name, $sessions, $attr = [])

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            ).'</option>';

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

            $course_list_destination[] = $course['code'];

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        )."'".')) return false;">'.get_lang('Copy course').'</button>';

Consider putting global function "searchCourses" in a static class
Open

function searchCourses($idSession, $type)

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES)

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                'SelectASession'

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            ).'</option>';

Missing function doc comment
Open

function searchCourses($idSession, $type)

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                ).'">'.

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

        Session::write('course_list_destination', $course_list_destination);

Multi-line function call not indented correctly; expected 16 spaces but found 20
Open

                    $course['title'].' ('.$course['visual_code'].')',

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        ).':</b></td>';

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        ).'</a>';

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            ).'</option>';

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            get_lang('Copy courseFromSessionToSessionExplanation')

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                'SelectASession'

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            $sessionId

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                'ThereIsNotStillASession'

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        ).':</b></td>';

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        ).'</td>';

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            ).'</option>';

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            'DestinationCoursesFromSession'

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            'OriginCoursesFromSession'

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            ).'</option>';

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                'ThereIsNotStillASession'

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                ).'">'.

Multi-line function call not indented correctly; expected 16 spaces but found 20
Open

                    $course['title'].' ('.$course['visual_code'].')',

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES)

Multi-line function call not indented correctly; expected 12 spaces but found 16
Open

                'SelectASession'

Multi-line function call not indented correctly; expected 4 spaces but found 8
Open

        )."'".')) return false;">'.get_lang('Copy course').'</button>';

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            ).'</option>';

The variable $category_name is not named in camelCase.
Open

function make_select_session_list($name, $sessions, $attr = [])
{
    $attrs = '';
    if (count($attr) > 0) {
        foreach ($attr as $key => $value) {

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 $category_name is not named in camelCase.
Open

function make_select_session_list($name, $sessions, $attr = [])
{
    $attrs = '';
    if (count($attr) > 0) {
        foreach ($attr as $key => $value) {

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 $course_list_destination is not named in camelCase.
Open

function searchCourses($idSession, $type)
{
    $xajaxResponse = new xajaxResponse();
    $return = null;
    $courseCode = api_get_course_id();

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 $course_list_destination is not named in camelCase.
Open

function searchCourses($idSession, $type)
{
    $xajaxResponse = new xajaxResponse();
    $return = null;
    $courseCode = api_get_course_id();

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 $category_name is not named in camelCase.
Open

function make_select_session_list($name, $sessions, $attr = [])
{
    $attrs = '';
    if (count($attr) > 0) {
        foreach ($attr as $key => $value) {

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