Skip to content

Commit 9695598

Browse files
committed
chore(api): rector to php84
1 parent 23125f8 commit 9695598

File tree

15 files changed

+39
-57
lines changed

15 files changed

+39
-57
lines changed

api/config/bootstrap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
// Load cached env vars if the .env.local.php file exists
1212
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
1313
if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) {
14-
(new Dotenv())->usePutenv(false)->populate($env);
14+
new Dotenv()->usePutenv(false)->populate($env);
1515
} else {
1616
// load all the .env files
17-
(new Dotenv())->usePutenv(false)->loadEnv(dirname(__DIR__).'/.env');
17+
new Dotenv()->usePutenv(false)->loadEnv(dirname(__DIR__).'/.env');
1818
}
1919

2020
$_SERVER += $_ENV;

api/rector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
->withComposerBased(doctrine: true, phpunit: true, symfony: true)
3838
->withPreparedSets(deadCode: true, codeQuality: true, privatization: true, rectorPreset: true, phpunitCodeQuality: true, symfonyCodeQuality: true)
3939
->withAttributesSets(all: true)
40-
->withPhpSets(php83: true)
40+
->withPhpSets(php84: true)
4141
->withConfiguredRule(RenameFunctionRector::class, [
4242
'implode' => 'join',
4343
'join' => 'join',

api/src/Doctrine/Orm/Extension/FilterEagerLoadingsExtension.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,11 @@ private function usesAnyToMany($toManyAliases, $wherePart) {
9898
}
9999

100100
private function usesAnyToManyAndx($toManyAliases, Andx $and) {
101-
foreach ($and->getParts() as $part) {
102-
if ($this->usesAnyToMany($toManyAliases, $part)) {
103-
return true;
104-
}
105-
}
106-
107-
return false;
101+
return array_any($and->getParts(), fn ($part) => $this->usesAnyToMany($toManyAliases, $part));
108102
}
109103

110104
private function usesAnyToManyOrx($toManyAliases, Orx $or) {
111-
foreach ($or->getParts() as $part) {
112-
if ($this->usesAnyToMany($toManyAliases, $part)) {
113-
return true;
114-
}
115-
}
116-
117-
return false;
105+
return array_any($or->getParts(), fn ($part) => $this->usesAnyToMany($toManyAliases, $part));
118106
}
119107

120108
private function usesAnyToManyComparison($toManyAliases, Comparison $comparison) {
@@ -124,13 +112,7 @@ private function usesAnyToManyComparison($toManyAliases, Comparison $comparison)
124112
}
125113

126114
private function usesAnyToManyFunc($toManyAliases, Func $func) {
127-
foreach ($func->getArguments() as $argument) {
128-
if ($this->usesAnyToMany($toManyAliases, $argument)) {
129-
return true;
130-
}
131-
}
132-
133-
return false;
115+
return array_any($func->getArguments(), fn ($argument) => $this->usesAnyToMany($toManyAliases, $argument));
134116
}
135117

136118
private function usesAnyToManyString($toManyAliases, string $comparison) {

api/src/Service/MailService.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(
2626
) {}
2727

2828
public function sendInviteToCampMail(User $byUser, Camp $camp, string $key, string $emailToInvite): void {
29-
$email = (new TemplatedEmail())
29+
$email = new TemplatedEmail()
3030
->from(new Address($this->senderEmail, $this->senderName))
3131
->to(new Address($emailToInvite))
3232
->subject($this->translator->trans('inviteToCamp.subject', ['campTitle' => $camp->title], self::TRANSLATE_DOMAIN, $byUser->profile->language))
@@ -48,7 +48,7 @@ public function sendInviteToCampMail(User $byUser, Camp $camp, string $key, stri
4848
}
4949

5050
public function sendUserActivationMail(User $user, string $key): void {
51-
$email = (new TemplatedEmail())
51+
$email = new TemplatedEmail()
5252
->from(new Address($this->senderEmail, $this->senderName))
5353
->to(new Address($user->getEmail()))
5454
->subject($this->translator->trans('userActivation.subject', [], self::TRANSLATE_DOMAIN, $user->profile->language))
@@ -68,7 +68,7 @@ public function sendUserActivationMail(User $user, string $key): void {
6868
}
6969

7070
public function sendPasswordResetLink(User $user, ResetPassword $data): void {
71-
$email = (new TemplatedEmail())
71+
$email = new TemplatedEmail()
7272
->from(new Address($this->senderEmail, $this->senderName))
7373
->to(new Address($user->getEmail()))
7474
->subject($this->translator->trans('passwordReset.subject', [], self::TRANSLATE_DOMAIN, $user->profile->language))
@@ -88,7 +88,7 @@ public function sendPasswordResetLink(User $user, ResetPassword $data): void {
8888
}
8989

9090
public function sendEmailVerificationMail(User $user, Profile $data): void {
91-
$email = (new TemplatedEmail())
91+
$email = new TemplatedEmail()
9292
->from(new Address($this->senderEmail, $this->senderName))
9393
->to(new Address($data->untrustedEmail))
9494
->subject($this->translator->trans('emailVerification.subject', [], self::TRANSLATE_DOMAIN, $user->profile->language))

api/src/Types/Doctrine/UTCDateTimeType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform)
4444
$value = $value->setTimeZone(self::getUtc());
4545

4646
if ($value instanceof \DateTimeImmutable) {
47-
return (new DateTimeImmutableType())->convertToDatabaseValue($value, $platform);
47+
return new DateTimeImmutableType()->convertToDatabaseValue($value, $platform);
4848
}
4949

5050
return parent::convertToDatabaseValue($value, $platform);

api/src/Types/Doctrine/UTCDateType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform)
2727
}
2828

2929
if ($value instanceof \DateTimeImmutable) {
30-
return (new DateImmutableType())->convertToDatabaseValue($value, $platform);
30+
return new DateImmutableType()->convertToDatabaseValue($value, $platform);
3131
}
3232

3333
return parent::convertToDatabaseValue($value, $platform);

api/src/Validator/AllowTransition/AssertAllowTransitionsValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function validate($value, Constraint $constraint): void {
2929
$allFrom = $transitions->map(fn (array $elem) => $elem['from'])->toArray();
3030
$allTo = $transitions->map(fn (array $elem) => $elem['to'])->toArray();
3131
$allTo = array_merge(...array_values($allTo));
32-
if (!(new ArrayCollection($allTo))->forAll(fn ($_, $to) => in_array($to, $allFrom, true))) {
32+
if (!new ArrayCollection($allTo)->forAll(fn ($_, $to) => in_array($to, $allFrom, true))) {
3333
throw new InvalidArgumentException('All to must appear in a from again');
3434
}
3535

api/src/Validator/Period/AssertNotOverlappingWithOtherPeriodsValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function validate(mixed $value, Constraint $constraint): void {
3434
return;
3535
}
3636
$periods = $camp->getPeriods();
37-
$overlappingExists = (new ArrayCollection($periods))
37+
$overlappingExists = new ArrayCollection($periods)
3838
->filter(fn (Period $p) => $p !== $object)
3939
->exists(fn ($_, Period $p) => self::overlaps($value, $p))
4040
;

api/tests/Entity/ScheduleEntryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function testGetDayReturnsNullIfDayEntityIsMissing() {
164164
}
165165

166166
protected function setCreateTime(ScheduleEntry $scheduleEntry, \DateTime $createTime) {
167-
$createTimeProperty = (new \ReflectionClass(ScheduleEntry::class))->getProperty('createTime');
167+
$createTimeProperty = new \ReflectionClass(ScheduleEntry::class)->getProperty('createTime');
168168
$createTimeProperty->setValue($scheduleEntry, $createTime);
169169
}
170170
}

api/tests/HttpCache/PurgeHttpCacheListenerTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ protected function setUp(): void {
102102
$this->propertyAccessorProphecy->getValue(Argument::type(Dummy::class), 'relatedOwningDummy')->willReturn(null);
103103

104104
$this->metadataFactoryProphecy = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class);
105-
$operation = (new GetCollection())->withShortName('Dummy')->withClass(Dummy::class);
106-
$operation2 = (new GetCollection())->withShortName('DummyAsSubresource')->withClass(Dummy::class);
105+
$operation = new GetCollection()->withShortName('Dummy')->withClass(Dummy::class);
106+
$operation2 = new GetCollection()->withShortName('DummyAsSubresource')->withClass(Dummy::class);
107107
$this->metadataFactoryProphecy->create(Dummy::class)->willReturn(new ResourceMetadataCollection('Dummy', [
108-
(new ApiResource('Dummy'))
108+
new ApiResource('Dummy')
109109
->withShortName('Dummy')
110110
->withOperations(new Operations([
111111
'get_collection' => $operation,
@@ -143,16 +143,16 @@ public function testOnFlush(): void {
143143
$cacheManagerProphecy->flush()->willReturn(0);
144144

145145
$metadataFactoryProphecy = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class);
146-
$operation = (new GetCollection())->withShortName('Dummy')->withClass(Dummy::class);
146+
$operation = new GetCollection()->withShortName('Dummy')->withClass(Dummy::class);
147147
$metadataFactoryProphecy->create(Dummy::class)->willReturn(new ResourceMetadataCollection('Dummy', [
148-
(new ApiResource('Dummy'))
148+
new ApiResource('Dummy')
149149
->withShortName('Dummy')
150150
->withOperations(new Operations([
151151
'get' => $operation,
152152
])),
153153
]))->shouldBeCalled();
154154
$metadataFactoryProphecy->create(DummyNoGetOperation::class)->willReturn(new ResourceMetadataCollection('DummyNoGetOperation', [
155-
(new ApiResource('DummyNoGetOperation'))
155+
new ApiResource('DummyNoGetOperation')
156156
->withShortName('DummyNoGetOperation'),
157157
]))->shouldBeCalled();
158158

@@ -345,7 +345,7 @@ public function testPropertyIsNotAResourceClass(): void {
345345

346346
$metadataFactoryProphecy = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class);
347347
$metadataFactoryProphecy->create(ContainNonResource::class)->willReturn(new ResourceMetadataCollection('ContainNonResource', [
348-
(new ApiResource('ContainNonResource'))
348+
new ApiResource('ContainNonResource')
349349
->withShortName('ContainNonResource'),
350350
]))->shouldBeCalled();
351351

0 commit comments

Comments
 (0)