The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->build_export_form();
}
- 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 parameters such as '$show_pdf'. Open
protected function build_export_form_option($show_pdf = true)
- 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
The parameter $form_type is not named in camelCase. Open
public function __construct(
$form_type,
$form_name,
$method = 'post',
$action = null,
- 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 $form_name is not named in camelCase. Open
public function __construct(
$form_type,
$form_name,
$method = 'post',
$action = null,
- 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 $locked_status is not named in camelCase. Open
public function __construct(
$form_type,
$form_name,
$method = 'post',
$action = null,
- 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 $show_pdf is not named in camelCase. Open
protected function build_export_form_option($show_pdf = true)
{
$this->addElement('header', get_lang('PDF report'));
$this->addElement('radio', 'file_type', get_lang('Output file type'), 'CSV (Comma-Separated Values)', 'csv');
$this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml');
- 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
Missing parameter name Open
* @param int form_type 1=import, 2=export
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
$this->form_type = $form_type;
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
} elseif (self::TYPE_EXPORT == $this->form_type) {
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
} elseif (self::TYPE_EXPORT_PDF == $this->form_type) {
- Exclude checks
Missing function doc comment Open
public function setDefaults($defaultValues = [], $filter = null)
- Exclude checks
Missing parameter name Open
* @param obj cat_obj the category object
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
$this->form_type = $form_type;
- Exclude checks
Missing parameter name Open
* @param obj res_obj the result object
- Exclude checks
Missing parameter name Open
* @param action
- Exclude checks
Method name "DataForm::build_export_form" is not in camel caps format Open
protected function build_export_form()
- Exclude checks
Missing parameter name Open
* @param method
- Exclude checks
Method name "DataForm::build_export_form_option" is not in camel caps format Open
protected function build_export_form_option($show_pdf = true)
- Exclude checks
Method name "DataForm::build_pdf_export_form" is not in camel caps format Open
protected function build_pdf_export_form()
- Exclude checks
Method name "DataForm::build_import_form" is not in camel caps format Open
protected function build_import_form()
- Exclude checks
Variable "form_name" is not in valid camel caps format Open
$form_name,
- Exclude checks
Variable "form_name" is not in valid camel caps format Open
parent:: __construct($form_name, $method, $action, $target);
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
if (self::TYPE_IMPORT == $this->form_type) {
- Exclude checks
Variable "locked_status" is not in valid camel caps format Open
if (0 == $locked_status) {
- Exclude checks
Variable "show_pdf" is not in valid camel caps format Open
protected function build_export_form_option($show_pdf = true)
- Exclude checks
Variable "form_type" is not in valid camel caps format Open
$form_type,
- Exclude checks
Missing parameter name Open
* @param string form name
- Exclude checks
Variable "locked_status" is not in valid camel caps format Open
$locked_status
- Exclude checks
Missing function doc comment Open
public function display()
- Exclude checks
Arguments with default values must be at the end of the argument list Open
$locked_status
- Exclude checks
The variable $form_name is not named in camelCase. Open
public function __construct(
$form_type,
$form_name,
$method = 'post',
$action = null,
- 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 $locked_status is not named in camelCase. Open
public function __construct(
$form_type,
$form_name,
$method = 'post',
$action = null,
- 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 $form_type is not named in camelCase. Open
public function __construct(
$form_type,
$form_name,
$method = 'post',
$action = null,
- 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 method build_export_form_option is not named in camelCase. Open
protected function build_export_form_option($show_pdf = true)
{
$this->addElement('header', get_lang('PDF report'));
$this->addElement('radio', 'file_type', get_lang('Output file type'), 'CSV (Comma-Separated Values)', 'csv');
$this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml');
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method build_import_form is not named in camelCase. Open
protected function build_import_form()
{
$this->addElement('hidden', 'formSent');
$this->addElement('header', get_lang('Import marks in an assessment'));
$this->addElement('file', 'import_file', get_lang('URL/URI'));
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method build_pdf_export_form is not named in camelCase. Open
protected function build_pdf_export_form()
{
$renderer = &$this->defaultRenderer();
$renderer->setCustomElementTemplate('<span>{element}</span>');
$this->addElement('header', get_lang('Choose orientation'));
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method build_export_form is not named in camelCase. Open
protected function build_export_form()
{
$this->addElement('header', get_lang('PDF report'));
$this->addElement('radio', 'file_type', get_lang('Output file type'), 'CSV (Comma-Separated Values)', 'csv');
$this->addElement('radio', 'file_type', null, 'XML (Extensible Markup Language)', 'xml');
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}