The method FormValidator::addFile() calls the typical debug function var_dump() which is mostly only used during development. Open
var_dump($e->getMessage());
- Read upRead up
- Exclude checks
DevelopmentCodeFragment
Since: 2.3.0
Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.
Example
class SuspectCode {
public function doSomething(array $items)
{
foreach ($items as $i => $item) {
// …
if ('qafoo' == $item) var_dump($i);
// …
}
}
}
Source https://phpmd.org/rules/design.html#developmentcodefragment
The method __construct() has an NPath complexity of 1008. The configured NPath complexity threshold is 200. Open
public function __construct(
string $name,
?string $method = 'post',
?string $action = '',
?string $target = '',
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The class FormValidator has a coupling between objects value of 23. Consider to reduce the number of dependencies under 13. Open
class FormValidator extends HTML_QuickForm
{
public const LAYOUT_HORIZONTAL = 'horizontal';
public const LAYOUT_INLINE = 'inline';
public const LAYOUT_BOX = 'box';
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '1713', column '28'). Open
$mailManager = new MailTemplateManager();
- 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
Missing class import via use statement (line '287', column '23'). Open
throw new \Exception('select_ajax needs an URL');
- 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
Missing class import via use statement (line '971', column '31'). Open
throw new Exception('If you use the crop functionality the element must have an id');
- 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
Missing class import via use statement (line '1667', column '35'). Open
throw new Exception("The $groupName doesn't have the element $elementName");
- 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 __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$renderer->setElementTemplate($this->getDefaultElementTemplate());
// Display a gray div in the buttons
$templateSimple = '<div class="form-actions">{label} {element}</div>';
- 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 addText uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$element = $this->addElement('text', $name, $label, $attributes);
}
- 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 addPasswordRule uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->addRule(
$elementName,
$message,
'callback',
- 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 '$parent'. Open
$parent = null;
- 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 parameters such as '$delay'. Open
public function addProgress($delay = 2, $label = '')
- 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 property $with_progress_bar is not named in camelCase. Open
class FormValidator extends HTML_QuickForm
{
public const LAYOUT_HORIZONTAL = 'horizontal';
public const LAYOUT_INLINE = 'inline';
public const LAYOUT_BOX = 'box';
- 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
Missing function doc comment Open
public function getFormTemplate(): string
- Exclude checks
Expected 6 spaces after parameter name; 3 found Open
* @param bool $required (optional) Is the form-element required (default=true)
- Exclude checks
Expected 3 spaces after parameter type; 2 found Open
* @param null $maxValue
- Exclude checks
Variable "allowed_tags" is not in valid camel caps format Open
$cleaned_html = kses($html, $allowed_tags);
- Exclude checks
Consider putting global function "html_filter_student_fullpage" in a static class Open
function html_filter_student_fullpage($html)
- Exclude checks
Missing function doc comment Open
public function getGridFormTemplate(): string
- Exclude checks
Expected 5 spaces after parameter type; 1 found Open
* @param string $textCallable set a function getStringValue() by default __toString()
- Exclude checks
Missing function doc comment Open
function html_filter_student($html)
- Exclude checks
Missing function doc comment Open
public function getLayout(): string
- Exclude checks
Doc comment for parameter $attributes does not match actual variable name $options Open
* @param array $attributes
- Exclude checks
Missing function doc comment Open
public function addMultiSelect(string $name, $label, array $options, array $attributes = [])
- Exclude checks
Method name "FormValidator::add_multiple_required_rule" is not in camel caps format Open
public function add_multiple_required_rule($elements, $message)
- Exclude checks
Expected 4 spaces after parameter type; 3 found Open
* @param int $minValue
- Exclude checks
Consider putting global function "html_filter" in a static class Open
function html_filter($html, $mode = NO_HTML)
- Exclude checks
Consider putting global function "html_filter_teacher" in a static class Open
function html_filter_teacher($html)
- Exclude checks
Member variable "with_progress_bar" is not in valid camel caps format Open
public $with_progress_bar = false;
- Exclude checks
Expected 4 spaces after parameter name; 1 found Open
* @param array $attributes (optional) List of attributes for the form-element
- Exclude checks
Missing parameter name Open
* @param $label
- Exclude checks
Expected 2 spaces after parameter type; 1 found Open
* @param bool $hideGeoLocalizationDetails
- Exclude checks
Doc comment for parameter $hideGeoLocalizationDetails does not match actual variable name $dataValue Open
* @param bool $hideGeoLocalizationDetails
- Exclude checks
Method name "FormValidator::return_form" is not in camel caps format Open
public function return_form()
- Exclude checks
Variable "cleaned_html" is not in valid camel caps format Open
$cleaned_html = kses($html, $allowed_tags);
- Exclude checks
Expected 9 spaces after parameter name; 6 found Open
* @param string|array $label The label for the form-element
- Exclude checks
Expected 7 spaces after parameter type; 3 found Open
* @param bool $addNoneOption
- Exclude checks
Expected 8 spaces after parameter type; 2 found Open
* @param array $attributes
- Exclude checks
Missing function doc comment Open
public function addEndPanel(): void
- Exclude checks
Missing function doc comment Open
function html_filter_student_fullpage($html)
- Exclude checks
Missing parameter name Open
* @param $label
- Exclude checks
Expected 3 spaces after parameter type; 2 found Open
* @param bool $required
- Exclude checks
Expected 3 spaces after parameter type; 2 found Open
* @param bool $allowNegative
- Exclude checks
Consider putting global function "html_filter_student" in a static class Open
function html_filter_student($html)
- Exclude checks
Missing function doc comment Open
function html_filter_teacher_fullpage($html)
- Exclude checks
Doc comment for parameter $trackSubmit does not match actual variable name $layout Open
* @param bool $trackSubmit Whether to track if the form was submitted by adding a special hidden field
- Exclude checks
Missing function doc comment Open
public function setLayout(string $layout)
- Exclude checks
Variable "with_progress_bar" is not in valid camel caps format Open
if (isset($this->with_progress_bar) && $this->with_progress_bar) {
- Exclude checks
Missing parameter name Open
* @param $label
- Exclude checks
Consider putting global function "html_filter_teacher_fullpage" in a static class Open
function html_filter_teacher_fullpage($html)
- Exclude checks
Missing parameter name Open
* @param $name
- Exclude checks
Missing parameter name Open
* @param $collection
- Exclude checks
Missing function doc comment Open
public function addStartPanel(string $id, string $title, bool $open = false, $icon = null): void
- Exclude checks
Missing parameter name Open
* @param $name
- Exclude checks
Consider putting global function "mobile_phone_number_filter" in a static class Open
function mobile_phone_number_filter($mobilePhoneNumber)
- Exclude checks
Missing function doc comment Open
public function addSelectTheme($name, $label, $options = [], $attributes = [])
- Exclude checks
Variable "with_progress_bar" is not in valid camel caps format Open
if (isset($this->with_progress_bar) && $this->with_progress_bar) {
- Exclude checks
Variable "allowed_tags" is not in valid camel caps format Open
$allowed_tags = HTML_QuickForm_Rule_HTML::get_allowed_tags($mode);
- Exclude checks
Variable "cleaned_html" is not in valid camel caps format Open
return $cleaned_html;
- Exclude checks
Doc comment for parameter $label does not match actual variable name $name Open
* @param string|array $label
- Exclude checks
Expected 2 spaces after parameter type; 1 found Open
* @param array $attributes
- Exclude checks
Expected 7 spaces after parameter type; 1 found Open
* @param string $name
- Exclude checks
Expected 6 spaces after parameter type; 2 found Open
* @param array $attributes
- Exclude checks
Variable "with_progress_bar" is not in valid camel caps format Open
$this->with_progress_bar = true;
- Exclude checks
Missing function doc comment Open
function html_filter_teacher($html)
- Exclude checks
Expected 10 spaces after parameter name; 7 found Open
* @param string $name The element name
- Exclude checks
The variable $cleaned_html is not named in camelCase. Open
function html_filter($html, $mode = NO_HTML)
{
$allowed_tags = HTML_QuickForm_Rule_HTML::get_allowed_tags($mode);
$cleaned_html = kses($html, $allowed_tags);
- 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 $allowed_tags is not named in camelCase. Open
function html_filter($html, $mode = NO_HTML)
{
$allowed_tags = HTML_QuickForm_Rule_HTML::get_allowed_tags($mode);
$cleaned_html = kses($html, $allowed_tags);
- 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 $cleaned_html is not named in camelCase. Open
function html_filter($html, $mode = NO_HTML)
{
$allowed_tags = HTML_QuickForm_Rule_HTML::get_allowed_tags($mode);
$cleaned_html = kses($html, $allowed_tags);
- 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 $allowed_tags is not named in camelCase. Open
function html_filter($html, $mode = NO_HTML)
{
$allowed_tags = HTML_QuickForm_Rule_HTML::get_allowed_tags($mode);
$cleaned_html = kses($html, $allowed_tags);
- 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 add_multiple_required_rule is not named in camelCase. Open
public function add_multiple_required_rule($elements, $message)
{
$this->_required[] = $elements[0];
$this->addRule($elements, $message, 'multiple_required');
}
- 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 return_form is not named in camelCase. Open
public function return_form()
{
return $this->returnForm();
}
- 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() {
}
}