modules/Settings/Media/models/Module.php
Avoid using static access to class '\Vtiger_Field_Model' in method 'getFieldInstanceByName'. Open
Open
$this->fields[$name] = \Vtiger_Field_Model::init($moduleName, $params, $name);
- 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
Saw an @param annotation for edit,
but it was not found in the param list of function getFieldInstanceByName(string $name) : \Vtiger_Field_Model
Open
Open
* @param bool $edit
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class Settings_Media_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks
The class Settings_Media_Module_Model is not named in CamelCase. Open
Open
class Settings_Media_Module_Model extends Settings_Vtiger_Module_Model
{
/** @var string Module name */
public $name = 'Media';
/** @var string Parent name */
- 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
Open
* @param string $name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getFieldInstanceByName(string $name)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Gets field instance by name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'label' => 'LBL_ICON',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (!isset($this->fields[$name])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public $parent = 'Settings';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ('image' === $name) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$params = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** @var \Settings_Picklist_Field_Model[] Fields model */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** @var string Module name */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public $name = 'Media';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $this->fields[$name];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'column' => $name,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$this->fields[$name] = \Vtiger_Field_Model::init($moduleName, $params, $name);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
protected $fields = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param bool $edit
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return \Vtiger_Field_Model
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$params = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'uitype' => 69,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** @var string Parent name */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'typeofdata' => 'V~O'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'name' => $name,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$moduleName = $this->getName(true);
- Exclude checks
Class name "Settings_Media_Module_Model" is not in camel caps format Open
Open
class Settings_Media_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks