Missing class import via use statement (line '70', column '21'). Open
$fieldInfo = (new \App\Db\Query())->from('vtiger_field')->where([
- 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
Avoid using static access to class '\App\Cache' in method 'getApiFieldPermission'. Open
if (\App\Cache::has('API-FieldPermission', $cacheName)) {
- 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\Cache' in method 'getApiFieldPermission'. Open
return \App\Cache::get('API-FieldPermission', $cacheName);
- 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 '\Api\WebservicePremium\Privilege' in method 'getPermittedModules'. Open
if (\Api\WebservicePremium\Privilege::isPermitted($value['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
Avoid using static access to class '\App\Language' in method 'getPermittedModules'. Open
$modules[$value['name']] = \App\Language::translate($value['name'], $value['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
Avoid using static access to class '\App\Module' in method 'getApiFieldPermission'. Open
'tabid' => \App\Module::getModuleId($moduleName),
- 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 '\vtlib\Functions' in method 'getPermittedModules'. Open
foreach (\vtlib\Functions::getAllModules(false, false, 0) as $value) {
- 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 '\Api\WebservicePremium\Privilege' in method 'checkModuleAccess'. Open
return \Api\WebservicePremium\Privilege::isPermitted($moduleName);
- 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\Cache' in method 'getApiFieldPermission'. Open
\App\Cache::save('API-FieldPermission', $cacheName, $fieldInfo, \App\Cache::LONG);
- 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
Define a constant instead of duplicating this literal "API-FieldPermission" 3 times. Open
if (\App\Cache::has('API-FieldPermission', $cacheName)) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Call to undeclared method \App\Db\Query::from
Open
$fieldInfo = (new \App\Db\Query())->from('vtiger_field')->where([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check module access.
- 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
public static function getPermittedModules(): array
- 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
return isset(static::$permittedModules[$moduleName]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getApiFieldPermission(string $moduleName, int $serverId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected static $permittedModules;
- 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
{
- 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 \App\Cache::get('API-FieldPermission', $cacheName);
- 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
{
- 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
- 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
* Returns info about field to permission for record.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cacheName = $moduleName . $serverId;
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInfo = (new \App\Db\Query())->from('vtiger_field')->where([
- 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
public static function checkModuleAccess($moduleName): bool
- 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
'uitype' => 318,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (\vtlib\Functions::getAllModules(false, false, 0) as $value) {
- 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 static::$permittedModules;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \Api\WebservicePremium\Privilege::isPermitted($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $serverId
- 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
'fieldparams' => $serverId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::save('API-FieldPermission', $cacheName, $fieldInfo, \App\Cache::LONG);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fieldInfo;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::$permittedModules)) {
- 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 bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(static::$permittedModules)) {
- 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|false
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules[$value['name']] = \App\Language::translate($value['name'], $value['name']);
- 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
])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\Api\WebservicePremium\Privilege::isPermitted($value['name'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Permitted modules */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get permitted modules.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$permittedModules = $modules;
- 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 (\App\Cache::has('API-FieldPermission', $cacheName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tabid' => \App\Module::getModuleId($moduleName),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks