Skip to content

Commit

Permalink
Merge branch '4.6.x' into 4.5.x-merge-up-into-4.6.x_9JgLVdSd
Browse files Browse the repository at this point in the history
* 4.6.x:
  Drop support of unmaintained versions of Symfony (#771)
  Fix CS (#772)
  Use PHP 7.4 for phpcs (#768)
  Use PHPUnit 9 methods
  Add property types
  Use PHP 7.4 syntax
  Wire the EntityArgumentResolver
  Add missing void types
  Allow doctrine/annotations 2
  Update to psalm 5
  Drop support of PHP < 7.4
  • Loading branch information
alcaeus committed Jul 20, 2023
2 parents 78849b4 + ba28758 commit 017ca26
Show file tree
Hide file tree
Showing 80 changed files with 413 additions and 582 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,29 @@ jobs:
os:
- "ubuntu-20.04"
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
stability:
- "stable"
symfony-version:
- "4.4.x"
- "5.4.x"
- "6.0.x"
- "6.2.x"
driver-version:
- "stable"
dependencies:
- "highest"
include:
- dependencies: "lowest"
os: "ubuntu-20.04"
php-version: "7.2"
php-version: "7.4"
driver-version: "1.5.0"
stability: "stable"
symfony-version: "4.4.*"
symfony-version: "5.4.*"
exclude:
- php-version: "7.2"
symfony-version: "6.0.x"
- php-version: "7.3"
symfony-version: "6.0.x"
- php-version: "7.4"
symfony-version: "6.0.x"
symfony-version: "6.2.x"

services:
mongodb:
Expand Down
2 changes: 1 addition & 1 deletion APM/CommandLoggerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
final class CommandLoggerRegistry
{
/** @var CommandLoggerInterface[] */
private $commandLoggers = [];
private array $commandLoggers = [];

public function __construct(iterable $commandLoggers)
{
Expand Down
9 changes: 3 additions & 6 deletions APM/PSRCommandLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@

final class PSRCommandLogger implements CommandLoggerInterface
{
/** @var bool */
private $registered = false;
private bool $registered = false;

/** @var LoggerInterface|null */
private $logger;
private ?LoggerInterface $logger;

/** @var string */
private $prefix;
private string $prefix;

public function __construct(?LoggerInterface $logger, string $prefix = 'MongoDB command: ')
{
Expand Down
6 changes: 2 additions & 4 deletions APM/StopwatchCommandLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

final class StopwatchCommandLogger implements CommandLoggerInterface
{
/** @var bool */
private $registered = false;
private bool $registered = false;

/** @var Stopwatch|null */
private $stopwatch;
private ?Stopwatch $stopwatch;

public function __construct(?Stopwatch $stopwatch)
{
Expand Down
11 changes: 3 additions & 8 deletions CacheWarmer/HydratorCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
*/
class HydratorCacheWarmer implements CacheWarmerInterface
{
/** @var ContainerInterface */
private $container;
private ContainerInterface $container;

public function __construct(ContainerInterface $container)
{
Expand All @@ -49,12 +48,8 @@ public function isOptional()
return false;
}

/**
* @param string $cacheDir
*
* @return string[]
*/
public function warmUp($cacheDir)
/** @return string[] */
public function warmUp(string $cacheDir)
{
// we need the directory no matter the hydrator cache generation strategy.
$hydratorCacheDir = (string) $this->container->getParameter('doctrine_mongodb.odm.hydrator_dir');
Expand Down
13 changes: 3 additions & 10 deletions CacheWarmer/PersistentCollectionCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Doctrine\ODM\MongoDB\Configuration;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use Doctrine\Persistence\ManagerRegistry;
use RuntimeException;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand All @@ -33,8 +32,7 @@
*/
class PersistentCollectionCacheWarmer implements CacheWarmerInterface
{
/** @var ContainerInterface */
private $container;
private ContainerInterface $container;

public function __construct(ContainerInterface $container)
{
Expand All @@ -51,12 +49,8 @@ public function isOptional()
return false;
}

/**
* @param string $cacheDir
*
* @return string[]
*/
public function warmUp($cacheDir)
/** @return string[] */
public function warmUp(string $cacheDir)
{
// we need the directory no matter the hydrator cache generation strategy.
$collCacheDir = (string) $this->container->getParameter('doctrine_mongodb.odm.persistent_collection_dir');
Expand All @@ -81,7 +75,6 @@ public function warmUp($cacheDir)
$collectionGenerator = $dm->getConfiguration()->getPersistentCollectionGenerator();
$classes = $dm->getMetadataFactory()->getAllMetadata();
foreach ($classes as $metadata) {
assert($metadata instanceof ClassMetadata);
foreach ($metadata->getAssociationNames() as $fieldName) {
$mapping = $metadata->getFieldMapping($fieldName);
if (empty($mapping['collectionClass']) || in_array($mapping['collectionClass'], $generated)) {
Expand Down
15 changes: 4 additions & 11 deletions CacheWarmer/ProxyCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
*/
class ProxyCacheWarmer implements CacheWarmerInterface
{
/** @var ContainerInterface */
private $container;
private ContainerInterface $container;

public function __construct(ContainerInterface $container)
{
Expand All @@ -51,12 +50,8 @@ public function isOptional()
return false;
}

/**
* @param string $cacheDir
*
* @return string[]
*/
public function warmUp($cacheDir)
/** @return string[] */
public function warmUp(string $cacheDir)
{
// we need the directory no matter the proxy cache generation strategy.
$proxyCacheDir = (string) $this->container->getParameter('doctrine_mongodb.odm.proxy_dir');
Expand Down Expand Up @@ -86,8 +81,6 @@ public function warmUp($cacheDir)
/** @return ClassMetadata[] */
private function getClassesForProxyGeneration(DocumentManager $dm)
{
return array_filter($dm->getMetadataFactory()->getAllMetadata(), static function (ClassMetadata $metadata) {
return ! $metadata->isEmbeddedDocument && ! $metadata->isMappedSuperclass;
});
return array_filter($dm->getMetadataFactory()->getAllMetadata(), static fn (ClassMetadata $metadata) => ! $metadata->isEmbeddedDocument && ! $metadata->isMappedSuperclass);
}
}
1 change: 1 addition & 0 deletions Command/ClearMetadataCacheDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
class ClearMetadataCacheDoctrineODMCommand extends MetadataCommand
{
/** @return void */
protected function configure()
{
parent::configure();
Expand Down
1 change: 1 addition & 0 deletions Command/CreateSchemaDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
class CreateSchemaDoctrineODMCommand extends CreateCommand
{
/** @return void */
protected function configure()
{
parent::configure();
Expand Down
3 changes: 1 addition & 2 deletions Command/DoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ abstract class DoctrineODMCommand extends Command
/** @var ContainerInterface|null */
protected $container;

/** @var ManagerRegistry|null */
private $managerRegistry;
private ?ManagerRegistry $managerRegistry;

public function __construct(?ManagerRegistry $registry = null)
{
Expand Down
1 change: 1 addition & 0 deletions Command/DropSchemaDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
class DropSchemaDoctrineODMCommand extends DropCommand
{
/** @return void */
protected function configure()
{
parent::configure();
Expand Down
1 change: 1 addition & 0 deletions Command/GenerateHydratorsDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
class GenerateHydratorsDoctrineODMCommand extends GenerateHydratorsCommand
{
/** @return void */
protected function configure()
{
parent::configure();
Expand Down
1 change: 1 addition & 0 deletions Command/GenerateProxiesDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
class GenerateProxiesDoctrineODMCommand extends GenerateProxiesCommand
{
/** @return void */
protected function configure()
{
parent::configure();
Expand Down
5 changes: 2 additions & 3 deletions Command/InfoDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
class InfoDoctrineODMCommand extends DoctrineODMCommand
{
/** @return void */
protected function configure()
{
$this
Expand All @@ -42,9 +43,7 @@ protected function configure()
/** @return int */
protected function execute(InputInterface $input, OutputInterface $output)
{
$documentManagerName = $input->getOption('dm') ?
$input->getOption('dm') :
$this->getManagerRegistry()->getDefaultManagerName();
$documentManagerName = $input->hasOption('dm') ? $input->getOption('dm') : $this->getManagerRegistry()->getDefaultManagerName();

$documentManager = $this->getManagerRegistry()->getManager($documentManagerName);
assert($documentManager instanceof DocumentManager);
Expand Down
4 changes: 2 additions & 2 deletions Command/LoadDataFixturesDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
*/
class LoadDataFixturesDoctrineODMCommand extends DoctrineODMCommand
{
/** @var SymfonyFixturesLoaderInterface */
private $fixturesLoader;
private ?SymfonyFixturesLoaderInterface $fixturesLoader;

public function __construct(?ManagerRegistry $registry = null, ?KernelInterface $kernel = null, ?SymfonyFixturesLoaderInterface $fixturesLoader = null)
{
Expand All @@ -43,6 +42,7 @@ public function isEnabled()
return parent::isEnabled() && class_exists(Loader::class);
}

/** @return void */
protected function configure()
{
$this
Expand Down
1 change: 1 addition & 0 deletions Command/QueryDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
class QueryDoctrineODMCommand extends QueryCommand
{
/** @return void */
protected function configure()
{
parent::configure();
Expand Down
1 change: 1 addition & 0 deletions Command/ShardDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
class ShardDoctrineODMCommand extends ShardCommand
{
/** @return void */
protected function configure()
{
parent::configure();
Expand Down
1 change: 1 addition & 0 deletions Command/TailCursorDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class TailCursorDoctrineODMCommand extends Command implements ContainerAwareInte
{
use ContainerAwareTrait;

/** @return void */
protected function configure()
{
$this
Expand Down
1 change: 1 addition & 0 deletions Command/UpdateSchemaDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
class UpdateSchemaDoctrineODMCommand extends UpdateCommand
{
/** @return void */
protected function configure()
{
parent::configure();
Expand Down
11 changes: 4 additions & 7 deletions DataCollector/CommandDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

class CommandDataCollector extends DataCollector
{
/** @var CommandLogger */
private $commandLogger;
private CommandLogger $commandLogger;

public function __construct(CommandLogger $commandLogger)
{
Expand All @@ -43,14 +42,12 @@ static function (Command $command): array {
'durationMicros' => $command->getDurationMicros(),
];
},
$this->commandLogger->getAll()
$this->commandLogger->getAll(),
),
'time' => array_reduce(
$this->commandLogger->getAll(),
static function (int $total, Command $command): int {
return $total + $command->getDurationMicros();
},
0
static fn (int $total, Command $command): int => $total + $command->getDurationMicros(),
0,
),
];
}
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Compiler/CacheCompatibilityPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private function createCompatibilityLayerDefinition(ContainerBuilder $container,
'doctrine/mongodb-odm-bundle',
'4.4',
'Configuring doctrine/cache is deprecated. Please update the cache service "%s" to use a PSR-6 cache.',
$definitionId
$definitionId,
);
}

Expand All @@ -90,7 +90,7 @@ private function wrapIfNecessary(ContainerBuilder $container, ?string $aliasId,
return;
}

$aliasId = $aliasId ?? $definitionId;
$aliasId ??= $definitionId;

$compatibilityLayerId = $definitionId . '.compatibility_layer';
$container->setDefinition($compatibilityLayerId, $compatibilityLayer);
Expand Down
5 changes: 3 additions & 2 deletions DependencyInjection/Compiler/CreateHydratorDirectoryPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

class CreateHydratorDirectoryPass implements CompilerPassInterface
{
/** @return void */
public function process(ContainerBuilder $container)
{
if (! $container->hasParameter('doctrine_mongodb.odm.hydrator_dir')) {
Expand All @@ -32,12 +33,12 @@ public function process(ContainerBuilder $container)
if (! is_dir($hydratorCacheDir)) {
if (@mkdir($hydratorCacheDir, 0775, true) === false && ! is_dir($hydratorCacheDir)) {
throw new RuntimeException(
sprintf('Unable to create the Doctrine Hydrator directory (%s)', dirname($hydratorCacheDir))
sprintf('Unable to create the Doctrine Hydrator directory (%s)', dirname($hydratorCacheDir)),
);
}
} elseif (! is_writable($hydratorCacheDir)) {
throw new RuntimeException(
sprintf('Unable to write in the Doctrine Hydrator directory (%s)', $hydratorCacheDir)
sprintf('Unable to write in the Doctrine Hydrator directory (%s)', $hydratorCacheDir),
);
}
}
Expand Down
5 changes: 3 additions & 2 deletions DependencyInjection/Compiler/CreateProxyDirectoryPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

class CreateProxyDirectoryPass implements CompilerPassInterface
{
/** @return void */
public function process(ContainerBuilder $container)
{
if (! $container->hasParameter('doctrine_mongodb.odm.proxy_dir')) {
Expand All @@ -32,12 +33,12 @@ public function process(ContainerBuilder $container)
if (! is_dir($proxyCacheDir)) {
if (@mkdir($proxyCacheDir, 0775, true) === false && ! is_dir($proxyCacheDir)) {
throw new RuntimeException(
sprintf('Unable to create the Doctrine Proxy directory (%s)', dirname($proxyCacheDir))
sprintf('Unable to create the Doctrine Proxy directory (%s)', dirname($proxyCacheDir)),
);
}
} elseif (! is_writable($proxyCacheDir)) {
throw new RuntimeException(
sprintf('Unable to write in the Doctrine Proxy directory (%s)', $proxyCacheDir)
sprintf('Unable to write in the Doctrine Proxy directory (%s)', $proxyCacheDir),
);
}
}
Expand Down
Loading

0 comments on commit 017ca26

Please sign in to comment.