Skip to content

Commit

Permalink
fix(rector): Update with rector to PHP 7.2
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Sep 18, 2024
1 parent c6c3a55 commit 448479c
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/Model/AttachmentMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function deleteByRoomId(int $roomId): void {
$query->delete($this->getTableName())
->where($query->expr()->eq('room_id', $query->createNamedParameter($roomId, IQueryBuilder::PARAM_INT)));

$this->atomic(static function () use ($query) {
$this->atomic(static function () use ($query): void {
$query->executeStatement();
}, $this->db);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/BotService.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,15 @@ protected function sendAsyncRequest(BotServer $botServer, array $body, ?string $
$client = $this->clientService->newClient();
$promise = $client->postAsync($botServer->getUrl(), $data);

$promise->then(function (IResponse $response) use ($botServer) {
$promise->then(function (IResponse $response) use ($botServer): void {
if ($response->getStatusCode() !== Http::STATUS_OK && $response->getStatusCode() !== Http::STATUS_ACCEPTED) {
$this->logger->error('Bot responded with unexpected status code (Received: ' . $response->getStatusCode() . '), increasing error count');
$botServer->setErrorCount($botServer->getErrorCount() + 1);
$botServer->setLastErrorDate($this->timeFactory->now());
$botServer->setLastErrorMessage('UnexpectedStatusCode: ' . $response->getStatusCode());
$this->botServerMapper->update($botServer);
}
}, function (\Exception $exception) use ($botServer) {
}, function (\Exception $exception) use ($botServer): void {
$this->logger->error('Bot error occurred, increasing error count', ['exception' => $exception]);
$botServer->setErrorCount($botServer->getErrorCount() + 1);
$botServer->setLastErrorDate($this->timeFactory->now());
Expand Down
8 changes: 4 additions & 4 deletions lib/Signaling/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function deleteMessages(array $sessionIds): void {
->where($delete->expr()->in('recipient', $delete->createNamedParameter($sessionIds, IQueryBuilder::PARAM_STR_ARRAY)))
->orWhere($delete->expr()->in('sender', $delete->createNamedParameter($sessionIds, IQueryBuilder::PARAM_STR_ARRAY)));

$this->atomic(function () use ($delete) {
$this->atomic(function () use ($delete): void {
$delete->executeStatement();
}, $this->db);
}
Expand Down Expand Up @@ -76,7 +76,7 @@ public function addMessageForAllParticipants(Room $room, string $message): void
);

$participants = $this->participantService->getParticipantsForAllSessions($room);
$this->atomic(function () use ($participants, $insert) {
$this->atomic(function () use ($participants, $insert): void {
foreach ($participants as $participant) {
$session = $participant->getSession();
if ($session instanceof Session) {
Expand Down Expand Up @@ -115,7 +115,7 @@ public function getAndDeleteMessages(string $sessionId): array {
->where($delete->expr()->eq('recipient', $delete->createNamedParameter($sessionId)))
->andWhere($delete->expr()->lte('timestamp', $delete->createNamedParameter($time)));

$this->atomic(function () use (&$messages, $query, $delete) {
$this->atomic(function () use (&$messages, $query, $delete): void {
$result = $query->executeQuery();

while ($row = $result->fetch()) {
Expand All @@ -141,7 +141,7 @@ public function expireOlderThan(int $olderThan): void {
$delete->delete('talk_internalsignaling')
->where($delete->expr()->lt('timestamp', $delete->createNamedParameter($time)));

$this->atomic(function () use ($delete) {
$this->atomic(function () use ($delete): void {
$delete->executeStatement();
}, $this->db);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/php/BackgroundJob/CheckHostedSignalingServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function testRunWithPendingToActiveChange(): void {
$i = 0;
$this->config->expects($this->exactly(count($expectedCalls)))
->method('setAppValue')
->willReturnCallback(function () use ($expectedCalls, &$i) {
->willReturnCallback(function () use ($expectedCalls, &$i): void {
Assert::assertArrayHasKey($i, $expectedCalls);
Assert::assertSame($expectedCalls[$i], func_get_args());
$i++;
Expand Down
10 changes: 5 additions & 5 deletions tests/php/Chat/AutoComplete/SearchPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected function createParticipantMock(string $uid, string $displayName, strin
$p = $this->createMock(Participant::class);
$a = Attendee::fromRow([
'actor_type' => $uid ? 'users' : 'guests',
'actor_id' => $uid ? $uid : sha1($session),
'actor_id' => $uid ?: sha1($session),
'display_name' => $displayName,
]);
$s = Session::fromRow([
Expand Down Expand Up @@ -133,16 +133,16 @@ public function testSearch(): void {
$plugin->expects($this->once())
->method('searchUsers')
->with('fo', ['123' => 'OneTwoThree', 'foo' => 'Foo Bar', 'bar' => 'Bar Tender'], $result)
->willReturnCallback(function ($search, $users, $result) {
array_map(function ($user) {
->willReturnCallback(function ($search, $users, $result): void {
array_map(function ($user): void {
$this->assertIsString($user);
}, $users);
});
$plugin->expects($this->once())
->method('searchGuests')
->with('fo', $this->anything(), $result)
->willReturnCallback(function ($search, $guests, $result) {
array_map(function ($guest) {
->willReturnCallback(function ($search, $guests, $result): void {
array_map(function ($guest): void {
$this->assertInstanceOf(Attendee::class, $guest);
}, $guests);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Chat/NotifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public function testGetMentionedUsers(string $message, array $expectedReturn): v
public static function dataGetMentionedUserIds(): array {
$return = self::dataGetMentionedUsers();
array_walk($return, function (array &$scenario) {
array_walk($scenario[1], function (array &$params) {
array_walk($scenario[1], function (array &$params): void {
$params = $params['id'];
});
return $scenario;
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Chat/SystemMessage/ListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function setUp(): void {
$this->handlers = [];

$this->eventDispatcher->method('addListener')
->will($this->returnCallback(function ($eventName, $handler) {
->will($this->returnCallback(function ($eventName, $handler): void {
$this->handlers[$eventName] ??= [];
$this->handlers[$eventName][] = $handler;
}));
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Controller/ChatControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public function testSendReplyByUser(): void {
];
$this->messageParser->expects($this->exactly(2))
->method('parseMessage')
->willReturnCallback(function () use ($expectedCalls, &$i) {
->willReturnCallback(function () use ($expectedCalls, &$i): void {
Assert::assertArrayHasKey($i, $expectedCalls);
Assert::assertSame($expectedCalls[$i], func_get_args());
$i++;
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Controller/SignalingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ public function testBackendRoomAnonymousOneToOne(): void {
}

public function testBackendRoomSessionFromEvent(): void {
$this->dispatcher->addListener(BeforeSignalingResponseSentEvent::class, static function (BeforeSignalingResponseSentEvent $event) {
$this->dispatcher->addListener(BeforeSignalingResponseSentEvent::class, static function (BeforeSignalingResponseSentEvent $event): void {
$room = $event->getRoom();
$event->setSession([
'foo' => 'bar',
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Service/RoomServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public function testVerifyPassword(): void {
\OC::$server,
$this->createMock(LoggerInterface::class)
);
$dispatcher->addListener(RoomPasswordVerifyEvent::class, static function (RoomPasswordVerifyEvent $event) {
$dispatcher->addListener(RoomPasswordVerifyEvent::class, static function (RoomPasswordVerifyEvent $event): void {
$password = $event->getPassword();

if ($password === '1234') {
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Settings/Admin/AdminSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function testInitStunServers(): void {
];
$this->initialState->expects($this->exactly(2))
->method('provideInitialState')
->willReturnCallback(function () use ($expectedCalls, &$i) {
->willReturnCallback(function () use ($expectedCalls, &$i): void {
Assert::assertArrayHasKey($i, $expectedCalls);
Assert::assertSame($expectedCalls[$i], func_get_args());
$i++;
Expand Down
2 changes: 1 addition & 1 deletion tests/php/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
require_once __DIR__.'/../../../../lib/base.php';
\OC::$loader->addValidRoot(\OC::$SERVERROOT . '/tests');
\OC_App::loadApp('spreed');
if (!class_exists('\PHPUnit\Framework\TestCase')) {
if (!class_exists(\PHPUnit\Framework\TestCase::class)) {
require_once('PHPUnit/Autoload.php');
}
\OC_Hook::clear();

0 comments on commit 448479c

Please sign in to comment.