src/Command/ClearCacheCommand.php
execute accesses the super-global variable $_ENV. Open
Open
protected function execute(InputInterface $input, OutputInterface $output)
{
$cachePath = $_ENV['CACHE_FOLDER'];
$logger = new ConsoleLogger($output);
$result = CommandHelper::clearFolderContents($cachePath, $logger);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Avoid using static access to class '\TikiManager\Command\Helper\CommandHelper' in method 'execute'. Open
Open
$result = CommandHelper::clearFolderContents($cachePath, $logger);
- 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
Argument 2 (logger)
is \Symfony\Component\Console\Logger\ConsoleLogger
but \TikiManager\Command\Helper\CommandHelper::clearFolderContents()
takes \Psr\Log\LoggerInterface
defined at /code/src/Command/Helper/CommandHelper.php:370
Open
Open
$result = CommandHelper::clearFolderContents($cachePath, $logger);
- Exclude checks