Skip to content

Commit

Permalink
Fix coding standard violations
Browse files Browse the repository at this point in the history
  • Loading branch information
malarzm committed Jan 11, 2021
1 parent 9d7ef1e commit af0c87c
Show file tree
Hide file tree
Showing 296 changed files with 2,292 additions and 1,749 deletions.
1 change: 1 addition & 0 deletions benchmark/BaseBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use MongoDB\Client;
use MongoDB\Model\DatabaseInfo;
use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods;

use function array_map;
use function getenv;
use function in_array;
Expand Down
1 change: 1 addition & 0 deletions benchmark/Document/LoadDocumentBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use MongoDB\BSON\ObjectId;
use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods;
use PhpBench\Benchmark\Metadata\Annotations\Warmup;

use function assert;

/**
Expand Down
20 changes: 10 additions & 10 deletions lib/Doctrine/ODM/MongoDB/APM/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private function __construct()
{
}

public static function createForSucceededCommand(CommandStartedEvent $startedEvent, CommandSucceededEvent $succeededEvent) : self
public static function createForSucceededCommand(CommandStartedEvent $startedEvent, CommandSucceededEvent $succeededEvent): self
{
self::checkRequestIds($startedEvent, $succeededEvent);

Expand All @@ -34,7 +34,7 @@ public static function createForSucceededCommand(CommandStartedEvent $startedEve
return $instance;
}

public static function createForFailedCommand(CommandStartedEvent $startedEvent, CommandFailedEvent $failedEvent) : self
public static function createForFailedCommand(CommandStartedEvent $startedEvent, CommandFailedEvent $failedEvent): self
{
self::checkRequestIds($startedEvent, $failedEvent);

Expand All @@ -48,44 +48,44 @@ public static function createForFailedCommand(CommandStartedEvent $startedEvent,
/**
* @param CommandSucceededEvent|CommandFailedEvent $finishedEvent
*/
private static function checkRequestIds(CommandStartedEvent $startedEvent, $finishedEvent) : void
private static function checkRequestIds(CommandStartedEvent $startedEvent, $finishedEvent): void
{
if ($startedEvent->getRequestId() !== $finishedEvent->getRequestId()) {
throw new LogicException('Cannot create APM command for events with different request IDs');
}
}

public function getCommandName() : string
public function getCommandName(): string
{
return $this->startedEvent->getCommandName();
}

public function getCommand() : object
public function getCommand(): object
{
return $this->startedEvent->getCommand();
}

public function getDurationMicros() : int
public function getDurationMicros(): int
{
return $this->finishedEvent->getDurationMicros();
}

public function getRequestId() : string
public function getRequestId(): string
{
return $this->startedEvent->getRequestId();
}

public function getServer() : Server
public function getServer(): Server
{
return $this->finishedEvent->getServer();
}

public function getReply() : object
public function getReply(): object
{
return $this->finishedEvent->getReply();
}

public function getError() : ?Throwable
public function getError(): ?Throwable
{
return $this->finishedEvent instanceof CommandFailedEvent ? $this->finishedEvent->getError() : null;
}
Expand Down
15 changes: 8 additions & 7 deletions lib/Doctrine/ODM/MongoDB/APM/CommandLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use MongoDB\Driver\Monitoring\CommandFailedEvent;
use MongoDB\Driver\Monitoring\CommandStartedEvent;
use MongoDB\Driver\Monitoring\CommandSucceededEvent;

use function count;
use function MongoDB\Driver\Monitoring\addSubscriber;
use function MongoDB\Driver\Monitoring\removeSubscriber;
Expand All @@ -23,7 +24,7 @@ final class CommandLogger implements Countable, CommandLoggerInterface
/** @var bool */
private $registered = false;

public function register() : void
public function register(): void
{
if ($this->registered) {
return;
Expand All @@ -33,7 +34,7 @@ public function register() : void
addSubscriber($this);
}

public function unregister() : void
public function unregister(): void
{
if (! $this->registered) {
return;
Expand Down Expand Up @@ -68,33 +69,33 @@ public function commandFailed(CommandFailedEvent $event)
$this->logCommand(Command::createForFailedCommand($commandStartedEvent, $event));
}

public function clear() : void
public function clear(): void
{
$this->commands = [];
}

public function count() : int
public function count(): int
{
return count($this->commands);
}

/**
* @return Command[]
*/
public function getAll() : array
public function getAll(): array
{
return $this->commands;
}

private function findAndRemoveCommandStartedEvent(string $requestId) : ?CommandStartedEvent
private function findAndRemoveCommandStartedEvent(string $requestId): ?CommandStartedEvent
{
$startedEvent = $this->startedCommands[$requestId] ?? null;
unset($this->startedCommands[$requestId]);

return $startedEvent;
}

private function logCommand(Command $command) : void
private function logCommand(Command $command): void
{
$this->commands[] = $command;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/MongoDB/APM/CommandLoggerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ interface CommandLoggerInterface extends CommandSubscriber
/**
* Registers this command logger instance with the MongoDB library so it can receive command events
*/
public function register() : void;
public function register(): void;

/**
* Unregisters this command logger instance with the MongoDB library so it no longer receives command events
*/
public function unregister() : void;
public function unregister(): void;
}
5 changes: 3 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Aggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use IteratorAggregate;
use MongoDB\Collection;
use MongoDB\Driver\Cursor;

use function array_merge;
use function assert;

Expand Down Expand Up @@ -46,7 +47,7 @@ public function __construct(DocumentManager $dm, ?ClassMetadata $classMetadata,
$this->rewindable = $rewindable;
}

public function getIterator() : Iterator
public function getIterator(): Iterator
{
// Force cursor to be used
$options = array_merge($this->options, ['cursor' => true]);
Expand All @@ -57,7 +58,7 @@ public function getIterator() : Iterator
return $this->prepareIterator($cursor);
}

private function prepareIterator(Cursor $cursor) : Iterator
private function prepareIterator(Cursor $cursor): Iterator
{
if ($this->classMetadata) {
$cursor = new HydratingIterator($cursor, $this->dm->getUnitOfWork(), $this->classMetadata);
Expand Down
Loading

0 comments on commit af0c87c

Please sign in to comment.