Skip to content

Commit

Permalink
style: rector
Browse files Browse the repository at this point in the history
  • Loading branch information
Grafikart committed Mar 30, 2024
1 parent 0849fec commit c222bc9
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/Domain/Comment/Entity/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Comment
private Collection $replies;

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

#[ORM\ManyToOne(targetEntity: \App\Domain\Application\Entity\Content::class)]
#[ORM\JoinColumn(onDelete: 'CASCADE', nullable: false, name: 'content_id')]
Expand Down
4 changes: 2 additions & 2 deletions src/Domain/Password/Event/PasswordRecoveredEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use App\Domain\Auth\User;

final class PasswordRecoveredEvent
final readonly class PasswordRecoveredEvent
{
public function __construct(private readonly User $user)
public function __construct(private User $user)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/Domain/Password/Event/PasswordResetTokenCreatedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use App\Domain\Auth\User;
use App\Domain\Password\Entity\PasswordResetToken;

final class PasswordResetTokenCreatedEvent
final readonly class PasswordResetTokenCreatedEvent
{
public function __construct(private readonly PasswordResetToken $token)
public function __construct(private PasswordResetToken $token)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Revision/Event/RevisionRefusedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class RevisionRefusedEvent
{
public function __construct(private readonly Revision $revision, private string $comment)
public function __construct(private readonly Revision $revision, private readonly string $comment)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Admin/Data/SchoolCrudData.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ class SchoolCrudData extends AutomaticCrudData
#[Assert\NotBlank]
public int $credits = 0;

public ?User $owner;
public ?User $owner = null;
}
6 changes: 3 additions & 3 deletions src/Http/Api/DataProvider/CommentApiProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
use Symfony\Component\HttpKernel\Exception\HttpException;
use Vich\UploaderBundle\Templating\Helper\UploaderHelper;

final class CommentApiProvider implements ProviderInterface
final readonly class CommentApiProvider implements ProviderInterface
{
public function __construct(
private readonly CommentRepository $commentRepository,
private readonly UploaderHelper $uploaderHelper
private CommentRepository $commentRepository,
private UploaderHelper $uploaderHelper
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Http/Api/Doctrine/NotificationQueryExtention.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
/**
* Filtre les notifications à renvoyer par l'API.
*/
final class NotificationQueryExtention implements QueryCollectionExtensionInterface
final readonly class NotificationQueryExtention implements QueryCollectionExtensionInterface
{
public function __construct(private readonly Security $security, private readonly NotificationService $notificationService)
public function __construct(private Security $security, private NotificationService $notificationService)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/Http/Api/Processor/NotificationProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
use App\Domain\Notification\Entity\Notification;
use Symfony\Bundle\SecurityBundle\Security;

final class NotificationProcessor implements ProcessorInterface
final readonly class NotificationProcessor implements ProcessorInterface
{
public function __construct(
private ProcessorInterface $persistProcessor,
private ProcessorInterface $removeProcessor,
private readonly Security $security
private Security $security
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Infrastructure/Captcha/CaptchaImageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
class CaptchaImageService
{

private string $holeImage;
private string $backgroundImage;
private string $noiseImage;
private readonly string $holeImage;
private readonly string $backgroundImage;
private readonly string $noiseImage;

public function __construct(
string $imagePath,
Expand Down
4 changes: 2 additions & 2 deletions src/Infrastructure/Captcha/CaptchaKeyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public function __construct(private readonly RequestStack $requestStack)

public function generateKey(): void
{
$x = rand(0, self::CAPTCHA_WIDTH - self::CAPTCHA_PIECE_WIDTH);
$y = rand(0, self::CAPTCHA_HEIGHT - self::CAPTCHA_PIECE_HEIGHT);
$x = random_int(0, self::CAPTCHA_WIDTH - self::CAPTCHA_PIECE_WIDTH);
$y = random_int(0, self::CAPTCHA_HEIGHT - self::CAPTCHA_PIECE_HEIGHT);
$session = $this->getSession();
$session->set(self::SESSION_KEY, [$x, $y]);
$session->set(self::SESSION_KEY_TRIES, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/Captcha/IsValidCaptchaValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function validate(mixed $value, Constraint $constraint): void
$this->setAsInvalid($constraint);
return;
}
} catch (TooManyTryException $e) {
} catch (TooManyTryException) {
$this->setAsInvalid($constraint);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/Orm/AbstractRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function hydrateRelation(array $items, string $propertyName): array
$setter = 'set'.ucfirst($propertyName);
$ids = array_map(fn ($item) => $item->$getter()->getId(), $items);
/** @var class-string $entityClass */
$entityClass = get_class($items[0]);
$entityClass = $items[0]::class;
$reflection = new \ReflectionClass($entityClass);
$relationType = $reflection->getProperty($propertyName)->getType();
if (!$relationType instanceof \ReflectionNamedType) {
Expand Down
10 changes: 2 additions & 8 deletions src/Infrastructure/Search/Meilisearch/MeilisearchClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@

class MeilisearchClient
{
private readonly string $apiKey;

public function __construct(
private readonly string $host,
string $apiKey,
private readonly HttpClientInterface $client
) {
$this->apiKey = $apiKey;
public function __construct(private readonly string $host, private readonly string $apiKey, private readonly HttpClientInterface $client)
{
}

public function get(string $endpoint): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MarkdownTransformer
public static function toText(string $content): string
{
$html = (new \Parsedown())->setSafeMode(false)->parse($content);
$html = preg_replace('@<pre>.*?</pre>@si', '', $html);
$html = preg_replace('@<pre>.*?</pre>@si', '', (string) $html);
if (!is_string($html)) {
return '';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/Spam/GeoIpService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getLocation(string $ip): ?GeoIpRecord
return new GeoIpRecord(
country: $record->country->isoCode,
);
} catch (AddressNotFoundException $e) {
} catch (AddressNotFoundException) {
return null;
}
}
Expand Down

0 comments on commit c222bc9

Please sign in to comment.