Skip to content

Commit

Permalink
Bump php cs fixer tool (#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
qdequippe authored Nov 21, 2024
1 parent 2e0d7a2 commit 6f23062
Show file tree
Hide file tree
Showing 42 changed files with 985 additions and 274 deletions.
30 changes: 15 additions & 15 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@
->withPhpSets(php83: true)
->withImportNames(importShortClasses: false, removeUnusedImports: true)
->withSkip([
LiteralGetToRequestClassConstantRector::class,
ClosureToArrowFunctionRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
SimplifyBoolIdenticalTrueRector::class,
ClassPropertyAssignToConstructorPromotionRector::class => [
__DIR__.'/src/Entity',
],
FirstClassCallableRector::class => [
__DIR__.'/config',
],
CallableThisArrayToAnonymousFunctionRector::class => [
__DIR__.'/config',
],
AddOverrideAttributeToOverriddenMethodsRector::class,
]
LiteralGetToRequestClassConstantRector::class,
ClosureToArrowFunctionRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
SimplifyBoolIdenticalTrueRector::class,
ClassPropertyAssignToConstructorPromotionRector::class => [
__DIR__.'/src/Entity',
],
FirstClassCallableRector::class => [
__DIR__.'/config',
],
CallableThisArrayToAnonymousFunctionRector::class => [
__DIR__.'/config',
],
AddOverrideAttributeToOverriddenMethodsRector::class,
]
)
->withSkipPath(__DIR__.'/config/bundles.php');
2 changes: 1 addition & 1 deletion src/Broadcast/Twitter/JobPostedTweet.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function toTweet(): Tweet
return '#'.$tag;
}, $this->job->getTags());

$text = sprintf(
$text = \sprintf(
"💻 %s\n🎸 %s\n📍 %s\n👉 %s\n\n%s",
$this->job->getTitle(),
$this->job->getOrganization(),
Expand Down
6 changes: 3 additions & 3 deletions src/Broadcast/Twitter/TwitterApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public function __construct(
private string $accessToken,
#[Autowire('%env(TWITTER_ACCESS_TOKEN_SECRET)%')]
private string $tokenSecret,
private HttpClientInterface $httpClient
private HttpClientInterface $httpClient,
) {
}

public function createTweet(Tweet $tweet): string
{
$method = 'POST';
$payload = $tweet->toArray();
$url = sprintf('%s/tweets', self::BASE_URL);
$url = \sprintf('%s/tweets', self::BASE_URL);
$authorizationHeader = $this->buildAuthorizationHeader(method: $method, url: $url);

$response = $this->httpClient->request($method, $url, [
Expand Down Expand Up @@ -97,7 +97,7 @@ private function buildAuthorizationHeader(string $method, string $url): string
public function deleteTweet(string $tweetId): bool
{
$method = 'DELETE';
$url = sprintf('%s/tweets/%s', self::BASE_URL, $tweetId);
$url = \sprintf('%s/tweets/%s', self::BASE_URL, $tweetId);
$authorizationHeader = $this->buildAuthorizationHeader(method: $method, url: $url);

$response = $this->httpClient->request($method, $url, [
Expand Down
4 changes: 2 additions & 2 deletions src/Command/AggregateCommunityEventCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class AggregateCommunityEventCommand extends Command
{
public function __construct(
private readonly EventSourceRepository $sourceRepository,
private readonly MessageBusInterface $bus
private readonly MessageBusInterface $bus,
) {
parent::__construct();
}
Expand All @@ -34,7 +34,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

foreach ($sources as $source) {
$this->bus->dispatch(new FetchSourceCommand($source->getId()));
$io->info(sprintf('Source "%s" fetching scheduled...', $source->getUrl()));
$io->info(\sprintf('Source "%s" fetching scheduled...', $source->getUrl()));
}

return Command::SUCCESS;
Expand Down
4 changes: 2 additions & 2 deletions src/Command/AggregateNewsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class AggregateNewsCommand extends Command
{
public function __construct(
private readonly FeedRepository $feedRepository,
private readonly MessageBusInterface $bus
private readonly MessageBusInterface $bus,
) {
parent::__construct();
}
Expand All @@ -35,7 +35,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
foreach ($feeds as $feed) {
$this->bus->dispatch(new FetchFeedCommand($feed->getId()->toString()));

$io->info(sprintf('Feed "%s" fetching scheduled...', $feed->getName()));
$io->info(\sprintf('Feed "%s" fetching scheduled...', $feed->getName()));
}

return Command::SUCCESS;
Expand Down
4 changes: 2 additions & 2 deletions src/Command/SendWeeklyJobsLetterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(
#[Autowire('%env(COMMAND_ROUTER_HOST)%')]
private readonly string $commandRouterHost,
#[Autowire('%env(COMMAND_ROUTER_SCHEME)%')]
private readonly string $commandRouterScheme
private readonly string $commandRouterScheme,
) {
parent::__construct();
}
Expand All @@ -64,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$context->setScheme($this->commandRouterScheme);

$response = $this->mailjetApi->createCampaignDraft(new CreateCampaignDraftRequest(
sprintf('[%s] Weekly jobs letter', (new \DateTime())->format('W')),
\sprintf('[%s] Weekly jobs letter', (new \DateTime())->format('W')),
$this->mailjetContactListId,
'en_US',
'[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion src/CommunityEvent/EventRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function findPastEvents(): array;
/**
* @return Event[]
*/
public function findUpcomingEvents(int $limit = null): array;
public function findUpcomingEvents(?int $limit = null): array;

public function remove(Event $event): void;
}
4 changes: 2 additions & 2 deletions src/CommunityEvent/FetchSourceCommandHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __invoke(FetchSourceCommand $command): void
$event->setName(html_entity_decode((string) $eventData['name']));
$event->setUrl($eventData['url']);
if (isset($eventData['description'])) {
$event->setAbstract(sprintf(
$event->setAbstract(\sprintf(
'%s...',
mb_substr(html_entity_decode((string) $eventData['description']), 0, 200))
);
Expand Down Expand Up @@ -86,7 +86,7 @@ public function __invoke(FetchSourceCommand $command): void
}
} catch (\Throwable $throwable) {
$this->logger->notice(
sprintf('Unable to fetch events from source "%s". Reason: %s', $source->getUrl(), $throwable->getMessage()),
\sprintf('Unable to fetch events from source "%s". Reason: %s', $source->getUrl(), $throwable->getMessage()),
[
'sourceId' => $source->getId(),
]
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class AssetsController extends AbstractController
public function __construct(
private readonly Server $glide,
#[Autowire('%env(GLIDE_KEY)%')]
private readonly string $secret
private readonly string $secret,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/JobController.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function subscribe(
Request $request,
SubscribeMailingListCommandHandler $handler,
#[Autowire('%env(MAILJET_CONTACT_LIST_ID)%')]
int $mailjetListId
int $mailjetListId,
): Response {
$form = $this->createForm(SubscriptionType::class);
$form->handleRequest($request);
Expand Down
6 changes: 3 additions & 3 deletions src/DataFixtures/AppFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ private function loadNews(ObjectManager $manager): void
$feedRSS->setType(FeedType::RSS);

$manager->persist($feedRSS);
$this->addReference(sprintf('feed-%s', self::FEED_RSS_ID), $feedRSS);
$this->addReference(\sprintf('feed-%s', self::FEED_RSS_ID), $feedRSS);

$feedAtom = new Feed(Uuid::fromString(self::FEED_ATOM_ID));
$feedAtom->setName('Atom Feed');
$feedAtom->setUrl('https://localhost/atom');
$feedAtom->setType(FeedType::ATOM);

$manager->persist($feedAtom);
$this->addReference(sprintf('feed-%s', self::FEED_ATOM_ID), $feedAtom);
$this->addReference(\sprintf('feed-%s', self::FEED_ATOM_ID), $feedAtom);

/**
* @var string|null $id
Expand All @@ -129,7 +129,7 @@ private function loadNews(ObjectManager $manager): void
*/
foreach ($this->getNewsData() as [$id, $title, $link, $description, $publishedAt, $feedId]) {
/** @var Feed $feed */
$feed = $this->getReference(sprintf('feed-%s', $feedId));
$feed = $this->getReference(\sprintf('feed-%s', $feedId));

$article = new Entry($id ? Uuid::fromString($id) : null);
$article->setFeed($feed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
public function __construct(
private JobRepository $jobRepository,
private CreatePaymentUrlInterface $createPaymentUrl
private CreatePaymentUrlInterface $createPaymentUrl,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/CommunityEvent/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Event
#[ApiProperty(types: ['https://schema.org/eventAttendanceMode'])]
private ?AttendanceMode $attendanceMode = null;

public function __construct(UuidInterface $id = null)
public function __construct(?UuidInterface $id = null)
{
if (null === $id) {
$id = Uuid::uuid4();
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/CommunityEvent/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class Source
private string $url = '';

public function __construct(
UuidInterface $id = null,
?UuidInterface $id = null,
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
public readonly \DateTimeImmutable $createdAt = new \DateTimeImmutable()
public readonly \DateTimeImmutable $createdAt = new \DateTimeImmutable(),
) {
if (null === $id) {
$id = Uuid::uuid4();
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function __construct(
EmploymentType $employmentType,
string $organization,
string $url,
UuidInterface $id = null
?UuidInterface $id = null,
) {
if (null === $id) {
$id = Uuid::uuid4();
Expand Down Expand Up @@ -273,7 +273,7 @@ public function setTweetId(?string $tweetId): void
$this->tweetId = $tweetId;
}

public function publish(\DateTimeImmutable $publishedAt = null): void
public function publish(?\DateTimeImmutable $publishedAt = null): void
{
if (null === $publishedAt) {
$publishedAt = new \DateTimeImmutable();
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/News/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Entry
#[ORM\JoinColumn(onDelete: 'SET NULL')]
private ?Feed $feed = null;

public function __construct(UuidInterface $id = null)
public function __construct(?UuidInterface $id = null)
{
if (null === $id) {
$id = Uuid::uuid4();
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/News/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Feed implements \Stringable
)]
private ?UploadedFile $imageFile = null;

public function __construct(UuidInterface $id = null)
public function __construct(?UuidInterface $id = null)
{
if (null === $id) {
$id = Uuid::uuid4();
Expand Down
4 changes: 2 additions & 2 deletions src/Form/PostJobOfferType.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'label' => 'form.label.employment_type',
'class' => EmploymentType::class,
'choice_label' => static function (EmploymentType $employmentType): string {
return sprintf('employment_type.%s', $employmentType->value);
return \sprintf('employment_type.%s', $employmentType->value);
},
])
->add('organization', TextType::class, [
Expand Down Expand Up @@ -75,7 +75,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'label' => false,
'class' => LocationType::class,
'choice_label' => static function (LocationType $locationType): string {
return sprintf('location_type.%s', $locationType->value);
return \sprintf('location_type.%s', $locationType->value);
},
])
;
Expand Down
4 changes: 2 additions & 2 deletions src/Job/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private function __construct(private string $token, private int $expiresIn, priv
public static function create(
string $token,
int $expiresIn,
\DateTimeImmutable $createAt = new \DateTimeImmutable()
\DateTimeImmutable $createAt = new \DateTimeImmutable(),
): self {
return new self($token, $expiresIn, $createAt);
}
Expand All @@ -27,6 +27,6 @@ public function getToken(): string

public function hasExpired(): bool
{
return new \DateTimeImmutable() > $this->createdAt->add(new \DateInterval(sprintf('PT%sS', $this->expiresIn)));
return new \DateTimeImmutable() > $this->createdAt->add(new \DateInterval(\sprintf('PT%sS', $this->expiresIn)));
}
}
2 changes: 1 addition & 1 deletion src/Job/Bridge/OpenAI/CreateJobPromptForClassification.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ final class CreateJobPromptForClassification
{
public static function create(Job $job): string
{
return sprintf('Extract maximum 5 tech keywords separated by comma from this text: %s', $job->getDescription());
return \sprintf('Extract maximum 5 tech keywords separated by comma from this text: %s', $job->getDescription());
}
}
2 changes: 1 addition & 1 deletion src/Job/EventSubscriber/NotifyNewJobOfferSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function onJobPosted(JobPostedEvent $event): void
return;
}

$jobTitleText = sprintf("New job offer posted:\n*%s*", $job->getTitle());
$jobTitleText = \sprintf("New job offer posted:\n*%s*", $job->getTitle());
$jobTitleSection = (new SlackSectionBlock())
->text($jobTitleText);

Expand Down
2 changes: 1 addition & 1 deletion src/Job/JobProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public function __construct(
#[TaggedIterator(JobProviderInterface::class, exclude: self::class)]
private iterable $providers
private iterable $providers,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Job/PoleEmploi/PoleEmploiApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function search(array $queryParams = []): array
$minCreationDateQueryUrl = $minCreationDate->format('Y-m-d\TH:i:s\Z');
}

$url .= sprintf(
$url .= \sprintf(
'?minCreationDate=%s&maxCreationDate=%s',
$minCreationDateQueryUrl,
$maxCreationDateQueryUrl
Expand Down
2 changes: 1 addition & 1 deletion src/Job/PoleEmploi/PoleEmploiJobProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public function __construct(
private PoleEmploiApi $api,
#[Autowire('%env(POLE_EMPLOI_CLIENT_ID)%')]
private string $poleEmploiClientId
private string $poleEmploiClientId,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Job/WelcometotheJungle/WelcometotheJungleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private function getLocation(array $data): string
continue;
}

$locations[] = sprintf(
$locations[] = \sprintf(
'%s, %s',
html_entity_decode((string) $jobLocation['address']['addressLocality']),
ucfirst(Countries::getName($jobLocation['address']['addressCountry'])),
Expand All @@ -79,7 +79,7 @@ private function getLocation(array $data): string
}

if ('Place' === $data['jobLocation']['@type']) {
return sprintf(
return \sprintf(
'%s, %s',
html_entity_decode((string) $data['jobLocation']['address']['addressLocality']),
ucfirst(Countries::getName($data['jobLocation']['address']['addressCountry'])),
Expand Down
Loading

0 comments on commit 6f23062

Please sign in to comment.