Apply new rector rules regarding to PHP version to 8.4

This commit is contained in:
2025-11-03 13:36:51 +01:00
parent d6f5ef4bb1
commit cdc489f01e
1086 changed files with 2219 additions and 1378 deletions

View File

@@ -41,9 +41,9 @@ class NotificationMailerTest extends TestCase
public function testPostPersistComment(): void
{
$user1 = (new User())->setEmail('user1@foo.com');
$user2 = (new User())->setEmail('user2@foo.com');
$user3 = (new User())->setEmail('user3@foo.com');
$user1 = new User()->setEmail('user1@foo.com');
$user2 = new User()->setEmail('user2@foo.com');
$user3 = new User()->setEmail('user3@foo.com');
$notification = new Notification();
$notification
@@ -53,7 +53,7 @@ class NotificationMailerTest extends TestCase
->addAddressee($user3)
;
$comment = (new NotificationComment())
$comment = new NotificationComment()
->setContent('foo bar baz')
->setCreatedBy($user2)
;
@@ -63,13 +63,7 @@ class NotificationMailerTest extends TestCase
// a mail only to user1 and user3 should have been sent
$mailer->send(Argument::that(function (Email $email) {
foreach ($email->getTo() as $address) {
if ('user1@foo.com' === $address->getAddress() || 'user3@foo.com' === $address->getAddress()) {
return true;
}
}
return false;
return array_any($email->getTo(), fn($address) => 'user1@foo.com' === $address->getAddress() || 'user3@foo.com' === $address->getAddress());
}))->shouldBeCalledTimes(2);
$objectManager = $this->prophesize(EntityManagerInterface::class);
@@ -80,9 +74,9 @@ class NotificationMailerTest extends TestCase
public function testPostPersistCommentDestWithNullEmail(): void
{
$user1 = (new User())->setEmail('user1@foo.com');
$user2 = (new User())->setEmail('user2@foo.com');
$user3 = (new User())->setEmail(null);
$user1 = new User()->setEmail('user1@foo.com');
$user2 = new User()->setEmail('user2@foo.com');
$user3 = new User()->setEmail(null);
$notification = new Notification();
$notification
@@ -92,7 +86,7 @@ class NotificationMailerTest extends TestCase
->addAddressee($user3)
;
$comment = (new NotificationComment())
$comment = new NotificationComment()
->setContent('foo bar baz')
->setCreatedBy($user2)
;
@@ -102,13 +96,7 @@ class NotificationMailerTest extends TestCase
// a mail only to user1 and user3 should have been sent
$mailer->send(Argument::that(function (Email $email) {
foreach ($email->getTo() as $address) {
if ('user1@foo.com' === $address->getAddress()) {
return true;
}
}
return false;
return array_any($email->getTo(), fn($address) => 'user1@foo.com' === $address->getAddress());
}))->shouldBeCalledTimes(1);
$objectManager = $this->prophesize(EntityManagerInterface::class);
@@ -130,7 +118,6 @@ class NotificationMailerTest extends TestCase
// Use reflection to set the ID since it's normally generated by the database
$reflectionNotification = new \ReflectionClass(Notification::class);
$idProperty = $reflectionNotification->getProperty('id');
$idProperty->setAccessible(true);
$idProperty->setValue($notification, 123);
// Create a real user entity
@@ -140,7 +127,6 @@ class NotificationMailerTest extends TestCase
// Use reflection to set the ID since it's normally generated by the database
$reflectionUser = new \ReflectionClass(User::class);
$idProperty = $reflectionUser->getProperty('id');
$idProperty->setAccessible(true);
$idProperty->setValue($user, 456);
// Set notification flags for the user
@@ -158,7 +144,6 @@ class NotificationMailerTest extends TestCase
// Call the method that processes notifications
$reflection = new \ReflectionClass(NotificationMailer::class);
$method = $reflection->getMethod('processNotificationForAddressee');
$method->setAccessible(true);
$method->invoke($mailer, $notification, $user);
}