Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doctrine/coding-standard #2269

Merged
merged 3 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"

steps:
- name: "Checkout"
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ jobs:
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

- name: "Prepare PHP 8 dependencies"
run: "composer remove --no-update --ignore-platform-req=php --dev doctrine/coding-standard squizlabs/php_codesniffer"
if: "${{ matrix.php-version == '8.0' }}"

- name: "Install dependencies with composer"
run: "composer update --no-interaction --no-progress"
if: "${{ matrix.deps == 'normal' }}"
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ jobs:
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

- name: "Prepare PHP 8 dependencies"
run: "composer remove --no-update --ignore-platform-req=php --dev doctrine/coding-standard squizlabs/php_codesniffer"

- name: "Install dependencies with composer"
run: "composer install --no-interaction --no-progress"

Expand Down Expand Up @@ -90,9 +87,6 @@ jobs:
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

- name: "Prepare PHP 8 dependencies"
run: "composer remove --no-update --ignore-platform-req=php --dev doctrine/coding-standard squizlabs/php_codesniffer"

- name: "Install dependencies with composer"
run: "composer install --no-interaction --no-progress"

Expand Down
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
},
"require-dev": {
"ext-bcmath": "*",
"doctrine/coding-standard": "^6.0",
"doctrine/coding-standard": "^8.2",
"jmikola/geojson": "^1.0",
"phpbench/phpbench": "^1.0.0-alpha3",
"phpstan/phpstan": "^0.12.32",
"phpunit/phpunit": "^8.5 || ^9",
"squizlabs/php_codesniffer": "^3.5, <3.5.5",
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "^4.2.1"
},
"suggest": {
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