Missing class import via use statement (line '126', column '20'). Open
$doc = new \PhpOffice\PhpWord\PhpWord();
- 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
The method exportCompleteReportCSV uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($header_col))).';';
}
- 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 exportCompleteReportCSV uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
header('Content-Disposition: attachment; filename= '.$filename);
}
- 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 private fields such as '$results'. Open
private $results = []; //stores the results
- Read upRead up
- Exclude checks
UnusedPrivateField
Since: 0.2
Detects when a private field is declared and/or assigned a value, but not used.
Example
class Something
{
private static $FOO = 2; // Unused
private $i = 5; // Unused
private $j = 6;
public function addOne()
{
return $this->j++;
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatefield
Avoid unused local variables such as '$column'. Open
$column = 0;
- 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
Avoid unused private fields such as '$gradebook_list'. Open
private $gradebook_list = []; //stores the list of exercises
- Read upRead up
- Exclude checks
UnusedPrivateField
Since: 0.2
Detects when a private field is declared and/or assigned a value, but not used.
Example
class Something
{
private static $FOO = 2; // Unused
private $i = 5; // Unused
private $j = 6;
public function addOne()
{
return $this->j++;
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatefield
Avoid unused parameters such as '$get_answers'. Open
public function __construct($get_questions = false, $get_answers = false)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$get_questions'. Open
public function __construct($get_questions = false, $get_answers = false)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid using count() function in for loops. Open
for ($i = 0; $i < count($data[0]); $i++) {
$table->addCell(1750)->addText(strip_tags($data[0][$i]));
}
- Read upRead up
- Exclude checks
CountInLoopExpression
Since: 2.7.0
Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.
Example
class Foo {
public function bar()
{
$array = array();
for ($i = 0; count($array); $i++) {
// ...
}
}
}
Source https://phpmd.org/rules/design.html#countinloopexpression
Avoid using count() function in for loops. Open
for ($i = 0; $i < count($dataLine); $i++) {
$table->addCell(1750)->addText(strip_tags($dataLine[$i]));
}
- Read upRead up
- Exclude checks
CountInLoopExpression
Since: 2.7.0
Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.
Example
class Foo {
public function bar()
{
$array = array();
for ($i = 0; count($array); $i++) {
// ...
}
}
}
Source https://phpmd.org/rules/design.html#countinloopexpression
The parameter $get_questions is not named in camelCase. Open
public function __construct($get_questions = false, $get_answers = false)
{
}
- Read upRead up
- Exclude checks
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
The parameter $get_answers is not named in camelCase. Open
public function __construct($get_questions = false, $get_answers = false)
{
}
- Read upRead up
- Exclude checks
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
The property $gradebook_list is not named in camelCase. Open
class GradeBookResult
{
private $gradebook_list = []; //stores the list of exercises
private $results = []; //stores the results
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Variable "col_name" is not in valid camel caps format Open
foreach ($dato[1][$i] as $col_name) {
- Exclude checks
Variable "header_col" is not in valid camel caps format Open
$list[0][] = html_entity_decode(strip_tags($header_col));
- Exclude checks
Variable "header_col" is not in valid camel caps format Open
foreach ($dato[0] as $header_col) {
- Exclude checks
Variable "col_name" is not in valid camel caps format Open
$list[$column][$line] = html_entity_decode(strip_tags($col_name));
- Exclude checks
Variable "get_answers" is not in valid camel caps format Open
public function __construct($get_questions = false, $get_answers = false)
- Exclude checks
Variable "header_col" is not in valid camel caps format Open
$data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($header_col))).';';
- Exclude checks
Variable "col_name" is not in valid camel caps format Open
$data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($col_name))).';';
- Exclude checks
Variable "header_col" is not in valid camel caps format Open
if (!empty($header_col)) {
- Exclude checks
Variable "header_col" is not in valid camel caps format Open
$data .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($header_col['header']))).';';
- Exclude checks
Variable "cant_students" is not in valid camel caps format Open
$cant_students = count($data[1]);
- Exclude checks
Variable "cant_students" is not in valid camel caps format Open
for ($i = 0; $i < $cant_students; $i++) {
- Exclude checks
Variable "cant_students" is not in valid camel caps format Open
for ($i = 0; $i < $cant_students; $i++) {
- Exclude checks
Variable "header_col" is not in valid camel caps format Open
foreach ($data[0] as $header_col) {
- Exclude checks
Variable "col_name" is not in valid camel caps format Open
foreach ($data[1][$i] as $col_name) {
- Exclude checks
Variable "header_col" is not in valid camel caps format Open
if (is_array($header_col)) {
- Exclude checks
Variable "get_questions" is not in valid camel caps format Open
public function __construct($get_questions = false, $get_answers = false)
- Exclude checks
Variable "header_col" is not in valid camel caps format Open
if (isset($header_col['header'])) {
- Exclude checks
Variable "cant_students" is not in valid camel caps format Open
$cant_students = count($dato[1]);
- Exclude checks
The variable $header_col is not named in camelCase. Open
public function exportCompleteReportCSV($dato)
{
$filename = 'gradebook_results_'.gmdate('YmdGis').'.csv';
$data = '';
- 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 $cant_students is not named in camelCase. Open
public function exportCompleteReportCSV($dato)
{
$filename = 'gradebook_results_'.gmdate('YmdGis').'.csv';
$data = '';
- 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 $col_name is not named in camelCase. Open
public function exportCompleteReportCSV($dato)
{
$filename = 'gradebook_results_'.gmdate('YmdGis').'.csv';
$data = '';
- 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 $cant_students is not named in camelCase. Open
public function exportCompleteReportCSV($dato)
{
$filename = 'gradebook_results_'.gmdate('YmdGis').'.csv';
$data = '';
- 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 $header_col is not named in camelCase. Open
public function exportCompleteReportXLS($data)
{
$filename = 'gradebook-results-'.api_get_local_time();
$list = [];
//headers
- 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 $header_col is not named in camelCase. Open
public function exportCompleteReportCSV($dato)
{
$filename = 'gradebook_results_'.gmdate('YmdGis').'.csv';
$data = '';
- 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 $col_name is not named in camelCase. Open
public function exportCompleteReportXLS($data)
{
$filename = 'gradebook-results-'.api_get_local_time();
$list = [];
//headers
- 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 $header_col is not named in camelCase. Open
public function exportCompleteReportCSV($dato)
{
$filename = 'gradebook_results_'.gmdate('YmdGis').'.csv';
$data = '';
- 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 $header_col is not named in camelCase. Open
public function exportCompleteReportXLS($data)
{
$filename = 'gradebook-results-'.api_get_local_time();
$list = [];
//headers
- 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 $header_col is not named in camelCase. Open
public function exportCompleteReportCSV($dato)
{
$filename = 'gradebook_results_'.gmdate('YmdGis').'.csv';
$data = '';
- 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 $col_name is not named in camelCase. Open
public function exportCompleteReportXLS($data)
{
$filename = 'gradebook-results-'.api_get_local_time();
$list = [];
//headers
- 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 $cant_students is not named in camelCase. Open
public function exportCompleteReportXLS($data)
{
$filename = 'gradebook-results-'.api_get_local_time();
$list = [];
//headers
- 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 $cant_students is not named in camelCase. Open
public function exportCompleteReportXLS($data)
{
$filename = 'gradebook-results-'.api_get_local_time();
$list = [];
//headers
- 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 $header_col is not named in camelCase. Open
public function exportCompleteReportCSV($dato)
{
$filename = 'gradebook_results_'.gmdate('YmdGis').'.csv';
$data = '';
- 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 $col_name is not named in camelCase. Open
public function exportCompleteReportCSV($dato)
{
$filename = 'gradebook_results_'.gmdate('YmdGis').'.csv';
$data = '';
- 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 $header_col is not named in camelCase. Open
public function exportCompleteReportCSV($dato)
{
$filename = 'gradebook_results_'.gmdate('YmdGis').'.csv';
$data = '';
- 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();
}
}