Missing class import via use statement (line '93', column '26'). Open
$queryGenerator = (new \App\QueryGenerator($this->moduleName));
- 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
Missing class import via use statement (line '32', column '14'). Open
throw new \Api\Core\Exception('No permission - wrong data', 401);
- 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
Missing class import via use statement (line '40', column '14'). Open
throw new \Api\Core\Exception('No permissions for module', 403);
- 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 '\Api\Core\Module' in method 'checkPermissionToModule'. Open
if (!\Api\Core\Module::checkModuleAccess($this->moduleName) || !\App\Privilege::isPermitted($this->moduleName, 'CreateView') || !($provider = \App\Integrations\SMSProvider::getDefaultProvider()) || 'SMSAPI' !== $provider->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 using static access to class '\Vtiger_Record_Model' in method 'post'. Open
&& ($recordModel = \Vtiger_Record_Model::getInstanceById($recordId, $this->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 '\Vtiger_Record_Model' in method 'post'. Open
$newRecordModel = \Vtiger_Record_Model::getCleanInstance($this->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\Record' in method 'post'. Open
if ($recordId && \App\Record::isExists($recordId, $this->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 assigning values to variables in if clauses and the like (line '97', column '8'). Open
public function post()
{
$msgId = $this->controller->request->getByType('MsgId', \App\Purifier::ALNUM);
$message = $this->controller->request->getByType('sms_text', \App\Purifier::HTML);
$smsFrom = $this->controller->request->getByType('sms_from', \App\Purifier::DIGITS);
- 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 '\App\Integrations\SMSProvider' in method 'checkPermissionToModule'. Open
if (!\Api\Core\Module::checkModuleAccess($this->moduleName) || !\App\Privilege::isPermitted($this->moduleName, 'CreateView') || !($provider = \App\Integrations\SMSProvider::getDefaultProvider()) || 'SMSAPI' !== $provider->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 using static access to class '\App\Privilege' in method 'checkPermissionToModule'. Open
if (!\Api\Core\Module::checkModuleAccess($this->moduleName) || !\App\Privilege::isPermitted($this->moduleName, 'CreateView') || !($provider = \App\Integrations\SMSProvider::getDefaultProvider()) || 'SMSAPI' !== $provider->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 assigning values to variables in if clauses and the like (line '39', column '133'). Open
protected function checkPermissionToModule(): void
{
if (!\Api\Core\Module::checkModuleAccess($this->moduleName) || !\App\Privilege::isPermitted($this->moduleName, 'CreateView') || !($provider = \App\Integrations\SMSProvider::getDefaultProvider()) || 'SMSAPI' !== $provider->getName()) {
throw new \Api\Core\Exception('No permissions for module', 403);
}
- 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 '\App\Integrations\SMSProvider' in method 'post'. Open
$provider = \App\Integrations\SMSProvider::getProviderByName('SMSAPI');
- 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 "phone" 3 times. Open
&& $smsFrom === $provider->setPhone($recordModel->get('phone'))->get('to')
- 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 method __construct
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator = (new \App\QueryGenerator($this->moduleName));
- Exclude checks
Method \Api\SMS\SMSAPI\Reception::post
is declared to return array
but has no return value Open
public function post()
- Exclude checks
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$recordId = $queryGenerator->setFields(['id'])->addCondition('msgid', $msgId, 'e')->createQuery()->scalar();
- Exclude checks
Possibly zero references to use statement for classlike/namespace OA
(\OpenApi\Annotations)
Open
use OpenApi\Annotations as OA;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* "url" : "https://www.smsapi.pl/docs"
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* },
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* response=200,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Response(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* description="Response",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
&& ($recordModel = \Vtiger_Record_Model::getInstanceById($recordId, $this->moduleName))
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* summary="Receipt of SMS",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Response(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* description="No permissions for module",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* type="string",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$msgId = $this->controller->request->getByType('MsgId', \App\Purifier::ALNUM);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$recordId = $queryGenerator->setFields(['id'])->addCondition('msgid', $msgId, 'e')->createQuery()->scalar();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$newRecordModel->set($msgField->getName(), $msgField->getDBValue($message))
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->set('related_to', $recordModel->get('related_to'))
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* },
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Response(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* schema="SMS_SMSAPI_Post_Reception",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* {"ApiKeyAuth" : {}, "token" : {}}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Response(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* response=403,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* example="OK"
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$newRecordModel->save();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
echo 'OK';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Response(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* description="`No sent token` OR `Invalid token` OR `wrong data provided in the request`",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* example="OK"
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* path="/webservice/SMS/SMSAPI/Reception",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* {"ApiKeyAuth" : {}, "token" : {}}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* description="Result",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* description="Method Not Allowed",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* summary="Receipt of SMS",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function post()
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->set('smsnotifier_status', 'PLL_REPLY')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* security={
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* title="Response",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
&& $smsFrom === $provider->setPhone($recordModel->get('phone'))->get('to')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* response=401,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* tags={"SMSAPI"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* externalDocs={
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* description="Result",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Response(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Response(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Response(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* schema="SMS_SMSAPI_Post_Reception",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$message = $this->controller->request->getByType('sms_text', \App\Purifier::HTML);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$queryGenerator = (new \App\QueryGenerator($this->moduleName));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($recordId && \App\Record::isExists($recordId, $this->moduleName)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->set('parentid', $recordModel->getId())
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* tags={"SMSAPI"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* },
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* description="`No sent token` OR `Invalid token` OR `wrong data provided in the request`",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* response=405,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* title="Response",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$msgField = $newRecordModel->getField('message');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* "url" : "https://www.smsapi.pl/docs"
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\JsonContent(ref="#/components/schemas/SMS_SMSAPI_Post_Reception")
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* description="No permissions for module",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* response=405,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\Schema(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$smsFrom = $this->controller->request->getByType('sms_from', \App\Purifier::DIGITS);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->set('phone', $recordModel->get('phone'));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* },
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* response=401,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* response=403,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$provider = \App\Integrations\SMSProvider::getProviderByName('SMSAPI');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* "description" : "SMSApi Documentation",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* security={
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* response=200,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* description="Method Not Allowed",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* type="string",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* externalDocs={
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* "description" : "SMSApi Documentation",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @OA\JsonContent(ref="#/components/schemas/SMS_SMSAPI_Post_Reception")
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* description="Response",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$newRecordModel = \Vtiger_Record_Model::getCleanInstance($this->moduleName);
- 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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @OA\Get(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Module name */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected function checkPermission(): void
- 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
parent::checkPermission();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $moduleName = 'SMSNotifier';
- 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
Line exceeds 120 characters; contains 242 characters Open
if (!\Api\Core\Module::checkModuleAccess($this->moduleName) || !\App\Privilege::isPermitted($this->moduleName, 'CreateView') || !($provider = \App\Integrations\SMSProvider::getDefaultProvider()) || 'SMSAPI' !== $provider->getName()) {
- 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
public $allowedMethod = ['POST'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \Api\Core\Exception('No permission - wrong data', 401);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Add record.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected function checkPermissionToModule(): void
- 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
throw new \Api\Core\Exception('No permissions for module', 403);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* path="/webservice/SMS/SMSAPI/Reception",
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->controller->request->isEmpty('MsgId', true)) {
- 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
if (!\Api\Core\Module::checkModuleAccess($this->moduleName) || !\App\Privilege::isPermitted($this->moduleName, 'CreateView') || !($provider = \App\Integrations\SMSProvider::getDefaultProvider()) || 'SMSAPI' !== $provider->getName()) {
- Exclude checks