Avoid using undefined variables such as '$selectedTabidsList' which will lead to PHP notices. Open
'tabid' => $selectedTabidsList,
- 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 '$selectedTabidsList' which will lead to PHP notices. Open
$selectedTabidsList[] = \App\Module::getModuleId($this->getName());
- 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 '49', column '23'). Open
$dataReader = (new \App\Db\Query())->select(['fieldid'])
- 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 getFields has a boolean flag argument $blockInstance, which is a certain sign of a Single Responsibility Principle violation. Open
public function getFields($blockInstance = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid using static access to class 'Settings_Leads_Field_Model' in method 'getFields'. Open
$fieldModel = Settings_Leads_Field_Model::getInstance($fieldId, $this);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Module' in method 'getMappingSupportedFieldIdsList'. Open
$selectedTabidsList[] = \App\Module::getModuleId($this->getName());
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid unused parameters such as '$blockInstance'. Open
public function getFields($blockInstance = 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
Reference to undeclared property \Settings_Leads_Module_Model->supportedFieldIdsList
Open
return $this->supportedFieldIdsList;
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$dataReader = (new \App\Db\Query())->select(['fieldid'])
- Exclude checks
Saw unextractable annotation for comment '* @return <array> list of field ids'</array>
Open
* @return <Array> list of field ids
- Exclude checks
Reference to undeclared property \Settings_Leads_Module_Model->supportedFieldIdsList
Open
$this->supportedFieldIdsList = [];
- Exclude checks
Saw unextractable annotation for comment '* @return <array> Restricted ui types'</array>
Open
* @return <array> Restricted ui types
- Exclude checks
Reference to undeclared property \Settings_Leads_Module_Model->supportedFieldIdsList
Open
if (empty($this->supportedFieldIdsList)) {
- Exclude checks
Argument 2 (module)
is \Settings_Leads_Module_Model|\Vtiger_Module_Model|\vtlib\Module|\vtlib\ModuleBasic
but \Settings_Leads_Field_Model::getInstance()
takes false|string
defined at /code/modules/Settings/Leads/models/Field.php:62
Open
$fieldModel = Settings_Leads_Field_Model::getInstance($fieldId, $this);
- Exclude checks
Variable $selectedTabidsList
was undeclared, but array fields are being added to it. Open
$selectedTabidsList[] = \App\Module::getModuleId($this->getName());
- Exclude checks
Reference to undeclared property \Settings_Leads_Module_Model->supportedFieldIdsList
Open
$this->supportedFieldIdsList[] = $field;
- Exclude checks
Saw unextractable annotation for comment '* @return <array> list of field models <settings_leads_field_model>'</settings_leads_field_model></array>
Open
* @return <Array> list of field models <Settings_Leads_Field_Model>
- Exclude checks
Saw unextractable annotation for comment '* @return <settings_leads_module_model>'</settings_leads_module_model>
Open
* @return <Settings_Leads_Module_Model>
- Exclude checks
Returning type array<string>|array<string></string></string>
but getFields()
is declared to return \Vtiger_Field_Model[]
Open
return $this->fields;
- Exclude checks
Avoid excessively long variable names like $selectedGeneratedTypes. Keep variable name length under 20. Open
$selectedGeneratedTypes = [1, 2];
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_Leads_Module_Model extends Vtiger_Module_Model
- Exclude checks
The class Settings_Leads_Module_Model is not named in CamelCase. Open
class Settings_Leads_Module_Model extends Vtiger_Module_Model
{
/**
* Function to get fields of this model.
*
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->fields) {
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
->andWhere(['and', ['NOT IN', 'uitype', $restrictedUitypes], ['NOT IN', 'fieldname', $restrictedFieldNames]])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getRestrictedUitypes()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFields($blockInstance = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->fields;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$presense = [0, 2];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = parent::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($this->supportedFieldIdsList)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the Restricted Ui Types.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $moduleModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = Settings_Leads_Field_Model::getInstance($fieldId, $this);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = (new \App\Db\Query())->select(['fieldid'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($objectProperties as $properName => $propertyValue) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModelsList = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getMappingSupportedFieldIdsList()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [4, 51, 52, 53, 57, 58, 69, 70];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel->{$properName} = $propertyValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $blockInstance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->supportedFieldIdsList = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($field = $dataReader->readColumn(0)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <array> Restricted ui types
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = new self();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Array> list of field ids
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tabid' => $selectedTabidsList,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->supportedFieldIdsList[] = $field;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get instance of module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Settings_Leads_Module_Model>
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$selectedGeneratedTypes = [1, 2];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'presence' => $presense,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Array> list of field models <Settings_Leads_Field_Model>
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get mapping supported field ids list.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$restrictedUitypes = $this->getRestrictedUitypes();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$objectProperties = get_object_vars($moduleModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->fields = $fieldModelsList;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$restrictedFieldNames = ['campaignrelstatus'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModelsList[$fieldModel->getFieldDataType()][$fieldId] = $fieldModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldIds = $this->getMappingSupportedFieldIdsList();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->andWhere(['and', ['NOT IN', 'uitype', $restrictedUitypes], ['NOT IN', 'fieldname', $restrictedFieldNames]])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->supportedFieldIdsList;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get fields of this model.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'generatedtype' => $selectedGeneratedTypes,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fieldIds as $fieldId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$selectedTabidsList[] = \App\Module::getModuleId($this->getName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_field')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getInstance($moduleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Class name "Settings_Leads_Module_Model" is not in camel caps format Open
class Settings_Leads_Module_Model extends Vtiger_Module_Model
- Exclude checks