Missing class import via use statement (line '26', column '19'). Open
$instance = new \App\Encryption();
- 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 '36', column '19'). Open
$instance = new \App\Encryption();
- 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\Encryption' in method 'testEncryptionModule'. Open
$instance = clone \App\Encryption::getInstance(\App\Module::getModuleId('Passwords'));
- 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\Config' in method 'testEncryptionWithPass'. Open
\App\Config::set('securityKeys', 'encryptionMethod', $method);
- 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 'testEncryptionModule'. Open
$instance = clone \App\Encryption::getInstance(\App\Module::getModuleId('Passwords'));
- 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\Encryption' in method 'testEncryptionWithPass'. Open
'method in getMethods' => \in_array($instance->get('method'), \App\Encryption::getMethods()),
- 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\Encryption' in method 'testEncryptionWithPass'. Open
$instance = clone \App\Encryption::getInstance();
- 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\Encryption' in method 'testAvailableMethods'. Open
$this->assertTrue(!empty(\App\Encryption::getMethods()), 'The system does not support any methods to encryption');
- 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\Config' in method 'testEncryptionWithPass'. Open
\App\Config::set('securityKeys', 'encryptionPass', $password);
- 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\Config' in method 'testEncryptionWithPass'. Open
'method !== securityKeys(\'encryptionMethod\')' => $instance->get('method') !== \App\Config::securityKeys('encryptionMethod'),
- 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\Config' in method 'testEncryptionWithPass'. Open
$instance->set('pass', \App\Config::securityKeys('encryptionPass'));
- 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 "TEST TEXT" 4 times. Open
$testText = 'TEST TEXT';
- 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 "1234567890123456" 4 times. Open
['aes-256-cbc', '1234567890123456'],
- 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 "method" 5 times. Open
$instance->set('method', $method);
- 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 getMethods
from undeclared class \App\Encryption
(Did you mean class \Tests\App\Encryption) Open
$this->assertTrue(!empty(\App\Encryption::getMethods()), 'The system does not support any methods to encryption');
- Exclude checks
Call to undeclared method \Tests\App\Encryption::assertTrue
Open
$this->assertTrue(!empty($encryptText), 'Encryption is not available');
- Exclude checks
Call to method decrypt
from undeclared class \App\Encryption
(Did you mean class \Tests\App\Encryption) Open
$this->assertSame($testText, $instance->decrypt($testText), 'Encryption should be disabeld');
- Exclude checks
Call to undeclared method \Tests\App\Encryption::assertSame
Open
$this->assertSame($testText, $instance->decrypt($testText), 'Encryption should be disabeld');
- Exclude checks
Call to undeclared method \Tests\App\Encryption::assertSame
Open
$this->assertSame($testText, $instance->decrypt($encryptText), 'The decrypted text does not match the encrypted text');
- Exclude checks
Call to undeclared method \Tests\App\Encryption::assertTrue
Open
$this->assertTrue(!empty($encryptText), 'Encryption is not available');
- Exclude checks
Call to undeclared method \Tests\App\Encryption::assertSame
Open
$this->assertSame($testText, $instance->decrypt($encryptText, true), 'The decrypted text does not match the encrypted text');
- Exclude checks
Call to method __construct
from undeclared class \App\Encryption
(Did you mean class \Tests\App\Encryption) Open
$instance = new \App\Encryption();
- Exclude checks
Call to method getInstance
from undeclared class \App\Encryption
(Did you mean class \Tests\App\Encryption) Open
$instance = clone \App\Encryption::getInstance(\App\Module::getModuleId('Passwords'));
- Exclude checks
Call to method __construct
from undeclared class \App\Encryption
(Did you mean class \Tests\App\Encryption) Open
$instance = new \App\Encryption();
- Exclude checks
Call to method encrypt
from undeclared class \App\Encryption
(Did you mean class \Tests\App\Encryption) Open
$this->assertSame($testText, $instance->encrypt($testText), 'Encryption should be disabeld');
- Exclude checks
Call to method getMethods
from undeclared class \App\Encryption
(Did you mean class \Tests\App\Encryption) Open
'method in getMethods' => \in_array($instance->get('method'), \App\Encryption::getMethods()),
- Exclude checks
Call to undeclared method \Tests\App\Encryption::assertNotSame
Open
$this->assertNotSame($testText, $encryptText, 'Encryption is not working');
- Exclude checks
Call to undeclared method \Tests\App\Encryption::assertTrue
Open
$this->assertTrue(!empty(\App\Encryption::getMethods()), 'The system does not support any methods to encryption');
- Exclude checks
Call to undeclared method \Tests\App\Encryption::assertSame
Open
$this->assertSame($testText, $instance->encrypt($testText), 'Encryption should be disabeld');
- Exclude checks
Call to undeclared method \Tests\App\Encryption::assertTrue
Open
$this->assertTrue($instance->isActive(), 'The encryption mechanism is not active');
- Exclude checks
Call to undeclared method \Tests\App\Encryption::assertTrue
Open
$this->assertTrue($instance->isActive(true), 'The encryption mechanism is not active');
- Exclude checks
Call to undeclared method \Tests\App\Encryption::assertNotSame
Open
$this->assertNotSame($testText, $encryptText, 'Encryption is not working');
- Exclude checks
Call to method getInstance
from undeclared class \App\Encryption
(Did you mean class \Tests\App\Encryption) Open
$instance = clone \App\Encryption::getInstance();
- 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 testEncryptionWithPass(string $method, string $password)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($testText, $instance->decrypt($encryptText), 'The decrypted text does not match the encrypted text');
- 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
$instance = new \App\Encryption();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Provide test data for testEncryptionWithPass function.
- 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
['aes-256-ctr', '1234567890123456'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['aes-192-cbc', '1234567890123456'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['aes-192-ctr', '1234567890123456'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing process function.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$testText = 'TEST TEXT';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertTrue(!empty($encryptText), 'Encryption is not available');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($testText, $instance->encrypt($testText), 'Encryption should be disabeld');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $password
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotSame($testText, $encryptText, 'Encryption is not working');
- 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
* @param string $method
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = clone \App\Encryption::getInstance();
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
'method !== securityKeys(\'encryptionMethod\')' => $instance->get('method') !== \App\Config::securityKeys('encryptionMethod'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$encryptText = $instance->encrypt($testText);
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
$this->assertSame($testText, $instance->decrypt($encryptText), 'The decrypted text does not match the encrypted text');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->set('vector', $password);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (['TEST TEXT', ''] as $testText) {
- 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
'method in getMethods' => \in_array($instance->get('method'), \App\Encryption::getMethods()),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertTrue($instance->isActive(true), 'The encryption mechanism is not active');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($testText, $instance->decrypt($encryptText, true), 'The decrypted text does not match the encrypted text');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Test decrypt data when encryption is disabled.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @codeCoverageIgnore
- 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
$instance = clone \App\Encryption::getInstance(\App\Module::getModuleId('Passwords'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->set('method', $method);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($testText) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$testText = 'TEST TEXT';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertTrue(!empty(\App\Encryption::getMethods()), 'The system does not support any methods to encryption');
- 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
$instance->set('method', $method);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotSame($testText, $encryptText, 'Encryption is not working');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->set('pass', $password);
- 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
['des-ede3-cbc', '12354678'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'method !== securityKeys(\'encryptionMethod\')' => $instance->get('method') !== \App\Config::securityKeys('encryptionMethod'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $method
- 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 testEncryptionModule(string $method, string $password)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$encryptText = $instance->encrypt($testText, true);
- 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
\App\Config::set('securityKeys', 'encryptionMethod', $method);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Config::set('securityKeys', 'encryptionPass', $password);
- 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 function encryptionProvider()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->set('pass', \App\Config::securityKeys('encryptionPass'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->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
}
- 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
['des-ede3-cfb', '12354678'],
- 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->assertTrue($instance->isActive(), 'The encryption mechanism is not active');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing process function for module.
- 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
$testText = 'TEST TEXT';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testDecryptWithoutPass()
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$this->assertTrue(!empty(\App\Encryption::getMethods()), 'The system does not support any methods to encryption');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @dataProvider encryptionProvider
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'isEmpty(\'method\')' => $instance->isEmpty('method'),
- 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
* Test encrypt data when encryption is disabled.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = new \App\Encryption();
- 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
['aes-256-cbc', '1234567890123456'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'function_exists(\'openssl_encrypt\')' => \function_exists('openssl_encrypt'),
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
$this->assertSame($testText, $instance->decrypt($encryptText, true), 'The decrypted text does not match the encrypted text');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testEncryptWithoutPass()
- 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 [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->set('vector', $password);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertTrue(!empty($encryptText), 'Encryption is not available');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($testText, $instance->decrypt($testText), 'Encryption should be disabeld');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testAvailableMethods()
- 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
* @param string $password
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @dataProvider encryptionProvider
- Exclude checks