Avoid using static access to class '\App\Zip' in method 'testInstanceOpenNoFileName'. Open
\App\Zip::openFile(false);
- 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\Zip' in method 'testExtractLinuxFile'. Open
$instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]);
- 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\Zip' in method 'testCreateFileBadDir'. Open
$zip = \App\Zip::createFile(ROOT_DIRECTORY . '/tests/data/NxDir/NxFile.zip');
- 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\Zip' in method 'testUnzipLinuxFile'. Open
$instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]);
- 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\Zip' in method 'testInstanceOpenLinuxFile'. Open
$instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip');
- 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 'testExtractLinuxFile'. Open
\vtlib\Functions::recurseDelete('tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'TestLinux');
- 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 'testUnzipLinuxFile'. Open
\vtlib\Functions::recurseDelete('tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'TestLinux');
- 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 "tests/data/TestLinux.zip" 3 times. Open
$instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip');
- 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.
Argument 1 (fileName)
is 'tests/data/TestLinux.zip'
but \App\Zip::openFile()
takes bool|false
defined at /code/app/Zip.php:51
Open
$instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]);
- Exclude checks
Call to undeclared method \Tests\App\Zip::assertFileExists
Open
$this->assertFileExists('tests/tmp/TestLinux/languages/pl-PL/TestLinux.json');
- Exclude checks
Call to undeclared method \Tests\App\Zip::assertFalse
Open
$this->assertFalse($zip->close());
- Exclude checks
Call to undeclared method \Tests\App\Zip::expectException
Open
$this->expectException(\App\Exceptions\AppException::class);
- Exclude checks
Call to undeclared method \Tests\App\Zip::assertFileExists
Open
$this->assertFileExists('tests/tmp/TestLinux/languages/pl-PL/TestLinux.json');
- Exclude checks
Call to undeclared method \Tests\App\Zip::assertInstanceOf
Open
$this->assertInstanceOf('\App\Zip', $instanceOpen, 'Expected zip object instance');
- Exclude checks
Argument 1 (fileName)
is 'tests/data/TestLinux.zip'
but \App\Zip::openFile()
takes bool|false
defined at /code/app/Zip.php:51
Open
$instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]);
- Exclude checks
Call to undeclared method \Tests\App\Zip::expectException
Open
$this->expectException(\App\Exceptions\AppException::class);
- Exclude checks
Call to undeclared method \Tests\App\Zip::expectWarning
Open
$this->expectWarning();
- Exclude checks
Call to undeclared method \Tests\App\Zip::assertFileExists
Open
$this->assertFileExists('tests/tmp/TestLinux/manifest.xml');
- Exclude checks
Argument 1 (fileName)
is 'tests/data/NxFile.zip'
but \App\Zip::openFile()
takes bool|false
defined at /code/app/Zip.php:51
Open
\App\Zip::openFile('tests/data/NxFile.zip')->close();
- Exclude checks
Argument 1 (fileName)
is 'tests/data/TestLinux.zip'
but \App\Zip::openFile()
takes bool|false
defined at /code/app/Zip.php:51
Open
$instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip');
- Exclude checks
Call to undeclared method \Tests\App\Zip::assertFileExists
Open
$this->assertFileExists('tests/tmp/TestLinux/manifest.xml');
- 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
* @throws \App\Exceptions\AppException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- 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
* Testing instance from linux generated zip file.
- 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 testUnzipLinuxFile(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testExtractLinuxFile(): 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
$this->assertInstanceOf('\App\Zip', $instanceOpen, 'Expected zip object instance');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing linux file extract.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instanceOpen->extract('tests/tmp/TestLinux/');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing file creation in not existent directory.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip->addFromString('filename.txt', '<minimal content>');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing linux file unzip.
- 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
$instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\vtlib\Functions::recurseDelete('tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'TestLinux');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testInstanceOpenNoFileName(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing instance from not existing file.
- 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 testInstanceOpenLinuxFile(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instanceOpen->unzip('tests/tmp/TestLinux/');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFileExists('tests/tmp/TestLinux/languages/pl-PL/TestLinux.json');
- 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\Zip::openFile(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- 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->expectException(\App\Exceptions\AppException::class);
- 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
public function testCreateFileBadDir(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\vtlib\Functions::recurseDelete('tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'TestLinux');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Zip::openFile('tests/data/NxFile.zip')->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFileExists('tests/tmp/TestLinux/manifest.xml');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\AppException
- 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 testInstanceOpenFileNotExists(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFileExists('tests/tmp/TestLinux/languages/pl-PL/TestLinux.json');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip = \App\Zip::createFile(ROOT_DIRECTORY . '/tests/data/NxDir/NxFile.zip');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing instance from file with no file name provided.
- 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
$this->expectException(\App\Exceptions\AppException::class);
- 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
$this->assertFalse($zip->close());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]);
- 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
* @throws \App\Exceptions\AppException
- 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
$this->assertFileExists('tests/tmp/TestLinux/manifest.xml');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->expectWarning();
- Exclude checks