Avoid using undefined variables such as '$course_list_destination' which will lead to PHP notices. Open
Session::write('course_list_destination', $course_list_destination);
- Read upRead up
- Exclude checks
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'];
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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>';
}
- Read upRead up
- Exclude checks
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']);
- Read upRead up
- Exclude checks
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;
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
).'</option>';
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
).'</td>';
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
'ThereIsNotStillASession'
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
).'</option>';
- Exclude checks
Variable "tbl_session" is not in valid camel caps format Open
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
- Exclude checks
Variable "category_name" is not in valid camel caps format Open
$category_name = '';
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
get_lang('Copy courseFromSessionToSessionExplanation')
- Exclude checks
Variable "current_course_tool" is not in valid camel caps format Open
$current_course_tool = TOOL_COURSE_MAINTENANCE;
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
'ThereIsNotStillASession'
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
$sessionId
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
'SelectASession'
- Exclude checks
Consider putting global function "displayForm" in a static class Open
function displayForm()
- Exclude checks
Variable "category_name" is not in valid camel caps format Open
$category_name = ' ('.$session['category_name'].')';
- Exclude checks
Variable "category_name" is not in valid camel caps format Open
$output .= '<option value="'.$session['id'].'">'.$session['title'].' '.$category_name.'</option>';
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
'OriginCoursesFromSession'
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
'DestinationCoursesFromSession'
- Exclude checks
Variable "tbl_course" is not in valid camel caps format Open
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
).':</b></td>';
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
).'</a>';
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
).':</b></td>';
- Exclude checks
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(
- Exclude checks
Consider putting global function "make_select_session_list" in a static class Open
function make_select_session_list($name, $sessions, $attr = [])
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
).'</option>';
- Exclude checks
Variable "course_list_destination" is not in valid camel caps format Open
$course_list_destination[] = $course['code'];
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
)."'".')) return false;">'.get_lang('Copy course').'</button>';
- Exclude checks
Consider putting global function "searchCourses" in a static class Open
function searchCourses($idSession, $type)
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES)
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
'SelectASession'
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
).'</option>';
- Exclude checks
Missing function doc comment Open
function searchCourses($idSession, $type)
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
).'">'.
- Exclude checks
Variable "course_list_destination" is not in valid camel caps format Open
Session::write('course_list_destination', $course_list_destination);
- Exclude checks
Multi-line function call not indented correctly; expected 16 spaces but found 20 Open
$course['title'].' ('.$course['visual_code'].')',
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
).':</b></td>';
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
).'</a>';
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
).'</option>';
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
get_lang('Copy courseFromSessionToSessionExplanation')
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
'SelectASession'
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
$sessionId
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
'ThereIsNotStillASession'
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
).':</b></td>';
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
).'</td>';
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
).'</option>';
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
'DestinationCoursesFromSession'
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
'OriginCoursesFromSession'
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
).'</option>';
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
'ThereIsNotStillASession'
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
).'">'.
- Exclude checks
Multi-line function call not indented correctly; expected 16 spaces but found 20 Open
$course['title'].' ('.$course['visual_code'].')',
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES)
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
'SelectASession'
- Exclude checks
Multi-line function call not indented correctly; expected 4 spaces but found 8 Open
)."'".')) return false;">'.get_lang('Copy course').'</button>';
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
).'</option>';
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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) {
- Read upRead up
- Exclude checks
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();
}
}