Avoid using static access to class '\Vtiger_Widget_Model' in method 'checkPermission'. Open
$this->widgetModel = \Vtiger_Widget_Model::getInstanceWithTemplateId($request->getInteger('widgetId'));
- 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\Link' in method 'checkPermission'. Open
if ($request->isEmpty('widgetId', true) && !$request->isEmpty('blockId', true) && $linkData = \vtlib\Link::getLinkData($request->getInteger('linkId'))) {
- 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 assigning values to variables in if clauses and the like (line '30', column '85'). Open
public function checkPermission(App\Request $request)
{
parent::checkPermission($request);
if ($request->isEmpty('widgetId', true) && !$request->isEmpty('blockId', true) && $linkData = \vtlib\Link::getLinkData($request->getInteger('linkId'))) {
$linkData['blockid'] = $request->getInteger('blockId');
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class '\Vtiger_Widget_Model' in method 'checkPermission'. Open
$this->widgetModel = \Vtiger_Widget_Model::getInstanceFromValues($linkData);
- 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
The method checkPermission uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->widgetModel = \Vtiger_Widget_Model::getInstanceWithTemplateId($request->getInteger('widgetId'));
}
- 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
Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->successBtnIcon
Open
$viewer->assign('BTN_SUCCESS_ICON', $this->successBtnIcon);
- Exclude checks
Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->footerClass
Open
$viewer->assign('FOOTER_CLASS', $this->footerClass);
- Exclude checks
Call to undeclared method \Settings_WidgetsManagement_EditWidget_View::getViewer
Open
$viewer = $this->getViewer($request);
- Exclude checks
Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->widgetModel
Open
$this->widgetModel = \Vtiger_Widget_Model::getInstanceFromValues($linkData);
- Exclude checks
Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->widgetModel
Open
$viewer->assign('WIDGET_MODEL', $this->widgetModel);
- Exclude checks
Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->widgetModel
Open
return $this->widgetModel->getTranslatedTitle();
- Exclude checks
Call to method getInstanceWithTemplateId
from undeclared class \Vtiger_Widget_Model
Open
$this->widgetModel = \Vtiger_Widget_Model::getInstanceWithTemplateId($request->getInteger('widgetId'));
- Exclude checks
Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->widgetModel
Open
$this->widgetModel = \Vtiger_Widget_Model::getInstanceWithTemplateId($request->getInteger('widgetId'));
- Exclude checks
Call to method getInstanceFromValues
from undeclared class \Vtiger_Widget_Model
Open
$this->widgetModel = \Vtiger_Widget_Model::getInstanceFromValues($linkData);
- Exclude checks
Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->successBtn
Open
$viewer->assign('BTN_SUCCESS', $this->successBtn);
- Exclude checks
Reference to undeclared property \Settings_WidgetsManagement_EditWidget_View->dangerBtn
Open
$viewer->assign('BTN_DANGER', $this->dangerBtn);
- Exclude checks
Avoid excessively long class names like Settings_WidgetsManagement_EditWidget_View. Keep class name length under 40. Open
class Settings_WidgetsManagement_EditWidget_View extends \App\Controller\ModalSettings
{
/** {@inheritdoc} */
public $modalIcon = 'adminIcon-widgets-configuration';
- Read upRead up
- Exclude checks
LongClassName
Since: 2.9
Detects when classes or interfaces are declared with excessively long names.
Example
class ATooLongClassNameThatHintsAtADesignProblem {
}
interface ATooLongInterfaceNameThatHintsAtADesignProblem {
}
Source https://phpmd.org/rules/naming.html#longclassname
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_WidgetsManagement_EditWidget_View extends \App\Controller\ModalSettings
- Exclude checks
The class Settings_WidgetsManagement_EditWidget_View is not named in CamelCase. Open
class Settings_WidgetsManagement_EditWidget_View extends \App\Controller\ModalSettings
{
/** {@inheritdoc} */
public $modalIcon = 'adminIcon-widgets-configuration';
- 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
public $modalSize = 'modal-md';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::checkPermission($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->widgetModel = \Vtiger_Widget_Model::getInstanceFromValues($linkData);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function checkPermission(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('BTN_SUCCESS', $this->successBtn);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('FOOTER_CLASS', $this->footerClass);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $showFooter = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 161 characters Open
if ($request->isEmpty('widgetId', true) && !$request->isEmpty('blockId', true) && $linkData = \vtlib\Link::getLinkData($request->getInteger('linkId'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function process(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('BTN_SUCCESS_ICON', $this->successBtnIcon);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$linkData['blockid'] = $request->getInteger('blockId');
- 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->widgetModel->getTranslatedTitle();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('EditWidget.tpl', $qualifiedModuleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $modalIcon = 'adminIcon-widgets-configuration';
- 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
$qualifiedModuleName = $request->getModule(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->widgetModel = \Vtiger_Widget_Model::getInstanceWithTemplateId($request->getInteger('widgetId'));
- 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
/** {@inheritdoc} */
- 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
$viewer->assign('BTN_DANGER', $this->dangerBtn);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer = $this->getViewer($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->isEmpty('widgetId', true) && !$request->isEmpty('blockId', true) && $linkData = \vtlib\Link::getLinkData($request->getInteger('linkId'))) {
- 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 getPageTitle(App\Request $request)
- 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
$viewer->assign('WIDGET_MODEL', $this->widgetModel);
- Exclude checks
Class name "Settings_WidgetsManagement_EditWidget_View" is not in camel caps format Open
class Settings_WidgetsManagement_EditWidget_View extends \App\Controller\ModalSettings
- Exclude checks