Skip to content

Commit

Permalink
🚨 Apply PHPStan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelien committed Sep 14, 2024
1 parent ad14730 commit 8f66207
Show file tree
Hide file tree
Showing 21 changed files with 136 additions and 74 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"phpro/grumphp-shim": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.3.2",
"phpstan/phpstan-doctrine": "^1.5",
"phpstan/phpstan-strict-rules": "^1.1.0",
"phpstan/phpstan-symfony": "^1.0.4",
"phpunit/phpunit": "^9.5",
Expand Down
74 changes: 73 additions & 1 deletion composer.lock

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

2 changes: 2 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ parameters:
- public/
- src/
- tests/
ignoreErrors:
- identifier: missingType.iterableValue
6 changes: 0 additions & 6 deletions src/Command/AOICommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$key = $input->getArgument('region');
$region = $this->provider->getRegion(null, $key);

if (null === $region) {
$io->error(sprintf('Region "%s" is not a valid key.', $key));

return Command::FAILURE;
}

$name = sprintf('Welcome Tool for %s', $region['name']);
$filters = [
'geometry' => $this->provider->getGeometry($region['continent'], $region['key']),
Expand Down
2 changes: 2 additions & 0 deletions src/Command/DeletedUsersCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ private function updateCache(SymfonyStyle $io, string $path): CacheItemInterface

/**
* Remove deleted users from `mapper` and `user` tables.
*
* @param int[] $usersDeleted
*/
private function delete(SymfonyStyle $io, array $usersDeleted): void
{
Expand Down
2 changes: 0 additions & 2 deletions src/Controller/API/RegionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Controller\API;

use App\Repository\MapperRepository;
use App\Service\RegionsProvider;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
Expand All @@ -13,7 +12,6 @@ class RegionController extends AbstractController
{
public function __construct(
private readonly RegionsProvider $provider,
private readonly MapperRepository $mapperRepository,
) {
}

Expand Down
2 changes: 0 additions & 2 deletions src/Controller/App/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

use App\Entity\Mapper;
use App\Service\RegionsProvider;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class ListController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly RegionsProvider $provider,
) {
}
Expand Down
7 changes: 4 additions & 3 deletions src/Controller/OpenStreetMapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
// use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

class OpenStreetMapController extends AbstractController
{
#[Route('/connect/openstreetmap', name: 'connect_openstreetmap_start')]
public function connectAction(ClientRegistry $clientRegistry)
public function connectAction(ClientRegistry $clientRegistry): RedirectResponse
{
return $clientRegistry
->getClient('openstreetmap') // key used in config/packages/knpu_oauth2_client.yaml
->redirect([], []);
}

#[Route('/connect/openstreetmap/check', name: 'connect_openstreetmap_check')]
public function connectCheckAction(Request $request, ClientRegistry $clientRegistry)
public function connectCheckAction(Request $request, ClientRegistry $clientRegistry): void
{
// ** if you want to *authenticate* the user, then
// leave this method blank and create a Guard authenticator
Expand All @@ -41,7 +42,7 @@ public function connectCheckAction(Request $request, ClientRegistry $clientRegis
}

#[Route('/logout', name: 'logout', priority: 5)]
public function logout()
public function logout(): void
{
// controller can be blank: it will never be executed!
}
Expand Down
28 changes: 14 additions & 14 deletions src/Entity/Changeset.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,50 @@ class Changeset
{
#[ORM\Id]
#[ORM\Column(type: 'integer')]
private $id;
private int $id;

#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $editor;
private ?string $editor = null;

#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $comment;
private ?string $comment = null;

#[ORM\Column(type: 'array', nullable: true)]
private $reasons = [];
private ?array $reasons = [];

#[ORM\ManyToOne(targetEntity: Mapper::class, inversedBy: 'changesets')]
#[ORM\JoinColumn(nullable: false)]
private $mapper;
private Mapper $mapper;

#[ORM\Column(type: 'integer')]
private $changes_count;
private int $changes_count;

#[ORM\Column(type: 'array')]
private array $extent = [];

#[ORM\Column(type: 'datetime_immutable')]
private $created_at;
private \DateTimeImmutable $created_at;

#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $locale;
private ?string $locale = null;

#[ORM\Column(type: 'integer', nullable: true)]
private $create_count;
private ?int $create_count = null;

#[ORM\Column(type: 'integer', nullable: true)]
private $modify_count;
private ?int $modify_count = null;

#[ORM\Column(type: 'integer', nullable: true)]
private $delete_count;
private ?int $delete_count = null;

#[ORM\Column(type: 'boolean', nullable: true)]
private $harmful;
private ?bool $harmful = null;

#[ORM\Column(type: 'boolean', nullable: true)]
private $suspect;
private ?bool $suspect = null;

#[ORM\Column(type: 'boolean', nullable: true)]
private $checked;
private ?bool $checked = null;

public function getId(): ?int
{
Expand Down
6 changes: 3 additions & 3 deletions src/Entity/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ public function setWelcome(Welcome $welcome): self
}

/**
* @return Collection<int, region>
* @return Collection<int, Region>
*/
public function getRegion(): Collection
{
return $this->region;
}

public function addRegion(region $region): self
public function addRegion(Region $region): self
{
if (!$this->region->contains($region)) {
$this->region->add($region);
Expand All @@ -221,7 +221,7 @@ public function addRegion(region $region): self
return $this;
}

public function removeRegion(region $region): self
public function removeRegion(Region $region): self
{
$this->region->removeElement($region);

Expand Down
14 changes: 7 additions & 7 deletions src/Entity/Note.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ class Note
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
private int $id;

#[ORM\ManyToOne(targetEntity: Mapper::class, inversedBy: 'notes')]
#[ORM\JoinColumn(nullable: false)]
private $mapper;
private Mapper $mapper;

#[ORM\Column(type: 'datetime')]
private $date;
private \DateTime $date;

#[ORM\Column(type: 'text')]
private $text;
private string $text;

#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(nullable: false)]
private $author;
private User $author;

public function getId(): ?int
{
Expand All @@ -44,12 +44,12 @@ public function setMapper(?Mapper $mapper): self
return $this;
}

public function getDate(): ?\DateTimeInterface
public function getDate(): ?\DateTime
{
return $this->date;
}

public function setDate(\DateTimeInterface $date): self
public function setDate(\DateTime $date): self
{
$this->date = $date;

Expand Down
Loading

0 comments on commit 8f66207

Please sign in to comment.