Skip to content

Commit f3ed76b

Browse files
authored
Merge pull request #1860 from alcaeus/doctrine-cs-5.0
Update to Doctrine CS 5.0
2 parents bce26f3 + 9116af7 commit f3ed76b

File tree

358 files changed

+4336
-4005
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

358 files changed

+4336
-4005
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"phpunit/phpunit": "^7.0",
3737
"jmikola/geojson": "^1.0",
3838
"phpstan/phpstan": "^0.10.3",
39-
"doctrine/coding-standard": "^4.0"
39+
"doctrine/coding-standard": "^5.0"
4040
},
4141
"autoload": {
4242
"psr-4": { "Doctrine\\ODM\\MongoDB\\": "lib/Doctrine/ODM/MongoDB" }

lib/Doctrine/ODM/MongoDB/APM/Command.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use MongoDB\Driver\Monitoring\CommandStartedEvent;
1010
use MongoDB\Driver\Monitoring\CommandSucceededEvent;
1111
use MongoDB\Driver\Server;
12+
use Throwable;
1213

1314
final class Command
1415
{
@@ -22,23 +23,23 @@ private function __construct()
2223
{
2324
}
2425

25-
public static function createForSucceededCommand(CommandStartedEvent $startedEvent, CommandSucceededEvent $succeededEvent): self
26+
public static function createForSucceededCommand(CommandStartedEvent $startedEvent, CommandSucceededEvent $succeededEvent) : self
2627
{
2728
self::checkRequestIds($startedEvent, $succeededEvent);
2829

29-
$instance = new self();
30-
$instance->startedEvent = $startedEvent;
30+
$instance = new self();
31+
$instance->startedEvent = $startedEvent;
3132
$instance->finishedEvent = $succeededEvent;
3233

3334
return $instance;
3435
}
3536

36-
public static function createForFailedCommand(CommandStartedEvent $startedEvent, CommandFailedEvent $failedEvent): self
37+
public static function createForFailedCommand(CommandStartedEvent $startedEvent, CommandFailedEvent $failedEvent) : self
3738
{
3839
self::checkRequestIds($startedEvent, $failedEvent);
3940

40-
$instance = new self();
41-
$instance->startedEvent = $startedEvent;
41+
$instance = new self();
42+
$instance->startedEvent = $startedEvent;
4243
$instance->finishedEvent = $failedEvent;
4344

4445
return $instance;
@@ -47,44 +48,44 @@ public static function createForFailedCommand(CommandStartedEvent $startedEvent,
4748
/**
4849
* @param CommandSucceededEvent|CommandFailedEvent $finishedEvent
4950
*/
50-
private static function checkRequestIds(CommandStartedEvent $startedEvent, $finishedEvent): void
51+
private static function checkRequestIds(CommandStartedEvent $startedEvent, $finishedEvent) : void
5152
{
5253
if ($startedEvent->getRequestId() !== $finishedEvent->getRequestId()) {
5354
throw new LogicException('Cannot create APM command for events with different request IDs');
5455
}
5556
}
5657

57-
public function getCommandName(): string
58+
public function getCommandName() : string
5859
{
5960
return $this->startedEvent->getCommandName();
6061
}
6162

62-
public function getCommand(): object
63+
public function getCommand() : object
6364
{
6465
return $this->startedEvent->getCommand();
6566
}
6667

67-
public function getDurationMicros(): int
68+
public function getDurationMicros() : int
6869
{
6970
return $this->finishedEvent->getDurationMicros();
7071
}
7172

72-
public function getRequestId(): string
73+
public function getRequestId() : string
7374
{
7475
return $this->startedEvent->getRequestId();
7576
}
7677

77-
public function getServer(): Server
78+
public function getServer() : Server
7879
{
7980
return $this->finishedEvent->getServer();
8081
}
8182

82-
public function getReply(): object
83+
public function getReply() : object
8384
{
8485
return $this->finishedEvent->getReply();
8586
}
8687

87-
public function getError(): ?\Throwable
88+
public function getError() : ?Throwable
8889
{
8990
return $this->finishedEvent instanceof CommandFailedEvent ? $this->finishedEvent->getError() : null;
9091
}

lib/Doctrine/ODM/MongoDB/APM/CommandLogger.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class CommandLogger implements Countable, CommandSubscriber
2424
/** @var bool */
2525
private $registered = false;
2626

27-
public function register(): void
27+
public function register() : void
2828
{
2929
if ($this->registered) {
3030
return;
@@ -34,7 +34,7 @@ public function register(): void
3434
addSubscriber($this);
3535
}
3636

37-
public function unregister(): void
37+
public function unregister() : void
3838
{
3939
if (! $this->registered) {
4040
return;
@@ -69,33 +69,33 @@ public function commandFailed(CommandFailedEvent $event)
6969
$this->logCommand(Command::createForFailedCommand($commandStartedEvent, $event));
7070
}
7171

72-
public function clear(): void
72+
public function clear() : void
7373
{
7474
$this->commands = [];
7575
}
7676

77-
public function count(): int
77+
public function count() : int
7878
{
7979
return count($this->commands);
8080
}
8181

8282
/**
8383
* @return Command[]
8484
*/
85-
public function getAll(): array
85+
public function getAll() : array
8686
{
8787
return $this->commands;
8888
}
8989

90-
private function findAndRemoveCommandStartedEvent(string $requestId): ?CommandStartedEvent
90+
private function findAndRemoveCommandStartedEvent(string $requestId) : ?CommandStartedEvent
9191
{
9292
$startedEvent = $this->startedCommands[$requestId] ?? null;
9393
unset($this->startedCommands[$requestId]);
9494

9595
return $startedEvent;
9696
}
9797

98-
private function logCommand(Command $command): void
98+
private function logCommand(Command $command) : void
9999
{
100100
$this->commands[] = $command;
101101
}

0 commit comments

Comments
 (0)