for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Drupal\mongodb_watchdog\Controller;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\Core\Controller\ControllerBase as CoreControllerBase;
use Drupal\mongodb_watchdog\Logger;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class ControllerBase extends CoreControllerBase {
use LoggerAwareTrait;
/**
* The items_per_page configuration value.
*
* @var int
*/
protected $itemsPerPage;
* The MongoDB logger, to load events.
* @var \Drupal\mongodb_watchdog\Logger
protected $watchdog;
* ControllerBase constructor.
* @param \Drupal\Core\Config\ImmutableConfig $config
* The module configuration.
public function __construct(LoggerInterface $logger, Logger $watchdog, ImmutableConfig $config) {
$this->setLogger($logger);
$this->itemsPerPage = $config->get('items_per_page');
$this->watchdog = $watchdog;
}
public static function create(ContainerInterface $container) {
$logger = $container->get('logger.channel.mongodb_watchdog');
$watchdog = $container->get('mongodb.logger');
$watchdog
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
return new static($logger);
This check marks files that end in a newline character, i.e. an empy line.