Skip to content

Commit

Permalink
Upgrade to doctrine/coding-standard 10
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Oct 30, 2022
1 parent f5c1679 commit 428dbb3
Show file tree
Hide file tree
Showing 81 changed files with 274 additions and 647 deletions.
4 changes: 1 addition & 3 deletions benchmark/BaseBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
use function in_array;
use function iterator_to_array;

/**
* @BeforeMethods({"initDocumentManager", "clearDatabase"})
*/
/** @BeforeMethods({"initDocumentManager", "clearDatabase"}) */
abstract class BaseBench
{
public const DATABASE_NAME = 'doctrine_odm_performance';
Expand Down
24 changes: 6 additions & 18 deletions benchmark/Document/HydrateDocumentBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods;
use PhpBench\Benchmark\Metadata\Annotations\Warmup;

/**
* @BeforeMethods({"init"}, extend=true)
*/
/** @BeforeMethods({"init"}, extend=true) */
final class HydrateDocumentBench extends BaseBench
{
/** @var array */
Expand Down Expand Up @@ -80,41 +78,31 @@ public function init(): void
->getHydratorFor(User::class);
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchHydrateDocument(): void
{
self::$hydrator->hydrate(new User(), self::$data);
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchHydrateDocumentWithEmbedOne(): void
{
self::$hydrator->hydrate(new User(), self::$data + self::$embedOneData);
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchHydrateDocumentWithEmbedMany(): void
{
self::$hydrator->hydrate(new User(), self::$data + self::$embedManyData);
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchHydrateDocumentWithReferenceOne(): void
{
self::$hydrator->hydrate(new User(), self::$data + self::$referenceOneData);
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchHydrateDocumentWithReferenceMany(): void
{
self::$hydrator->hydrate(new User(), self::$data + self::$referenceManyData);
Expand Down
28 changes: 7 additions & 21 deletions benchmark/Document/LoadDocumentBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

use function assert;

/**
* @BeforeMethods({"init"}, extend=true)
*/
/** @BeforeMethods({"init"}, extend=true) */
final class LoadDocumentBench extends BaseBench
{
/** @var ObjectId */
Expand Down Expand Up @@ -55,53 +53,41 @@ public function init(): void
$this->getDocumentManager()->clear();
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchLoadDocument(): void
{
$this->loadDocument();
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchLoadEmbedOne(): void
{
$this->loadDocument()->getAddress()->getCity();
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchLoadEmbedMany(): void
{
$this->loadDocument()->getPhonenumbers()->forAll(static function (int $key, Phonenumber $element) {
return $element->getPhoneNumber() !== null;
});
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchLoadReferenceOne(): void
{
$this->loadDocument()->getAccount()->getName();
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchLoadReferenceMany(): void
{
$this->loadDocument()->getGroups()->forAll(static function (int $key, Group $group) {
return $group->getName() !== null;
});
}

/**
* @return User
*/
/** @return User */
private function loadDocument()
{
$document = $this->getDocumentManager()->find(User::class, self::$userId);
Expand Down
20 changes: 5 additions & 15 deletions benchmark/Document/StoreDocumentBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

final class StoreDocumentBench extends BaseBench
{
/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchStoreDocument(): void
{
$user = new User();
Expand All @@ -29,9 +27,7 @@ public function benchStoreDocument(): void
$this->getDocumentManager()->clear();
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchStoreDocumentWithEmbedOne(): void
{
$address = new Address();
Expand All @@ -48,9 +44,7 @@ public function benchStoreDocumentWithEmbedOne(): void
$this->getDocumentManager()->clear();
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchStoreDocumentWithEmbedMany(): void
{
$user = new User();
Expand All @@ -64,9 +58,7 @@ public function benchStoreDocumentWithEmbedMany(): void
$this->getDocumentManager()->clear();
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchStoreDocumentWithReferenceOne(): void
{
$account = new Account();
Expand All @@ -82,9 +74,7 @@ public function benchStoreDocumentWithReferenceOne(): void
$this->getDocumentManager()->clear();
}

/**
* @Warmup(2)
*/
/** @Warmup(2) */
public function benchStoreDocumentWithReferenceMany(): void
{
$group1 = new Group('One');
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"require-dev": {
"ext-bcmath": "*",
"doctrine/coding-standard": "^9.0",
"doctrine/coding-standard": "^9.0 || ^10.0",
"jmikola/geojson": "^1.0",
"phpbench/phpbench": "^1.0.0",
"phpstan/phpstan": "^1.4.6",
Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/ODM/MongoDB/APM/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ public static function createForFailedCommand(CommandStartedEvent $startedEvent,
return $instance;
}

/**
* @param CommandSucceededEvent|CommandFailedEvent $finishedEvent
*/
/** @param CommandSucceededEvent|CommandFailedEvent $finishedEvent */
private static function checkRequestIds(CommandStartedEvent $startedEvent, $finishedEvent): void
{
if ($startedEvent->getRequestId() !== $finishedEvent->getRequestId()) {
Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/ODM/MongoDB/APM/CommandLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ public function count(): int
return count($this->commands);
}

/**
* @return Command[]
*/
/** @return Command[] */
public function getAll(): array
{
return $this->commands;
Expand Down
8 changes: 2 additions & 6 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,7 @@ public function floor($number): self
return $this->operator('$floor', $number);
}

/**
* @return array<string, mixed>
*/
/** @return array<string, mixed> */
public function getExpression(): array
{
return $this->expr;
Expand Down Expand Up @@ -1608,9 +1606,7 @@ private function requiresCurrentField(?string $method = null): void
}
}

/**
* @throws BadMethodCallException If there is no current switch operator.
*/
/** @throws BadMethodCallException If there is no current switch operator. */
private function requiresSwitchStatement(?string $method = null): void
{
$message = ($method ?: 'This method') . ' requires a valid switch statement (call switch() first).';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ public function getExpression(): array
return $stage;
}

/**
* @return mixed[]
*/
/** @return mixed[] */
abstract protected function getExtraPipelineFields(): array;

/**
Expand Down
8 changes: 2 additions & 6 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

use function assert;

/**
* @method Bucket groupBy($expression)
*/
/** @method Bucket groupBy($expression) */
class Bucket extends AbstractBucket
{
/** @var mixed[] */
Expand Down Expand Up @@ -65,9 +63,7 @@ public function output(): Bucket\BucketOutput
return $this->output;
}

/**
* @return array{boundaries: mixed[], default: mixed}
*/
/** @return array{boundaries: mixed[], default: mixed} */
protected function getExtraPipelineFields(): array
{
$fields = ['boundaries' => $this->boundaries];
Expand Down
8 changes: 2 additions & 6 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/BucketAuto.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

use function assert;

/**
* @method BucketAuto groupBy($expression)
*/
/** @method BucketAuto groupBy($expression) */
class BucketAuto extends AbstractBucket
{
/** @var int */
Expand Down Expand Up @@ -56,9 +54,7 @@ public function output(): Bucket\BucketAutoOutput
return $this->output;
}

/**
* @return array{buckets: int, granularity?: string}
*/
/** @return array{buckets: int, granularity?: string} */
protected function getExtraPipelineFields(): array
{
$fields = ['buckets' => $this->buckets];
Expand Down
12 changes: 3 additions & 9 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
use function is_string;
use function substr;

/**
* @psalm-import-type FieldMapping from ClassMetadata
*/
/** @psalm-import-type FieldMapping from ClassMetadata */
class GraphLookup extends Stage
{
/** @var string|null */
Expand Down Expand Up @@ -242,9 +240,7 @@ public function startWith($expression): self
return $this;
}

/**
* @throws MappingException
*/
/** @throws MappingException */
private function fromReference(string $fieldName): self
{
if (! $this->class->hasReference($fieldName)) {
Expand Down Expand Up @@ -311,9 +307,7 @@ private function getDocumentPersister(ClassMetadata $class): DocumentPersister
return $this->dm->getUnitOfWork()->getDocumentPersister($class->name);
}

/**
* @psalm-param FieldMapping $mapping
*/
/** @psalm-param FieldMapping $mapping */
private function getReferencedFieldName(string $fieldName, array $mapping): string
{
if (! $this->targetClass) {
Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ protected function prepareFieldName(string $fieldName, ?ClassMetadata $class = n
return $this->getDocumentPersister($class)->prepareFieldName($fieldName);
}

/**
* @throws MappingException
*/
/** @throws MappingException */
private function fromReference(string $fieldName): self
{
if (! $this->class->hasReference($fieldName)) {
Expand Down
12 changes: 3 additions & 9 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/MatchStage.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public function __construct(Builder $builder)
$this->query = $this->expr();
}

/**
* @see http://php.net/manual/en/language.oop5.cloning.php
*/
/** @see http://php.net/manual/en/language.oop5.cloning.php */
public function __clone()
{
$this->query = clone $this->query;
Expand Down Expand Up @@ -368,9 +366,7 @@ public function in(array $values): self
return $this;
}

/**
* @return static
*/
/** @return static */
public function includesReferenceTo(object $document): self
{
$this->query->includesReferenceTo($document);
Expand Down Expand Up @@ -521,9 +517,7 @@ public function range($start, $end): self
return $this;
}

/**
* @return static
*/
/** @return static */
public function references(object $document): self
{
$this->query->references($document);
Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public function __construct(Builder $builder)
$this->expr = $builder->expr();
}

/**
* @param mixed[] $args
*/
/** @param mixed[] $args */
public function __call(string $method, array $args): self
{
$this->expr->$method(...$args);
Expand Down
Loading

0 comments on commit 428dbb3

Please sign in to comment.