Avoid using undefined variables such as '$languages' which will lead to PHP notices. Open
$languages[] = $legal[1];
- 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 '46', column '36'). Open
$extraFieldValue = new ExtraFieldValue('terms_and_condition');
- 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 '403', column '32'). Open
$extraFieldValue = new ExtraFieldValue('user');
- 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 '424', column '32'). Open
$extraFieldValue = new ExtraFieldValue('user');
- 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 '109', column '33'). Open
$extraFieldValues = new ExtraFieldValue('terms_and_condition');
- 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 add uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
// It means there's a new extra field that was not included before.
$changeList[] = $replace;
}
- 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 '$languages'. Open
$languages[] = $legal[1];
- 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 '$id'. Open
public static function delete($id)
- 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 $legal_id is not named in camelCase. Open
public static function get_type_of_terms_and_conditions($legal_id, $language_id)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$legal_id = (int) $legal_id;
$language_id = (int) $language_id;
- 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 $number_of_items is not named in camelCase. Open
public static function get_legal_data($from, $number_of_items, $column)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$from = (int) $from;
- 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 $term_preview is not named in camelCase. Open
public static function show_last_condition($term_preview)
{
$preview = '';
switch ($term_preview['type']) {
case 0:
- 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 $language_id is not named in camelCase. Open
public static function get_type_of_terms_and_conditions($legal_id, $language_id)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$legal_id = (int) $legal_id;
$language_id = (int) $language_id;
- 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
Variable "term_preview" is not in valid camel caps format Open
<div id="legal-terms" class="scrollbar-inner">'.$term_preview['content'].'</div>
- Exclude checks
Variable "number_of_items" is not in valid camel caps format Open
public static function get_legal_data($from, $number_of_items, $column)
- Exclude checks
Variable "language_id" is not in valid camel caps format Open
WHERE id = $legal_id AND language_id = $language_id";
- Exclude checks
Method name "LegalManager::show_last_condition" is not in camel caps format Open
public static function show_last_condition($term_preview)
- Exclude checks
Variable "lang_table" is not in valid camel caps format Open
INNER JOIN $lang_table l
- Exclude checks
Variable "language_id" is not in valid camel caps format Open
public static function get_type_of_terms_and_conditions($legal_id, $language_id)
- Exclude checks
Variable "legal_id" is not in valid camel caps format Open
WHERE id = $legal_id AND language_id = $language_id";
- Exclude checks
Method name "LegalManager::get_last_version" is not in camel caps format Open
public static function get_last_version($language)
- Exclude checks
Variable "term_preview" is not in valid camel caps format Open
switch ($term_preview['type']) {
- Exclude checks
Method name "LegalManager::get_legal_data" is not in camel caps format Open
public static function get_legal_data($from, $number_of_items, $column)
- Exclude checks
Method name "LegalManager::get_type_of_terms_and_conditions" is not in camel caps format Open
public static function get_type_of_terms_and_conditions($legal_id, $language_id)
- Exclude checks
Variable "legal_id" is not in valid camel caps format Open
$legal_id = (int) $legal_id;
- Exclude checks
Variable "number_of_items" is not in valid camel caps format Open
$number_of_items = (int) $number_of_items;
- Exclude checks
Method name "LegalManager::get_last_condition" is not in camel caps format Open
public static function get_last_condition($language)
- Exclude checks
Variable "term_preview" is not in valid camel caps format Open
public static function show_last_condition($term_preview)
- Exclude checks
Variable "language_id" is not in valid camel caps format Open
$language_id = (int) $language_id;
- Exclude checks
Expected 2 spaces after parameter name; 1 found Open
* @param int $userId The user to send legal terms to
- Exclude checks
Variable "legal_id" is not in valid camel caps format Open
public static function get_type_of_terms_and_conditions($legal_id, $language_id)
- Exclude checks
Variable "legal_id" is not in valid camel caps format Open
$legal_id = (int) $legal_id;
- Exclude checks
Variable "term_preview" is not in valid camel caps format Open
if (!empty($term_preview['content'])) {
- Exclude checks
Variable "lang_table" is not in valid camel caps format Open
$lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
- Exclude checks
Variable "number_of_items" is not in valid camel caps format Open
$number_of_items = (int) $number_of_items;
- Exclude checks
Variable "number_of_items" is not in valid camel caps format Open
LIMIT $from, $number_of_items ";
- Exclude checks
Variable "language_id" is not in valid camel caps format Open
$language_id = (int) $language_id;
- Exclude checks
The 'get_last_version()' method which returns a boolean should be named 'is...()' or 'has...()' Open
public static function get_last_version($language)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$language = (int) $language;
$sql = "SELECT version FROM $table
- Read upRead up
- Exclude checks
BooleanGetMethodName
Since: 0.2
Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.
Example
class Foo {
/**
* @return boolean
*/
public function getFoo() {} // bad
/**
* @return bool
*/
public function isFoo(); // ok
/**
* @return boolean
*/
public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}
Source https://phpmd.org/rules/naming.html#booleangetmethodname
The variable $legal_id is not named in camelCase. Open
public static function get_type_of_terms_and_conditions($legal_id, $language_id)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$legal_id = (int) $legal_id;
$language_id = (int) $language_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 $language_id is not named in camelCase. Open
public static function get_type_of_terms_and_conditions($legal_id, $language_id)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$legal_id = (int) $legal_id;
$language_id = (int) $language_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 $language_id is not named in camelCase. Open
public static function get_type_of_terms_and_conditions($legal_id, $language_id)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$legal_id = (int) $legal_id;
$language_id = (int) $language_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 $legal_id is not named in camelCase. Open
public static function get_type_of_terms_and_conditions($legal_id, $language_id)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$legal_id = (int) $legal_id;
$language_id = (int) $language_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 $legal_id is not named in camelCase. Open
public static function get_type_of_terms_and_conditions($legal_id, $language_id)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$legal_id = (int) $legal_id;
$language_id = (int) $language_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 $term_preview is not named in camelCase. Open
public static function show_last_condition($term_preview)
{
$preview = '';
switch ($term_preview['type']) {
case 0:
- 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 $term_preview is not named in camelCase. Open
public static function show_last_condition($term_preview)
{
$preview = '';
switch ($term_preview['type']) {
case 0:
- 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 $term_preview is not named in camelCase. Open
public static function show_last_condition($term_preview)
{
$preview = '';
switch ($term_preview['type']) {
case 0:
- 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 $lang_table is not named in camelCase. Open
public static function get_legal_data($from, $number_of_items, $column)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$from = (int) $from;
- 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 $number_of_items is not named in camelCase. Open
public static function get_legal_data($from, $number_of_items, $column)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$from = (int) $from;
- 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 $number_of_items is not named in camelCase. Open
public static function get_legal_data($from, $number_of_items, $column)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$from = (int) $from;
- 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 $lang_table is not named in camelCase. Open
public static function get_legal_data($from, $number_of_items, $column)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$from = (int) $from;
- 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 $language_id is not named in camelCase. Open
public static function get_type_of_terms_and_conditions($legal_id, $language_id)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$legal_id = (int) $legal_id;
$language_id = (int) $language_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 $number_of_items is not named in camelCase. Open
public static function get_legal_data($from, $number_of_items, $column)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$from = (int) $from;
- 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 get_last_version is not named in camelCase. Open
public static function get_last_version($language)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$language = (int) $language;
$sql = "SELECT version FROM $table
- 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 get_last_condition is not named in camelCase. Open
public static function get_last_condition($language)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$language = (int) $language;
$sql = "SELECT * FROM $table
- 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 get_legal_data is not named in camelCase. Open
public static function get_legal_data($from, $number_of_items, $column)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$from = (int) $from;
- 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 get_type_of_terms_and_conditions is not named in camelCase. Open
public static function get_type_of_terms_and_conditions($legal_id, $language_id)
{
$table = Database::get_main_table(TABLE_MAIN_LEGAL);
$legal_id = (int) $legal_id;
$language_id = (int) $language_id;
- 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 show_last_condition is not named in camelCase. Open
public static function show_last_condition($term_preview)
{
$preview = '';
switch ($term_preview['type']) {
case 0:
- 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() {
}
}