Avoid using undefined variables such as '$map' which will lead to PHP notices. Open
self::$data[$type] = $map ?? [];
- 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 static access to class '\App\Utils' in method 'remove'. Open
\App\Utils::saveToFile(self::$types[$this->get('type')], $content);
- 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\Utils' in method 'putToFile'. Open
\App\Utils::saveToFile(self::$types[$this->get('type')], $content);
- 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 local variables such as '$map'. Open
self::$data[$type] = $map ?? [];
- 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
Variable $map
is undeclared Open
self::$data[$type] = $map ?? [];
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_RecordAllocation_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks
The class Settings_RecordAllocation_Module_Model is not named in CamelCase. Open
class Settings_RecordAllocation_Module_Model extends Settings_Vtiger_Module_Model
{
private static $data = [];
private static $types = [
'owner' => 'app_data/module_record_allocation.php',
- 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
$moduleName = $data['module'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($fileData[$moduleName]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileData[$moduleName][$userId] = $userData;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileData = self::loadFile($type);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fileData[$moduleName] ?? [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$file = self::$types[$type];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$data = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userData = $data['ids'] ?? [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function remove($moduleName)
- 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 getRecordAllocationByModule($type, $moduleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sharedOwner' => 'app_data/sharedOwner.php',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$data[$type] = $map ?? [];
- 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 self::$data[$type];
- 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
if (!isset(self::$data[$type])) {
- 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
if (!isset($fileData[$moduleName])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
require $file;
- 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
$fileData[$moduleName] = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function resetDataVariable()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileData = self::loadFile($this->get('type'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'owner' => 'app_data/module_record_allocation.php',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function save($data)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Utils::saveToFile(self::$types[$this->get('type')], $content);
- 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
\App\Utils::saveToFile(self::$types[$this->get('type')], $content);
- 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
private static $types = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userId = $data['userid'];
- 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
$content = '$map=' . var_export($fileData, true) . ';';
- 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
$fileData = self::loadFile($this->get('type'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $data = [];
- 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
$this->putToFile($moduleName, $userId, $userData);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content = '$map=' . var_export($fileData, true) . ';';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function putToFile($moduleName, $userId, $userData)
- 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 loadFile($type)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty(self::$types[$type])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [];
- 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
Class name "Settings_RecordAllocation_Module_Model" is not in camel caps format Open
class Settings_RecordAllocation_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks