Skip to content

Commit

Permalink
Upgrade PHPstan (#1173)
Browse files Browse the repository at this point in the history
* deps: upgrade phpstan

* fix phpstan errors
  • Loading branch information
Rubc authored Mar 20, 2024
1 parent 80c2fd3 commit fc7c121
Show file tree
Hide file tree
Showing 22 changed files with 172 additions and 68 deletions.
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
"mi-schi/phpmd-extension": "^4.2",
"phpmd/phpmd": "^2.6",
"phpspec/prophecy": "^1.19",
"phpstan/phpstan": "^0.12",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-doctrine": "^1.3",
"phpunit/phpunit": "^9.6",
"squizlabs/php_codesniffer": "^3.3",
"symfony/browser-kit": "^5.0",
Expand Down Expand Up @@ -94,7 +96,8 @@
"sort-packages": true,
"process-timeout": 0,
"allow-plugins": {
"symfony/flex": true
"symfony/flex": true,
"phpstan/extension-installer": true
}
},
"conflict": {
Expand Down
148 changes: 131 additions & 17 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
parameters:
inferPrivatePropertyTypeFromConstructor: true
excludes_analyse:
- %rootDir%/../../../src/Migrations/*
excludePaths:
- %rootDir%/../../../src/Migrations/*
5 changes: 1 addition & 4 deletions src/Command/CleanupAlertCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace App\Command;

use App\DependencyInjection\CleanupAlert;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -15,13 +14,11 @@ class CleanupAlertCommand extends Command
{
protected static $defaultName = 'app:cleanupAlert';

private $logger;
private $cleanupAlert;

public function __construct(LoggerInterface $logger, CleanupAlert $cleanupAlert)
public function __construct(CleanupAlert $cleanupAlert)
{
$this->cleanupAlert = $cleanupAlert;
$this->logger = $logger;

parent::__construct();
}
Expand Down
3 changes: 0 additions & 3 deletions src/Controller/SlaveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@

class SlaveController extends AbstractController
{
private $em = null;
private $logger = null;

private $domainSlaveGroupCache = [];
private $deviceSlaveGroupCache = [];
private $domainProbeCache = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function getLastseen()
/**
* @return string
*/
public function __toString()
public function __toString(): string
{
return $this->alertRule->getName().' on '.$this->device->getName().' from '.$this->slaveGroup->getName();
}
Expand Down
5 changes: 5 additions & 0 deletions src/Entity/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Device
private $ip;

/**
* @var ArrayCollection<int, SlaveGroup>
* @ORM\ManyToMany(targetEntity="SlaveGroup", inversedBy="devices", fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="device_slavegroups",
* joinColumns={@ORM\JoinColumn(name="device_id", referencedColumnName="id", onDelete="CASCADE")},
Expand All @@ -78,6 +79,7 @@ class Device
private $slavegroups;

/**
* @var ArrayCollection<int, Probe>
* @ORM\ManyToMany(targetEntity="Probe", fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="device_probes",
* joinColumns={@ORM\JoinColumn(name="device_id", referencedColumnName="id", onDelete="CASCADE")},
Expand All @@ -90,6 +92,7 @@ class Device
private $probes;

/**
* @var ArrayCollection<int, AlertRule>
* @ORM\ManyToMany(targetEntity="AlertRule", fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="device_alert_rules",
* joinColumns={@ORM\JoinColumn(name="device_id", referencedColumnName="id", onDelete="CASCADE")},
Expand All @@ -102,6 +105,7 @@ class Device
private $alertRules;

/**
* @var ArrayCollection<int, AlertDestination>
* @ORM\ManyToMany(targetEntity="AlertDestination", fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="device_alert_destinations",
* joinColumns={@ORM\JoinColumn(name="device_id", referencedColumnName="id", onDelete="CASCADE")},
Expand All @@ -113,6 +117,7 @@ class Device
private $alertDestinations;

/**
* @var ArrayCollection<int, Alert>
* @ORM\OneToMany(targetEntity="Alert", mappedBy="device", fetch="EXTRA_LAZY")
*/
private $alerts;
Expand Down
4 changes: 4 additions & 0 deletions src/Entity/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Domain
private $name;

/**
* @var ArrayCollection<int, SlaveGroup>
* @ORM\ManyToMany(targetEntity="SlaveGroup", inversedBy="domains", fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="domain_slavegroups",
* joinColumns={@ORM\JoinColumn(name="domain_id", referencedColumnName="id", onDelete="CASCADE")},
Expand All @@ -72,6 +73,7 @@ class Domain
private $slavegroups;

/**
* @var ArrayCollection<int, Probe>
* @ORM\ManyToMany(targetEntity="Probe", fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="domain_probes",
* joinColumns={@ORM\JoinColumn(name="domain_id", referencedColumnName="id", onDelete="CASCADE")},
Expand All @@ -83,6 +85,7 @@ class Domain
private $probes;

/**
* @var ArrayCollection<int, AlertRule>
* @ORM\ManyToMany(targetEntity="AlertRule", fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="domain_alert_rules",
* joinColumns={@ORM\JoinColumn(name="domain_id", referencedColumnName="id", onDelete="CASCADE")},
Expand All @@ -94,6 +97,7 @@ class Domain
private $alertRules;

/**
* @var ArrayCollection<int, AlertDestination>
* @ORM\ManyToMany(targetEntity="AlertDestination", fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="domain_alert_destinations",
* joinColumns={@ORM\JoinColumn(name="domain_id", referencedColumnName="id", onDelete="CASCADE")},
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Probe.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Probe
private $samples;

/**
* @var string
* @var string|null
*
* @ORM\Column(name="arguments", type="text")
*/
Expand Down
4 changes: 3 additions & 1 deletion src/Entity/SlaveGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,19 @@ class SlaveGroup
private $name;

/**
* @var ArrayCollection<int, Device>
* @ORM\ManyToMany(targetEntity="Device", mappedBy="slavegroups")
*/
private $devices;

/**
* @var ArrayCollection<int, Domain>
* @ORM\ManyToMany(targetEntity="Domain", mappedBy="slavegroups")
*/
private $domains;

/**
* @var ArrayCollection
* @var ArrayCollection<int, Slave>
* @ORM\OneToMany(targetEntity="Slave", mappedBy="slavegroup")
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
* @ORM\OrderBy({"id" = "asc"})
Expand Down
1 change: 1 addition & 0 deletions src/Entity/StorageNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class StorageNode
private $status;

/**
* @var ArrayCollection<int, Device>
* @ORM\OneToMany(targetEntity="App\Entity\Device", mappedBy="storageNode")
*/
private $devices;
Expand Down
4 changes: 1 addition & 3 deletions src/EventSubscriber/MenuBuilderSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ class MenuBuilderSubscriber implements EventSubscriberInterface
private $domainRepository;
private $slaveRepository;
private $storageNodeRepository;
private $security;

public function __construct(DomainRepository $domainRepository, Security $security, AlertRepository $alertRepository, SlaveRepository $slaveRepository, StorageNodeRepository $storageNodeRepository)
public function __construct(DomainRepository $domainRepository, AlertRepository $alertRepository, SlaveRepository $slaveRepository, StorageNodeRepository $storageNodeRepository)
{
$this->alertRepository = $alertRepository;
$this->domainRepository = $domainRepository;
$this->slaveRepository = $slaveRepository;
$this->storageNodeRepository = $storageNodeRepository;
$this->security = $security;
}

public static function getSubscribedEvents(): array
Expand Down
Loading

0 comments on commit fc7c121

Please sign in to comment.