Missing class import via use statement (line '39', column '59'). Open
foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(ROOT_DIRECTORY . '/cache/logs', \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
- 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 '39', column '28'). Open
foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(ROOT_DIRECTORY . '/cache/logs', \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
- 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 '\vtlib\Functions' in method 'logs'. Open
$this->climate->bold('Size of deleted log files: ' . \vtlib\Functions::showBytes($s));
- 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\Session' in method 'session'. Open
$this->climate->bold('Number of deleted sessions: ' . \App\Session::cleanAll());
- 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 'cacheData'. Open
$this->climate->bold('Clear opcache: ' . \App\Cache::clearOpcache());
- 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\Session' in method 'session'. Open
\App\Session::load();
- 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 'cacheData'. Open
$this->climate->bold('Clear: ' . \App\Cache::clear());
- 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 'cacheFiles'. Open
$stats = \App\Cache::clearTemporaryFiles('now');
- 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 'cacheFiles'. Open
$this->climate->bold(" - files: {$stats['counter']} , size: " . \vtlib\Functions::showBytes($stats['size']));
- 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 'logs'. Open
$this->climate->bold($iterator->getSubPathName() . ' - ' . \vtlib\Functions::showBytes($item->getSize()));
- 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 "action" 3 times. Open
if (!$this->climate->arguments->defined('action')) {
- 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.
Define a constant instead of duplicating this literal "Cleaner" 4 times. Open
public $moduleName = 'Cleaner';
- 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 bold
from undeclared class \League\CLImate\CLImate
Open
$this->climate->bold('Size of deleted log files: ' . \vtlib\Functions::showBytes($s));
- Exclude checks
Call to method lightYellow
from undeclared class \League\CLImate\CLImate
Open
$this->climate->lightYellow()->border('─', 200);
- Exclude checks
Call to method lightYellow
from undeclared class \League\CLImate\CLImate
Open
$this->climate->lightYellow()->border('─', 200);
- Exclude checks
Call to method lightYellow
from undeclared class \League\CLImate\CLImate
Open
$this->climate->lightYellow()->border('─', 200);
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
if (!$this->climate->arguments->defined('action')) {
- Exclude checks
Call to method bold
from undeclared class \League\CLImate\CLImate
Open
$this->climate->bold('Clear opcache: ' . \App\Cache::clearOpcache());
- Exclude checks
Call to method bold
from undeclared class \League\CLImate\CLImate
Open
$this->climate->bold('Removing all sessions...');
- Exclude checks
Suspicious type bool
of a variable or expression used to build a string. (Expected type to be able to cast to a string) Open
$this->climate->bold('Clear opcache: ' . \App\Cache::clearOpcache());
- Exclude checks
Call to method bold
from undeclared class \League\CLImate\CLImate
Open
$this->climate->bold('Removing all logs...');
- Exclude checks
Call to method bold
from undeclared class \League\CLImate\CLImate
Open
$this->climate->bold('Number of deleted log files: ' . $i);
- Exclude checks
Call to method lightYellow
from undeclared class \League\CLImate\CLImate
Open
$this->climate->lightYellow()->border('─', 200);
- Exclude checks
Call to method lightYellow
from undeclared class \League\CLImate\CLImate
Open
$this->climate->lightYellow()->border('─', 200);
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
if (!$this->climate->arguments->defined('action')) {
- Exclude checks
Call to method bold
from undeclared class \League\CLImate\CLImate
Open
$this->climate->bold(" - files: {$stats['counter']} , size: " . \vtlib\Functions::showBytes($stats['size']));
- Exclude checks
Call to undeclared method \RecursiveIteratorIterator::getSubPathName
Open
$this->climate->bold($iterator->getSubPathName() . ' - ' . \vtlib\Functions::showBytes($item->getSize()));
- Exclude checks
Call to method bold
from undeclared class \League\CLImate\CLImate
Open
$this->climate->bold('Clear: ' . \App\Cache::clear());
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
if (!$this->climate->arguments->defined('action')) {
- Exclude checks
Suspicious type bool
of a variable or expression used to build a string. (Expected type to be able to cast to a string) Open
$this->climate->bold('Clear: ' . \App\Cache::clear());
- Exclude checks
Call to method bold
from undeclared class \League\CLImate\CLImate
Open
$this->climate->bold($iterator->getSubPathName() . ' - ' . \vtlib\Functions::showBytes($item->getSize()));
- Exclude checks
Call to method bold
from undeclared class \League\CLImate\CLImate
Open
$this->climate->bold('Number of deleted sessions: ' . \App\Session::cleanAll());
- Exclude checks
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = $s = 0;
- 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
Avoid variables with short names like $s. Configured minimum length is 3. Open
$i = $s = 0;
- 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
'cacheData' => 'Cache 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
* Delete all logs.
- 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
'session' => 'Delete all sessions',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->bold('Removing all logs...');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->lightYellow()->border('─', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->lightYellow()->border('─', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->bold($iterator->getSubPathName() . ' - ' . \vtlib\Functions::showBytes($item->getSize()));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->bold('Size of deleted log files: ' . \vtlib\Functions::showBytes($s));
- 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
$i = $s = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($item->isFile() && 'index.html' !== $item->getBasename()) {
- 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
* Delete all session.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->bold('Removing all sessions...');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->bold('Number of deleted log files: ' . $i);
- 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
public $moduleName = 'Cleaner';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function logs(): 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->climate->arguments->defined('action')) {
- 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 cacheFiles(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return 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
$this->climate->bold('Clear opcache: ' . \App\Cache::clearOpcache());
- 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
'logs' => 'Delete all logs',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'cacheFiles' => 'Cache files',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$s += $item->getSize();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unlink($item->getPathname());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$i;
- 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->climate->bold('Number of deleted sessions: ' . \App\Session::cleanAll());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->lightYellow()->border('─', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$this->climate->bold($iterator->getSubPathName() . ' - ' . \vtlib\Functions::showBytes($item->getSize()));
- 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
/** @var string[] Methods list */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(ROOT_DIRECTORY . '/cache/logs', \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->climate->arguments->defined('action')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->climate->arguments->defined('action')) {
- 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
* Clear cache files.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function session(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->bold('Clear: ' . \App\Cache::clear());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $methods = [
- Exclude checks
Line exceeds 120 characters; contains 216 characters Open
foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(ROOT_DIRECTORY . '/cache/logs', \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
- 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->climate->lightYellow()->border('─', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Clear cache data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function cacheData(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->cli->actionsList('Cleaner');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->cli->actionsList('Cleaner');
- 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 void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->lightYellow()->border('─', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->bold(" - files: {$stats['counter']} , size: " . \vtlib\Functions::showBytes($stats['size']));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Session::load();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->cli->actionsList('Cleaner');
- 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 void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$stats = \App\Cache::clearTemporaryFiles('now');
- Exclude checks