Missing class import via use statement (line '33', column '23'). Open
$this->data = (new \App\Db\Query())->from(self::TABLE_NAME)->one($db) ?: [];
- 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 '__construct'. Open
\App\Cache::save(self::CACHE_NAME, '', $this->data, \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
Avoid using static access to class '\App\Cache' in method '__construct'. Open
$this->data = \App\Cache::get(self::CACHE_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\Cache' in method '__construct'. Open
if (!\App\Cache::has(self::CACHE_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\Purifier' in method 'setToken'. Open
\App\Purifier::purifyByType($token, \App\Purifier::ALNUM2);
- 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\Db' in method '__construct'. Open
$db = \App\Db::getInstance('admin');
- 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 __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->data = \App\Cache::get(self::CACHE_NAME, '');
}
- 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
Avoid using static access to class '\App\Cache' in method 'setToken'. Open
\App\Cache::delete(self::CACHE_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
syntax error, unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST)
Open
private array $data = [];
- Exclude checks
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = \App\Db::getInstance('admin');
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Spaces must be used to indent lines; tabs are not allowed Open
/** Constructor */
- 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
$result = \App\Db::getInstance('admin')->createCommand()->update(self::TABLE_NAME, ['key' => $token])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array 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
public function getToken(): string
- 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\Cache::delete(self::CACHE_NAME, '');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private const CACHE_NAME = 'YetiForce:config';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = $db->createCommand()->insert(self::TABLE_NAME, $data)->execute();
- 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 __construct()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = (new Encryption())->getDefaultData();
- 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 getData(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::save(self::CACHE_NAME, '', $this->data, \App\Cache::LONG);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->data['key'] = $token;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string URL */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private array $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
return $this->data['key'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $token
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const TABLE_NAME = 's_#__reg_data';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->data = $result ? $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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$result = \App\Db::getInstance('admin')->createCommand()->update(self::TABLE_NAME, ['key' => $token])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($result) {
- 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
* @return string
- 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
$db = \App\Db::getInstance('admin');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->data = (new \App\Db\Query())->from(self::TABLE_NAME)->one($db) ?: [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setToken(string $token): 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
return (bool) $result;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\App\Cache::has(self::CACHE_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
* Get 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
}
- 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
* Get token.
- 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
}
- 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 (!$this->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
* Set Token.
- 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\Purifier::purifyByType($token, \App\Purifier::ALNUM2);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->data = \App\Cache::get(self::CACHE_NAME, '');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks