Skip to content

Commit

Permalink
refactor: Fixing psalm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
philipsorst committed May 4, 2024
1 parent 69d74b5 commit 1256d00
Show file tree
Hide file tree
Showing 21 changed files with 53 additions and 88 deletions.
3 changes: 3 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedCode="false"
findUnusedPsalmSuppress="true"
ensureOverrideAttribute="true"

>
<projectFiles>
<directory name="src" />
Expand Down
5 changes: 2 additions & 3 deletions src/Command/Encrypt/GenerateKeyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Dontdrinkandroot\BridgeBundle\Command\Encrypt;

use Dontdrinkandroot\BridgeBundle\Service\EncryptionService;
use Override;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -19,9 +20,7 @@ public function __construct(private readonly EncryptionService $encryptionServic
parent::__construct();
}

/**
* {@inheritdoc}
*/
#[Override]
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln(bin2hex($this->encryptionService->generateKey()));
Expand Down
18 changes: 5 additions & 13 deletions src/Command/Mail/SendMailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Dontdrinkandroot\BridgeBundle\Command\Mail;

use Dontdrinkandroot\BridgeBundle\Service\Mail\MailServiceInterface;
use Override;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -23,28 +24,22 @@ public function __construct(
parent::__construct();
}

/**
* {@inheritdoc}
*/
#[Override]
protected function configure(): void
{
$this->addOption('to', null, InputOption::VALUE_REQUIRED, 'The to address of the message')
->addOption('subject', null, InputOption::VALUE_REQUIRED, 'The subject of the message')
->addOption('markdown', null, InputOption::VALUE_REQUIRED, 'The body of the message provided in markdown');
}

/**
* {@inheritdoc}
*/
#[Override]
protected function initialize(InputInterface $input, OutputInterface $output): void
{
$this->io = new SymfonyStyle($input, $output);
$this->io->title('Send Email');
}

/**
* {@inheritdoc}
*/
#[Override]
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->mailService->sendMailMarkdown(
Expand All @@ -58,10 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::SUCCESS;
}


/**
* {@inheritdoc}
*/
#[Override]
protected function interact(InputInterface $input, OutputInterface $output): void
{
$options = ['to', 'subject', 'markdown'];
Expand Down
5 changes: 2 additions & 3 deletions src/Command/User/EditCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Dontdrinkandroot\BridgeBundle\Repository\User\UserRepository;
use Dontdrinkandroot\Common\Asserted;
use Dontdrinkandroot\DoctrineBundle\Service\TransactionManager\TransactionManagerRegistry;
use Override;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
Expand Down Expand Up @@ -37,9 +38,7 @@ public function __construct(
parent::__construct();
}

/**
* {@inheritdoc}
*/
#[Override]
protected function execute(InputInterface $input, OutputInterface $output): int
{
return $this->transactionManagerRegistry->getDefault()->transactional(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\Persistence\ManagerRegistry;
use Dontdrinkandroot\Common\Asserted;
use Dontdrinkandroot\DoctrineBundle\Entity\EntityInterface;
use Override;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
Expand All @@ -17,9 +18,7 @@ public function __construct(
) {
}

/**
* {@inheritdoc}
*/
#[Override]
public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\Persistence\ManagerRegistry;
use Dontdrinkandroot\Common\Asserted;
use Dontdrinkandroot\DoctrineBundle\Entity\UuidInterface;
use Override;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
Expand All @@ -18,9 +19,7 @@ public function __construct(
) {
}

/**
* {@inheritdoc}
*/
#[Override]
public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
if (
Expand Down
5 changes: 2 additions & 3 deletions src/DdrBridgeBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace Dontdrinkandroot\BridgeBundle;

use Override;
use Symfony\Component\HttpKernel\Bundle\Bundle;

use function dirname;

class DdrBridgeBundle extends Bundle
{
/**
* {@inheritdoc}
*/
#[Override]
public function getPath(): string
{
return dirname(__DIR__);
Expand Down
3 changes: 2 additions & 1 deletion src/Model/Health/HealthStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
namespace Dontdrinkandroot\BridgeBundle\Model\Health;

use JsonSerializable;
use Override;

class HealthStatus implements JsonSerializable
{
/**
* @param bool $ok
* @param array<string,mixed> $info
*/
public function __construct(public bool $ok, public array $info = [])
{
}

#[Override]
public function jsonSerialize(): array
{
return [
Expand Down
9 changes: 3 additions & 6 deletions src/Routing/NestedLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Dontdrinkandroot\BridgeBundle\Routing;

use InvalidArgumentException;
use Override;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Routing\Loader\YamlFileLoader;
use Symfony\Component\Routing\RouteCollection;
Expand All @@ -14,17 +15,13 @@

class NestedLoader extends YamlFileLoader
{
/**
* {@inheritdoc}
*/
#[Override]
public function supports($resource, string $type = null): bool
{
return 'ddr_nested' === $type;
}

/**
* {@inheritdoc}
*/
#[Override]
public function load(mixed $file, string $type = null): RouteCollection
{
$path = $this->locator->locate($file);
Expand Down
5 changes: 2 additions & 3 deletions src/Service/DdrCrudAdmin/DontdrinkandrootTemplateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

use Dontdrinkandroot\Common\CrudOperation;
use Dontdrinkandroot\CrudAdminBundle\Service\Template\TemplateProviderInterface;
use Override;

class DontdrinkandrootTemplateProvider implements TemplateProviderInterface
{
/**
* {@inheritdoc}
*/
#[Override]
public function provideTemplate(string $entityClass, CrudOperation $crudOperation): string
{
$prefix = '@DdrBridge/DdrCrudAdmin/';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@
use Dontdrinkandroot\CrudAdminBundle\Model\FieldDefinition;
use Dontdrinkandroot\CrudAdminBundle\Service\FieldRenderer\FieldRenderer;
use Dontdrinkandroot\CrudAdminBundle\Service\FieldRenderer\FieldRendererProviderInterface;
use Override;

class MillisecondsRendererProvider implements FieldRendererProviderInterface
{
/**
* {@inheritdoc}
*/
#[Override]
public function supports(FieldDefinition $fieldDefinition, mixed $value): bool
{
return 'milliseconds' === $fieldDefinition->displayType;
}

/**
* {@inheritdoc}
*/
#[Override]
public function render(FieldDefinition $fieldDefinition, mixed $value): string
{
return FieldRenderer::escapeHtml(DateUtils::fromMillis($value)->format('Y-m-d H:i:s'));
Expand Down
5 changes: 2 additions & 3 deletions src/Service/DdrCrudAdmin/UuidEntityIdProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
use Dontdrinkandroot\Common\CrudOperation;
use Dontdrinkandroot\CrudAdminBundle\Service\Id\IdProviderInterface;
use Dontdrinkandroot\DoctrineBundle\Entity\UuidInterface;
use Override;

class UuidEntityIdProvider implements IdProviderInterface
{
/**
* {@inheritdoc}
*/
#[Override]
public function provideId(string $entityClass, CrudOperation $crudOperation, object $entity): mixed
{
if (!($entity instanceof UuidInterface)) {
Expand Down
5 changes: 2 additions & 3 deletions src/Service/DdrCrudAdmin/UuidEntityItemProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Dontdrinkandroot\CrudAdminBundle\Service\Item\ItemProviderInterface;
use Dontdrinkandroot\DoctrineBundle\Entity\UuidInterface;
use InvalidArgumentException;
use Override;
use Symfony\Component\Uid\Uuid;

class UuidEntityItemProvider implements ItemProviderInterface
Expand All @@ -18,9 +19,7 @@ public function __construct(private readonly ManagerRegistry $managerRegistry)
{
}

/**
* {@inheritdoc}
*/
#[Override]
public function provideItem(string $entityClass, CrudOperation $crudOperation, mixed $id): ?object
{
if (
Expand Down
9 changes: 3 additions & 6 deletions src/Service/Health/DoctrineHealthProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,21 @@
use Doctrine\Persistence\ManagerRegistry;
use Dontdrinkandroot\BridgeBundle\Model\Health\HealthStatus;
use Dontdrinkandroot\Common\Asserted;
use Override;

class DoctrineHealthProvider implements HealthProviderInterface
{
public function __construct(private readonly ManagerRegistry $managerRegistry)
{
}

/**
* {@inheritdoc}
*/
#[Override]
public function getKey(): string
{
return 'database';
}

/**
* {@inheritdoc}
*/
#[Override]
public function getStatus(): HealthStatus
{
$overallOk = true;
Expand Down
9 changes: 3 additions & 6 deletions src/Service/Health/HttpHealthProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Dontdrinkandroot\BridgeBundle\Service\Health;

use Dontdrinkandroot\BridgeBundle\Model\Health\HealthStatus;
use Override;
use Symfony\Component\HttpFoundation\RequestStack;

class HttpHealthProvider implements HealthProviderInterface
Expand All @@ -11,17 +12,13 @@ public function __construct(private readonly RequestStack $requestStack)
{
}

/**
* {@inheritdoc}
*/
#[Override]
public function getKey(): string
{
return 'http';
}

/**
* {@inheritdoc}
*/
#[Override]
public function getStatus(): HealthStatus
{
$request = $this->requestStack->getMainRequest();
Expand Down
9 changes: 3 additions & 6 deletions src/Service/Mail/MailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Dontdrinkandroot\BridgeBundle\Service\Mail;

use League\CommonMark\GithubFlavoredMarkdownConverter;
use Override;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;
Expand All @@ -24,9 +25,7 @@ public function __construct(
]);
}

/**
* {@inheritdoc}
*/
#[Override]
public function sendMailMarkdown(
Address|array $to,
string $subject,
Expand Down Expand Up @@ -55,9 +54,7 @@ public function sendMailMarkdown(
$this->mailer->send($message);
}

/**
* {@inheritdoc}
*/
#[Override]
public function sendMailMarkdownTemplate(
Address|array $to,
string $subject,
Expand Down
5 changes: 2 additions & 3 deletions src/Service/Version/CachedVersionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Dontdrinkandroot\BridgeBundle\Service\Version;

use Override;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Contracts\Cache\CacheInterface;
Expand All @@ -17,9 +18,7 @@ public function __construct(
parent::__construct($kernel, $logger);
}

/**
* {@inheritdoc}
*/
#[Override]
public function getVersion(): string
{
return $this->cache->get('ddr.version', function (ItemInterface $cacheItem): string {
Expand Down
Loading

0 comments on commit 1256d00

Please sign in to comment.