diff --git a/lib/Doctrine/ODM/MongoDB/APM/Command.php b/lib/Doctrine/ODM/MongoDB/APM/Command.php index 2f23eca505..20552995da 100644 --- a/lib/Doctrine/ODM/MongoDB/APM/Command.php +++ b/lib/Doctrine/ODM/MongoDB/APM/Command.php @@ -13,8 +13,7 @@ final class Command { - /** @var CommandStartedEvent */ - private $startedEvent; + private CommandStartedEvent $startedEvent; /** @var CommandSucceededEvent|CommandFailedEvent */ private $finishedEvent; diff --git a/lib/Doctrine/ODM/MongoDB/APM/CommandLogger.php b/lib/Doctrine/ODM/MongoDB/APM/CommandLogger.php index 3994f05039..7278f65bbd 100644 --- a/lib/Doctrine/ODM/MongoDB/APM/CommandLogger.php +++ b/lib/Doctrine/ODM/MongoDB/APM/CommandLogger.php @@ -16,13 +16,12 @@ final class CommandLogger implements Countable, CommandLoggerInterface { /** @var Command[] */ - private $commands = []; + private array $commands = []; /** @var CommandStartedEvent[] */ - private $startedCommands = []; + private array $startedCommands = []; - /** @var bool */ - private $registered = false; + private bool $registered = false; public function register(): void { diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Aggregation.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Aggregation.php index 9cf3ec8f61..655de73d29 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Aggregation.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Aggregation.php @@ -19,23 +19,19 @@ final class Aggregation implements IteratorAggregate { - /** @var DocumentManager */ - private $dm; + private DocumentManager $dm; - /** @var ClassMetadata|null */ - private $classMetadata; + private ?ClassMetadata $classMetadata; - /** @var Collection */ - private $collection; + private Collection $collection; /** @var array */ - private $pipeline; + private array $pipeline; /** @var array */ - private $options; + private array $options; - /** @var bool */ - private $rewindable; + private bool $rewindable; /** * @param array $pipeline diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php index e71d94ef27..3496f370c4 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php @@ -34,36 +34,26 @@ class Builder { /** * The DocumentManager instance for this query - * - * @var DocumentManager */ - private $dm; + private DocumentManager $dm; /** * The ClassMetadata instance. - * - * @var ClassMetadata */ - private $class; + private ClassMetadata $class; - /** - * @var string - * @psalm-var class-string - */ - private $hydrationClass; + /** @psalm-var class-string */ + private ?string $hydrationClass = null; /** * The Collection instance. - * - * @var Collection */ - private $collection; + private Collection $collection; /** @var Stage[] */ - private $stages = []; + private array $stages = []; - /** @var bool */ - private $rewindable = true; + private bool $rewindable = true; /** * Create a new aggregation builder. diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php index 8677a24bc6..50cebef908 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Expr.php @@ -25,24 +25,20 @@ */ class Expr { - /** @var DocumentManager */ - private $dm; + private DocumentManager $dm; - /** @var ClassMetadata */ - private $class; + private ClassMetadata $class; /** @var array */ - private $expr = []; + private array $expr = []; /** * The current field we are operating on. - * - * @var string */ - private $currentField; + private ?string $currentField = null; /** @var array{case: mixed|self, then?: mixed|self}|null */ - private $switchBranch; + private ?array $switchBranch = null; public function __construct(DocumentManager $dm, ClassMetadataInterface $class) { diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/AbstractBucket.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/AbstractBucket.php index 22ebf2923d..74c516ad7d 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/AbstractBucket.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/AbstractBucket.php @@ -24,11 +24,9 @@ */ abstract class AbstractBucket extends Stage { - /** @var DocumentManager */ - private $dm; + private DocumentManager $dm; - /** @var ClassMetadata */ - private $class; + private ClassMetadata $class; /** @var Bucket\AbstractOutput|null */ protected $output; diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket.php index 0472b5064f..475a820604 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket.php @@ -12,7 +12,7 @@ class Bucket extends AbstractBucket { /** @var mixed[] */ - private $boundaries; + private ?array $boundaries = null; /** @var mixed */ private $default; diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/AbstractOutput.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/AbstractOutput.php index f751c60ab8..89cde5600b 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/AbstractOutput.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/AbstractOutput.php @@ -18,8 +18,7 @@ abstract class AbstractOutput extends Stage /** @var Stage\AbstractBucket */ protected $bucket; - /** @var Expr */ - private $expr; + private Expr $expr; public function __construct(Builder $builder, Stage\AbstractBucket $bucket) { diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/BucketAuto.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/BucketAuto.php index 106eb54d0d..482f8094e8 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/BucketAuto.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/BucketAuto.php @@ -11,11 +11,9 @@ */ class BucketAuto extends AbstractBucket { - /** @var int */ - private $buckets; + private ?int $buckets = null; - /** @var string|null */ - private $granularity; + private ?string $granularity = null; /** * A positive 32-bit integer that specifies the number of buckets into which diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/CollStats.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/CollStats.php index e4dee55e02..9d787b6429 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/CollStats.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/CollStats.php @@ -16,11 +16,9 @@ class CollStats extends Stage public const LATENCY_STATS_SIMPLE = 1; public const LATENCY_STATS_HISTOGRAMS = 2; - /** @var int */ - private $latencyStats = self::LATENCY_STATS_NONE; + private int $latencyStats = self::LATENCY_STATS_NONE; - /** @var bool */ - private $storageStats = false; + private bool $storageStats = false; public function __construct(Builder $builder) { diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Count.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Count.php index 10ed0bea69..647833e373 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Count.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Count.php @@ -12,8 +12,7 @@ */ class Count extends Stage { - /** @var string */ - private $fieldName; + private string $fieldName; public function __construct(Builder $builder, string $fieldName) { diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Facet.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Facet.php index a998db6c7d..2cb3e1390a 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Facet.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Facet.php @@ -17,10 +17,9 @@ class Facet extends Stage { /** @var Builder[] */ - private $pipelines = []; + private array $pipelines = []; - /** @var string */ - private $field; + private ?string $field = null; public function getExpression(): array { diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GeoNear.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GeoNear.php index 2752e5b203..c2d4959afb 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GeoNear.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GeoNear.php @@ -14,32 +14,24 @@ */ class GeoNear extends MatchStage { - /** @var string */ - private $distanceField; + private ?string $distanceField = null; - /** @var float */ - private $distanceMultiplier; + private ?float $distanceMultiplier = null; - /** @var string */ - private $includeLocs; + private ?string $includeLocs = null; - /** @var float */ - private $maxDistance; + private ?float $maxDistance = null; - /** @var float */ - private $minDistance; + private ?float $minDistance = null; /** @var array|array{int|float, int|float} */ private $near; - /** @var int */ - private $num; + private ?int $num = null; - /** @var bool */ - private $spherical = false; + private bool $spherical = false; - /** @var bool */ - private $uniqueDocs; + private ?bool $uniqueDocs = null; /** * @param float|array|Point $x diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php index e19577a5dd..2c46c50e30 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php @@ -25,38 +25,28 @@ */ class GraphLookup extends Stage { - /** @var string|null */ - private $from; + private ?string $from; /** @var string|Expr|mixed[]|null */ private $startWith; - /** @var string|null */ - private $connectFromField; + private ?string $connectFromField = null; - /** @var string|null */ - private $connectToField; + private ?string $connectToField = null; - /** @var string|null */ - private $as; + private ?string $as = null; - /** @var int|null */ - private $maxDepth; + private ?int $maxDepth = null; - /** @var string|null */ - private $depthField; + private ?string $depthField = null; - /** @var Stage\GraphLookup\MatchStage */ - private $restrictSearchWithMatch; + private Stage\GraphLookup\MatchStage $restrictSearchWithMatch; - /** @var DocumentManager */ - private $dm; + private DocumentManager $dm; - /** @var ClassMetadata */ - private $class; + private ClassMetadata $class; - /** @var ClassMetadata|null */ - private $targetClass; + private ?ClassMetadata $targetClass = null; /** * @param string $from Target collection for the $graphLookup operation to diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup/MatchStage.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup/MatchStage.php index 0edfa96245..dbd6194061 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup/MatchStage.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup/MatchStage.php @@ -11,8 +11,7 @@ class MatchStage extends BaseMatchStage { - /** @var GraphLookup */ - private $graphLookup; + private GraphLookup $graphLookup; public function __construct(Builder $builder, GraphLookup $graphLookup) { diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Limit.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Limit.php index 4a2408dc1b..ec2aa15596 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Limit.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Limit.php @@ -12,8 +12,7 @@ */ class Limit extends Stage { - /** @var int */ - private $limit; + private int $limit; public function __construct(Builder $builder, int $limit) { diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php index 170881083c..48144783f6 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php @@ -17,26 +17,19 @@ */ class Lookup extends Stage { - /** @var DocumentManager */ - private $dm; + private DocumentManager $dm; - /** @var ClassMetadata */ - private $class; + private ClassMetadata $class; - /** @var ClassMetadata */ - private $targetClass; + private ?ClassMetadata $targetClass = null; - /** @var string */ - private $from; + private string $from; - /** @var string */ - private $localField; + private ?string $localField = null; - /** @var string */ - private $foreignField; + private ?string $foreignField = null; - /** @var string */ - private $as; + private ?string $as = null; /** @var array */ private $let; diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Out.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Out.php index 9d9f7b610b..dbf62a0492 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Out.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Out.php @@ -13,11 +13,9 @@ class Out extends Stage { - /** @var DocumentManager */ - private $dm; + private DocumentManager $dm; - /** @var string */ - private $collection; + private ?string $collection = null; public function __construct(Builder $builder, string $collection, DocumentManager $documentManager) { diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/ReplaceRoot.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/ReplaceRoot.php index a5058fcb7c..661eafcfc2 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/ReplaceRoot.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/ReplaceRoot.php @@ -18,11 +18,9 @@ class ReplaceRoot extends Operator { - /** @var DocumentManager */ - private $dm; + private DocumentManager $dm; - /** @var ClassMetadata */ - private $class; + private ClassMetadata $class; /** @var string|mixed[]|Expr|null */ private $expression; diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Sample.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Sample.php index ce077eee35..a60bc0b514 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Sample.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Sample.php @@ -12,8 +12,7 @@ */ class Sample extends Stage { - /** @var int */ - private $size; + private int $size; public function __construct(Builder $builder, int $size) { diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Skip.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Skip.php index 4f00efd045..062072dd44 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Skip.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Skip.php @@ -12,8 +12,7 @@ */ class Skip extends Stage { - /** @var int */ - private $skip; + private int $skip; public function __construct(Builder $builder, int $skip) { diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Sort.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Sort.php index ec4d282154..2531be5580 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Sort.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Sort.php @@ -21,7 +21,7 @@ class Sort extends Stage { /** @var array */ - private $sort = []; + private array $sort = []; /** * @param array>|string $fieldName Field name or array of field/order pairs diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/SortByCount.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/SortByCount.php index 0b23d14aad..737675d86d 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/SortByCount.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/SortByCount.php @@ -13,8 +13,7 @@ class SortByCount extends Stage { - /** @var string */ - private $fieldName; + private string $fieldName; /** * @param string $fieldName Expression to group by. To specify a field path, diff --git a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Unwind.php b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Unwind.php index 3e9f21cb92..dd2ff3dc29 100644 --- a/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Unwind.php +++ b/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Unwind.php @@ -12,14 +12,11 @@ */ class Unwind extends Stage { - /** @var string */ - private $fieldName; + private string $fieldName; - /** @var string */ - private $includeArrayIndex; + private ?string $includeArrayIndex = null; - /** @var bool */ - private $preserveNullAndEmptyArrays = false; + private bool $preserveNullAndEmptyArrays = false; public function __construct(Builder $builder, string $fieldName) { diff --git a/lib/Doctrine/ODM/MongoDB/Configuration.php b/lib/Doctrine/ODM/MongoDB/Configuration.php index 8aadb2ab11..de421104bf 100644 --- a/lib/Doctrine/ODM/MongoDB/Configuration.php +++ b/lib/Doctrine/ODM/MongoDB/Configuration.php @@ -83,7 +83,6 @@ class Configuration /** * Array of attributes for this configuration instance. * - * @var array * @psalm-var array{ * autoGenerateHydratorClasses?: self::AUTOGENERATE_*, * autoGeneratePersistentCollectionClasses?: self::AUTOGENERATE_*, @@ -108,16 +107,13 @@ class Configuration * repositoryFactory?: RepositoryFactory * } */ - private $attributes = []; + private array $attributes = []; - /** @var CacheItemPoolInterface|null */ - private $metadataCache; + private ?CacheItemPoolInterface $metadataCache = null; - /** @var ProxyManagerConfiguration */ - private $proxyManagerConfiguration; + private ProxyManagerConfiguration $proxyManagerConfiguration; - /** @var int */ - private $autoGenerateProxyClasses = self::AUTOGENERATE_EVAL; + private int $autoGenerateProxyClasses = self::AUTOGENERATE_EVAL; public function __construct() { diff --git a/lib/Doctrine/ODM/MongoDB/DocumentManager.php b/lib/Doctrine/ODM/MongoDB/DocumentManager.php index 81363ee435..beafc603fe 100644 --- a/lib/Doctrine/ODM/MongoDB/DocumentManager.php +++ b/lib/Doctrine/ODM/MongoDB/DocumentManager.php @@ -58,107 +58,83 @@ class DocumentManager implements ObjectManager /** * The Doctrine MongoDB connection instance. - * - * @var Client */ - private $client; + private Client $client; /** * The used Configuration. - * - * @var Configuration */ - private $config; + private Configuration $config; /** * The metadata factory, used to retrieve the ODM metadata of document classes. - * - * @var ClassMetadataFactory */ - private $metadataFactory; + private ClassMetadataFactory $metadataFactory; /** * The UnitOfWork used to coordinate object-level transactions. - * - * @var UnitOfWork */ - private $unitOfWork; + private UnitOfWork $unitOfWork; /** * The event manager that is the central point of the event system. - * - * @var EventManager */ - private $eventManager; + private EventManager $eventManager; /** * The Hydrator factory instance. - * - * @var HydratorFactory */ - private $hydratorFactory; + private HydratorFactory $hydratorFactory; /** * The Proxy factory instance. - * - * @var ProxyFactory */ - private $proxyFactory; + private ProxyFactory $proxyFactory; /** * The repository factory used to create dynamic repositories. - * - * @var RepositoryFactory */ - private $repositoryFactory; + private RepositoryFactory $repositoryFactory; /** * SchemaManager instance - * - * @var SchemaManager */ - private $schemaManager; + private SchemaManager $schemaManager; /** * Array of cached document database instances that are lazily loaded. * * @var Database[] */ - private $documentDatabases = []; + private array $documentDatabases = []; /** * Array of cached document collection instances that are lazily loaded. * * @var Collection[] */ - private $documentCollections = []; + private array $documentCollections = []; /** * Array of cached document bucket instances that are lazily loaded. * * @var Bucket[] */ - private $documentBuckets = []; + private array $documentBuckets = []; /** * Whether the DocumentManager is closed or not. - * - * @var bool */ - private $closed = false; + private bool $closed = false; /** * Collection of query filters. - * - * @var FilterCollection */ - private $filterCollection; + private ?FilterCollection $filterCollection = null; - /** @var ClassNameResolver */ - private $classNameResolver; + private ClassNameResolver $classNameResolver; - /** @var string|null */ - private static $version; + private static ?string $version = null; /** * Creates a new Document that operates on the given Mongo connection diff --git a/lib/Doctrine/ODM/MongoDB/Event/DocumentNotFoundEventArgs.php b/lib/Doctrine/ODM/MongoDB/Event/DocumentNotFoundEventArgs.php index 4c868a6638..c85f86c00c 100644 --- a/lib/Doctrine/ODM/MongoDB/Event/DocumentNotFoundEventArgs.php +++ b/lib/Doctrine/ODM/MongoDB/Event/DocumentNotFoundEventArgs.php @@ -14,8 +14,7 @@ final class DocumentNotFoundEventArgs extends LifecycleEventArgs /** @var mixed */ private $identifier; - /** @var bool */ - private $disableException = false; + private bool $disableException = false; /** * @param mixed $identifier diff --git a/lib/Doctrine/ODM/MongoDB/Event/OnClassMetadataNotFoundEventArgs.php b/lib/Doctrine/ODM/MongoDB/Event/OnClassMetadataNotFoundEventArgs.php index 674930e87d..e4f0e82074 100644 --- a/lib/Doctrine/ODM/MongoDB/Event/OnClassMetadataNotFoundEventArgs.php +++ b/lib/Doctrine/ODM/MongoDB/Event/OnClassMetadataNotFoundEventArgs.php @@ -15,14 +15,11 @@ */ final class OnClassMetadataNotFoundEventArgs extends ManagerEventArgs { - /** - * @var string - * @psalm-var class-string - */ - private $className; + /** @psalm-var class-string */ + private string $className; /** @var ClassMetadata|null */ - private $foundMetadata; + private ?ClassMetadata $foundMetadata = null; /** * @psalm-param class-string $className diff --git a/lib/Doctrine/ODM/MongoDB/Event/OnClearEventArgs.php b/lib/Doctrine/ODM/MongoDB/Event/OnClearEventArgs.php index 1522a17fbe..23c71968eb 100644 --- a/lib/Doctrine/ODM/MongoDB/Event/OnClearEventArgs.php +++ b/lib/Doctrine/ODM/MongoDB/Event/OnClearEventArgs.php @@ -23,7 +23,7 @@ final class OnClearEventArgs extends BaseOnClearEventArgs * * @var class-string|null */ - private $entityClass; + private ?string $entityClass; /** * @param class-string|null $entityClass diff --git a/lib/Doctrine/ODM/MongoDB/Event/PostCollectionLoadEventArgs.php b/lib/Doctrine/ODM/MongoDB/Event/PostCollectionLoadEventArgs.php index 581dadca74..e45ee91fe1 100644 --- a/lib/Doctrine/ODM/MongoDB/Event/PostCollectionLoadEventArgs.php +++ b/lib/Doctrine/ODM/MongoDB/Event/PostCollectionLoadEventArgs.php @@ -16,7 +16,7 @@ final class PostCollectionLoadEventArgs extends ManagerEventArgs { /** @var PersistentCollectionInterface */ - private $collection; + private PersistentCollectionInterface $collection; /** * @param PersistentCollectionInterface $collection diff --git a/lib/Doctrine/ODM/MongoDB/Event/PreLoadEventArgs.php b/lib/Doctrine/ODM/MongoDB/Event/PreLoadEventArgs.php index a81c8602f6..509f6ae100 100644 --- a/lib/Doctrine/ODM/MongoDB/Event/PreLoadEventArgs.php +++ b/lib/Doctrine/ODM/MongoDB/Event/PreLoadEventArgs.php @@ -12,7 +12,7 @@ final class PreLoadEventArgs extends LifecycleEventArgs { /** @var array */ - private $data; + private array $data; /** * @param array $data diff --git a/lib/Doctrine/ODM/MongoDB/Event/PreUpdateEventArgs.php b/lib/Doctrine/ODM/MongoDB/Event/PreUpdateEventArgs.php index 97e1e65ae7..85a94ec5bf 100644 --- a/lib/Doctrine/ODM/MongoDB/Event/PreUpdateEventArgs.php +++ b/lib/Doctrine/ODM/MongoDB/Event/PreUpdateEventArgs.php @@ -18,11 +18,8 @@ */ final class PreUpdateEventArgs extends LifecycleEventArgs { - /** - * @var array - * @psalm-var array - */ - private $documentChangeSet; + /** @psalm-var array */ + private array $documentChangeSet; /** * @psalm-param array $changeSet diff --git a/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php b/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php index c618b348bd..baa7b3c9e9 100644 --- a/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php +++ b/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php @@ -44,53 +44,40 @@ final class HydratorFactory { /** * The DocumentManager this factory is bound to. - * - * @var DocumentManager */ - private $dm; + private DocumentManager $dm; /** * The UnitOfWork used to coordinate object-level transactions. - * - * @var UnitOfWork */ - private $unitOfWork; + private ?UnitOfWork $unitOfWork = null; /** * The EventManager associated with this Hydrator - * - * @var EventManager */ - private $evm; + private EventManager $evm; /** * Which algorithm to use to automatically (re)generate hydrator classes. - * - * @var int */ - private $autoGenerate; + private int $autoGenerate; /** * The namespace that contains all hydrator classes. - * - * @var string|null */ - private $hydratorNamespace; + private ?string $hydratorNamespace; /** * The directory that contains all hydrator classes. - * - * @var string */ - private $hydratorDir; + private string $hydratorDir; /** * Array of instantiated document hydrators. * - * @var array * @psalm-var array */ - private $hydrators = []; + private array $hydrators = []; /** * @throws HydratorException diff --git a/lib/Doctrine/ODM/MongoDB/Id/AlnumGenerator.php b/lib/Doctrine/ODM/MongoDB/Id/AlnumGenerator.php index a5d3bf139b..3140f99839 100644 --- a/lib/Doctrine/ODM/MongoDB/Id/AlnumGenerator.php +++ b/lib/Doctrine/ODM/MongoDB/Id/AlnumGenerator.php @@ -29,17 +29,13 @@ */ final class AlnumGenerator extends IncrementGenerator { - /** @var int|null */ - protected $pad = null; + protected ?int $pad = null; - /** @var bool */ - protected $awkwardSafeMode = false; + protected bool $awkwardSafeMode = false; - /** @var string */ - protected $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + protected string $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; - /** @var string */ - protected $awkwardSafeChars = '0123456789BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz'; + protected string $awkwardSafeChars = '0123456789BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz'; /** * Set padding on generated id diff --git a/lib/Doctrine/ODM/MongoDB/Id/UuidGenerator.php b/lib/Doctrine/ODM/MongoDB/Id/UuidGenerator.php index 7cf747b146..556587924c 100644 --- a/lib/Doctrine/ODM/MongoDB/Id/UuidGenerator.php +++ b/lib/Doctrine/ODM/MongoDB/Id/UuidGenerator.php @@ -9,9 +9,9 @@ use function chr; use function hexdec; -use function mt_rand; use function php_uname; use function preg_match; +use function random_int; use function sha1; use function sprintf; use function str_replace; @@ -25,10 +25,8 @@ final class UuidGenerator extends AbstractIdGenerator { /** * A unique environment value to salt each UUID with. - * - * @var string */ - protected $salt = null; + protected ?string $salt = null; /** * Used to set the salt that will be applied to each id @@ -41,9 +39,9 @@ public function setSalt(string $salt): void /** * Returns the current salt value * - * @return string $salt The current salt + * @return string|null The current salt */ - public function getSalt(): string + public function getSalt(): ?string { return $this->salt; } @@ -82,21 +80,21 @@ public function generateV4(): string return sprintf( '%04x%04x%04x%04x%04x%04x%04x%04x', // 32 bits for "time_low" - mt_rand(0, 0xffff), - mt_rand(0, 0xffff), + random_int(0, 0xffff), + random_int(0, 0xffff), // 16 bits for "time_mid" - mt_rand(0, 0xffff), + random_int(0, 0xffff), // 16 bits for "time_hi_and_version", // four most significant bits holds version number 4 - mt_rand(0, 0x0fff) | 0x4000, + random_int(0, 0x0fff) | 0x4000, // 16 bits, 8 bits for "clk_seq_hi_res", // 8 bits for "clk_seq_low", // two most significant bits holds zero and one for variant DCE1.1 - mt_rand(0, 0x3fff) | 0x8000, + random_int(0, 0x3fff) | 0x8000, // 48 bits for "node" - mt_rand(0, 0xffff), - mt_rand(0, 0xffff), - mt_rand(0, 0xffff) + random_int(0, 0xffff), + random_int(0, 0xffff), + random_int(0, 0xffff) ); } diff --git a/lib/Doctrine/ODM/MongoDB/Iterator/CachingIterator.php b/lib/Doctrine/ODM/MongoDB/Iterator/CachingIterator.php index 322fb8d933..a695a1517b 100644 --- a/lib/Doctrine/ODM/MongoDB/Iterator/CachingIterator.php +++ b/lib/Doctrine/ODM/MongoDB/Iterator/CachingIterator.php @@ -31,16 +31,14 @@ final class CachingIterator implements Countable, Iterator { /** @var array */ - private $items = []; + private array $items = []; /** @var Generator|null */ private $iterator; - /** @var bool */ - private $iteratorAdvanced = false; + private bool $iteratorAdvanced = false; - /** @var bool */ - private $iteratorExhausted = false; + private bool $iteratorExhausted = false; /** * Initialize the iterator and stores the first item in the cache. This diff --git a/lib/Doctrine/ODM/MongoDB/Iterator/HydratingIterator.php b/lib/Doctrine/ODM/MongoDB/Iterator/HydratingIterator.php index 9fab5bb772..7c8319df59 100644 --- a/lib/Doctrine/ODM/MongoDB/Iterator/HydratingIterator.php +++ b/lib/Doctrine/ODM/MongoDB/Iterator/HydratingIterator.php @@ -28,17 +28,16 @@ final class HydratingIterator implements Iterator /** @var Generator|null */ private $iterator; - /** @var UnitOfWork */ - private $unitOfWork; + private UnitOfWork $unitOfWork; /** @var ClassMetadata */ - private $class; + private ClassMetadata $class; /** * @var array * @psalm-var Hints */ - private $unitOfWorkHints; + private array $unitOfWorkHints; /** * @param Traversable $traversable diff --git a/lib/Doctrine/ODM/MongoDB/Iterator/PrimingIterator.php b/lib/Doctrine/ODM/MongoDB/Iterator/PrimingIterator.php index 5a75d9201c..cedb8898ef 100644 --- a/lib/Doctrine/ODM/MongoDB/Iterator/PrimingIterator.php +++ b/lib/Doctrine/ODM/MongoDB/Iterator/PrimingIterator.php @@ -21,25 +21,23 @@ final class PrimingIterator implements Iterator { /** @var \Iterator */ - private $iterator; + private \Iterator $iterator; /** @var ClassMetadata */ - private $class; + private ClassMetadata $class; - /** @var ReferencePrimer */ - private $referencePrimer; + private ReferencePrimer $referencePrimer; /** @var array */ - private $primers; + private array $primers; /** * @var array * @psalm-var Hints */ - private $unitOfWorkHints; + private array $unitOfWorkHints; - /** @var bool */ - private $referencesPrimed = false; + private bool $referencesPrimed = false; /** * @param \Iterator $iterator diff --git a/lib/Doctrine/ODM/MongoDB/Iterator/UnrewindableIterator.php b/lib/Doctrine/ODM/MongoDB/Iterator/UnrewindableIterator.php index 6f3ad3383c..0d21fe726f 100644 --- a/lib/Doctrine/ODM/MongoDB/Iterator/UnrewindableIterator.php +++ b/lib/Doctrine/ODM/MongoDB/Iterator/UnrewindableIterator.php @@ -26,8 +26,7 @@ final class UnrewindableIterator implements Iterator /** @var Generator|null */ private $iterator; - /** @var bool */ - private $iteratorAdvanced = false; + private bool $iteratorAdvanced = false; /** * Initialize the iterator. This effectively rewinds the Traversable and diff --git a/lib/Doctrine/ODM/MongoDB/LockException.php b/lib/Doctrine/ODM/MongoDB/LockException.php index 4db476c83e..e05e3cabf4 100644 --- a/lib/Doctrine/ODM/MongoDB/LockException.php +++ b/lib/Doctrine/ODM/MongoDB/LockException.php @@ -6,8 +6,7 @@ final class LockException extends MongoDBException { - /** @var object|null */ - private $document; + private ?object $document; public function __construct(string $msg, ?object $document = null) { diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php index 83e2064e0f..68877fe714 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php @@ -468,10 +468,8 @@ /** * Determines how strictly MongoDB applies the validation rules to existing documents during an update. - * - * @var string */ - private $validationLevel = self::SCHEMA_VALIDATION_LEVEL_STRICT; + private string $validationLevel = self::SCHEMA_VALIDATION_LEVEL_STRICT; /** * READ-ONLY: The name of the document class. @@ -657,10 +655,8 @@ /** * READ-ONLY: Whether this class describes the mapping of a database view. - * - * @var bool */ - private $isView = false; + private bool $isView = false; /** * READ-ONLY: Whether this class describes the mapping of a gridFS file @@ -728,11 +724,9 @@ */ public $isReadOnly; - /** @var InstantiatorInterface */ - private $instantiator; + private InstantiatorInterface $instantiator; - /** @var ReflectionService */ - private $reflectionService; + private ReflectionService $reflectionService; /** * @var string|null diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php index f2619e4ff3..1dd7686caf 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php @@ -47,16 +47,16 @@ final class ClassMetadataFactory extends AbstractClassMetadataFactory protected $cacheSalt = '$MONGODBODMCLASSMETADATA'; /** @var DocumentManager The DocumentManager instance */ - private $dm; + private DocumentManager $dm; /** @var Configuration The Configuration instance */ - private $config; + private Configuration $config; /** @var MappingDriver The used metadata driver. */ - private $driver; + private MappingDriver $driver; /** @var EventManager The event manager instance */ - private $evm; + private EventManager $evm; public function setDocumentManager(DocumentManager $dm): void { diff --git a/lib/Doctrine/ODM/MongoDB/PersistentCollection/DefaultPersistentCollectionGenerator.php b/lib/Doctrine/ODM/MongoDB/PersistentCollection/DefaultPersistentCollectionGenerator.php index bbad90d491..d2e131b200 100644 --- a/lib/Doctrine/ODM/MongoDB/PersistentCollection/DefaultPersistentCollectionGenerator.php +++ b/lib/Doctrine/ODM/MongoDB/PersistentCollection/DefaultPersistentCollectionGenerator.php @@ -45,17 +45,13 @@ final class DefaultPersistentCollectionGenerator implements PersistentCollection { /** * The namespace that contains all persistent collection classes. - * - * @var string */ - private $collectionNamespace; + private string $collectionNamespace; /** * The directory that contains all persistent collection classes. - * - * @var string */ - private $collectionDir; + private string $collectionDir; public function __construct(string $collectionDir, string $collectionNs) { diff --git a/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php b/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php index 626836dfc7..b69fc1b3c8 100644 --- a/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php +++ b/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php @@ -44,14 +44,11 @@ */ final class CollectionPersister { - /** @var DocumentManager */ - private $dm; + private DocumentManager $dm; - /** @var PersistenceBuilder */ - private $pb; + private PersistenceBuilder $pb; - /** @var UnitOfWork */ - private $uow; + private UnitOfWork $uow; public function __construct(DocumentManager $dm, PersistenceBuilder $pb, UnitOfWork $uow) { diff --git a/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php b/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php index 26d190b923..3c48cb52cf 100644 --- a/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php +++ b/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php @@ -82,49 +82,38 @@ */ final class DocumentPersister { - /** @var PersistenceBuilder */ - private $pb; + private PersistenceBuilder $pb; - /** @var DocumentManager */ - private $dm; + private DocumentManager $dm; - /** @var UnitOfWork */ - private $uow; + private UnitOfWork $uow; - /** - * @var ClassMetadata - * @psalm-var ClassMetadata - */ - private $class; + /** @psalm-var ClassMetadata */ + private ClassMetadata $class; - /** @var Collection|null */ - private $collection; + private ?Collection $collection = null; - /** @var Bucket|null */ - private $bucket; + private ?Bucket $bucket = null; /** * Array of queued inserts for the persister to insert. * * @var array */ - private $queuedInserts = []; + private array $queuedInserts = []; /** * Array of queued inserts for the persister to insert. * * @var array */ - private $queuedUpserts = []; + private array $queuedUpserts = []; - /** @var CriteriaMerger */ - private $cm; + private CriteriaMerger $cm; - /** @var CollectionPersister */ - private $cp; + private CollectionPersister $cp; - /** @var HydratorFactory */ - private $hydratorFactory; + private HydratorFactory $hydratorFactory; /** * @psalm-param ClassMetadata $class diff --git a/lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php b/lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php index aca0fe4a32..c7331f003b 100644 --- a/lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php +++ b/lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php @@ -33,17 +33,13 @@ final class PersistenceBuilder { /** * The DocumentManager instance. - * - * @var DocumentManager */ - private $dm; + private DocumentManager $dm; /** * The UnitOfWork instance. - * - * @var UnitOfWork */ - private $uow; + private UnitOfWork $uow; /** * Initializes a new PersistenceBuilder instance. diff --git a/lib/Doctrine/ODM/MongoDB/Proxy/Factory/StaticProxyFactory.php b/lib/Doctrine/ODM/MongoDB/Proxy/Factory/StaticProxyFactory.php index bb1ad0de1d..d7fec9496b 100644 --- a/lib/Doctrine/ODM/MongoDB/Proxy/Factory/StaticProxyFactory.php +++ b/lib/Doctrine/ODM/MongoDB/Proxy/Factory/StaticProxyFactory.php @@ -25,13 +25,11 @@ final class StaticProxyFactory implements ProxyFactory { /** @var UnitOfWork The UnitOfWork this factory is bound to. */ - private $uow; + private UnitOfWork $uow; - /** @var LifecycleEventManager */ - private $lifecycleEventManager; + private LifecycleEventManager $lifecycleEventManager; - /** @var LazyLoadingGhostFactory */ - private $proxyFactory; + private LazyLoadingGhostFactory $proxyFactory; public function __construct(DocumentManager $documentManager) { diff --git a/lib/Doctrine/ODM/MongoDB/Proxy/Resolver/CachingClassNameResolver.php b/lib/Doctrine/ODM/MongoDB/Proxy/Resolver/CachingClassNameResolver.php index 6f42570820..9bd86ac036 100644 --- a/lib/Doctrine/ODM/MongoDB/Proxy/Resolver/CachingClassNameResolver.php +++ b/lib/Doctrine/ODM/MongoDB/Proxy/Resolver/CachingClassNameResolver.php @@ -11,11 +11,10 @@ */ final class CachingClassNameResolver implements ClassNameResolver, ProxyClassNameResolver { - /** @var ProxyClassNameResolver */ - private $resolver; + private ProxyClassNameResolver $resolver; /** @var array */ - private $resolvedNames = []; + private array $resolvedNames = []; public function __construct(ProxyClassNameResolver $resolver) { diff --git a/lib/Doctrine/ODM/MongoDB/Proxy/Resolver/ProxyManagerClassNameResolver.php b/lib/Doctrine/ODM/MongoDB/Proxy/Resolver/ProxyManagerClassNameResolver.php index 40756c682e..910f539ce1 100644 --- a/lib/Doctrine/ODM/MongoDB/Proxy/Resolver/ProxyManagerClassNameResolver.php +++ b/lib/Doctrine/ODM/MongoDB/Proxy/Resolver/ProxyManagerClassNameResolver.php @@ -14,8 +14,7 @@ */ final class ProxyManagerClassNameResolver implements ClassNameResolver, ProxyClassNameResolver { - /** @var Configuration */ - private $configuration; + private Configuration $configuration; public function __construct(Configuration $configuration) { diff --git a/lib/Doctrine/ODM/MongoDB/Query/Builder.php b/lib/Doctrine/ODM/MongoDB/Query/Builder.php index b0765feca5..1dc91e98e2 100644 --- a/lib/Doctrine/ODM/MongoDB/Query/Builder.php +++ b/lib/Doctrine/ODM/MongoDB/Query/Builder.php @@ -35,17 +35,13 @@ class Builder { /** * The DocumentManager instance for this query - * - * @var DocumentManager */ - private $dm; + private DocumentManager $dm; /** * The ClassMetadata instance. - * - * @var ClassMetadata */ - private $class; + private ClassMetadata $class; /** * The current field we are operating on. @@ -57,41 +53,32 @@ class Builder /** * Whether or not to hydrate the data to documents. - * - * @var bool */ - private $hydrate = true; + private bool $hydrate = true; /** * Whether or not to refresh the data for documents that are already in the identity map. - * - * @var bool */ - private $refresh = false; + private bool $refresh = false; /** * Array of primer Closure instances. * * @var array */ - private $primers = []; + private array $primers = []; /** * Whether or not to register documents in UnitOfWork. - * - * @var bool */ - private $readOnly = false; + private bool $readOnly = false; - /** @var bool */ - private $rewindable = true; + private bool $rewindable = true; /** * The Collection instance. - * - * @var Collection */ - private $collection; + private Collection $collection; /** * Array containing the query data. @@ -106,10 +93,8 @@ class Builder * * This object includes the query criteria and the "new object" used for * insert and update queries. - * - * @var Expr $expr */ - private $expr; + private Expr $expr; /** * Construct a Builder diff --git a/lib/Doctrine/ODM/MongoDB/Query/Expr.php b/lib/Doctrine/ODM/MongoDB/Query/Expr.php index 7f10674f4f..3439ceeb04 100644 --- a/lib/Doctrine/ODM/MongoDB/Query/Expr.php +++ b/lib/Doctrine/ODM/MongoDB/Query/Expr.php @@ -40,7 +40,7 @@ class Expr /** * The query criteria array. * - * @var array + * @var array|mixed */ private $query = []; @@ -52,28 +52,22 @@ class Expr * * @var array */ - private $newObj = []; + private array $newObj = []; /** * The current field we are operating on. - * - * @var string|null */ - private $currentField; + private ?string $currentField = null; /** * The DocumentManager instance for this query - * - * @var DocumentManager */ - private $dm; + private DocumentManager $dm; /** * The ClassMetadata instance for the document being queried - * - * @var ClassMetadata */ - private $class; + private ?ClassMetadata $class = null; public function __construct(DocumentManager $dm) { diff --git a/lib/Doctrine/ODM/MongoDB/Query/FilterCollection.php b/lib/Doctrine/ODM/MongoDB/Query/FilterCollection.php index be2f6f0f4b..997eceb7bc 100644 --- a/lib/Doctrine/ODM/MongoDB/Query/FilterCollection.php +++ b/lib/Doctrine/ODM/MongoDB/Query/FilterCollection.php @@ -22,31 +22,25 @@ final class FilterCollection { /** * The used Configuration. - * - * @var Configuration */ - private $config; + private Configuration $config; /** * The DocumentManager that "owns" this FilterCollection instance. - * - * @var DocumentManager */ - private $dm; + private DocumentManager $dm; /** * Instances of enabled filters. * * @var BsonFilter[] */ - private $enabledFilters = []; + private array $enabledFilters = []; /** * The CriteriaMerger instance. - * - * @var CriteriaMerger */ - private $cm; + private CriteriaMerger $cm; public function __construct(DocumentManager $dm, ?CriteriaMerger $cm = null) { diff --git a/lib/Doctrine/ODM/MongoDB/Query/Query.php b/lib/Doctrine/ODM/MongoDB/Query/Query.php index f9e4aa8f03..05eb60ec96 100644 --- a/lib/Doctrine/ODM/MongoDB/Query/Query.php +++ b/lib/Doctrine/ODM/MongoDB/Query/Query.php @@ -79,67 +79,55 @@ final class Query implements IteratorAggregate /** * The DocumentManager instance. - * - * @var DocumentManager */ - private $dm; + private DocumentManager $dm; /** * The ClassMetadata instance. - * - * @var ClassMetadata */ - private $class; + private ClassMetadata $class; /** * Whether to hydrate results as document class instances. - * - * @var bool */ - private $hydrate = true; + private bool $hydrate = true; /** * Array of primer Closure instances. * * @var array */ - private $primers = []; + private array $primers = []; - /** @var bool */ - private $rewindable = true; + private bool $rewindable = true; /** * Hints for UnitOfWork behavior. * - * @var array * @psalm-var Hints */ - private $unitOfWorkHints = []; + private array $unitOfWorkHints = []; /** * The Collection instance. - * - * @var Collection */ - protected $collection; + protected Collection $collection; /** * Query structure generated by the Builder class. * - * @var array * @psalm-var QueryShape */ - private $query; + private array $query; - /** @var Iterator|null */ - private $iterator; + private ?Iterator $iterator = null; /** * Query options * * @var array */ - private $options; + private array $options; /** * @param QueryShape $query diff --git a/lib/Doctrine/ODM/MongoDB/Query/QueryExpressionVisitor.php b/lib/Doctrine/ODM/MongoDB/Query/QueryExpressionVisitor.php index 267ba5e6e1..e9fe6f1d7a 100644 --- a/lib/Doctrine/ODM/MongoDB/Query/QueryExpressionVisitor.php +++ b/lib/Doctrine/ODM/MongoDB/Query/QueryExpressionVisitor.php @@ -24,7 +24,7 @@ final class QueryExpressionVisitor extends ExpressionVisitor * @todo Implement support for Comparison::CONTAINS * @var array */ - private static $operatorMethods = [ + private static array $operatorMethods = [ Comparison::EQ => 'equals', Comparison::GT => 'gt', Comparison::GTE => 'gte', @@ -38,16 +38,14 @@ final class QueryExpressionVisitor extends ExpressionVisitor /** * Map Criteria API composite types to query builder methods * - * @var array * @psalm-var array */ - private static $compositeMethods = [ + private static array $compositeMethods = [ CompositeExpression::TYPE_AND => 'addAnd', CompositeExpression::TYPE_OR => 'addOr', ]; - /** @var Builder */ - protected $builder; + protected Builder $builder; public function __construct(Builder $builder) { diff --git a/lib/Doctrine/ODM/MongoDB/Query/ReferencePrimer.php b/lib/Doctrine/ODM/MongoDB/Query/ReferencePrimer.php index 4146d52d44..36412aa3a2 100644 --- a/lib/Doctrine/ODM/MongoDB/Query/ReferencePrimer.php +++ b/lib/Doctrine/ODM/MongoDB/Query/ReferencePrimer.php @@ -54,17 +54,13 @@ final class ReferencePrimer /** * The DocumentManager instance. - * - * @var DocumentManager $dm */ - private $dm; + private DocumentManager $dm; /** * The UnitOfWork instance. - * - * @var UnitOfWork */ - private $uow; + private UnitOfWork $uow; public function __construct(DocumentManager $dm, UnitOfWork $uow) { diff --git a/lib/Doctrine/ODM/MongoDB/Repository/AbstractRepositoryFactory.php b/lib/Doctrine/ODM/MongoDB/Repository/AbstractRepositoryFactory.php index 274b567129..065ba26356 100644 --- a/lib/Doctrine/ODM/MongoDB/Repository/AbstractRepositoryFactory.php +++ b/lib/Doctrine/ODM/MongoDB/Repository/AbstractRepositoryFactory.php @@ -23,7 +23,7 @@ abstract class AbstractRepositoryFactory implements RepositoryFactory * * @var ObjectRepository[] */ - private $repositoryList = []; + private array $repositoryList = []; /** * @psalm-param class-string $documentName diff --git a/lib/Doctrine/ODM/MongoDB/SchemaManager.php b/lib/Doctrine/ODM/MongoDB/SchemaManager.php index cf621f84d5..64bcbfdf70 100644 --- a/lib/Doctrine/ODM/MongoDB/SchemaManager.php +++ b/lib/Doctrine/ODM/MongoDB/SchemaManager.php @@ -54,11 +54,9 @@ final class SchemaManager 'name', ]; - /** @var DocumentManager */ - protected $dm; + protected DocumentManager $dm; - /** @var ClassMetadataFactory */ - protected $metadataFactory; + protected ClassMetadataFactory $metadataFactory; public function __construct(DocumentManager $dm, ClassMetadataFactory $cmf) { diff --git a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/CreateCommand.php b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/CreateCommand.php index f9dfd6416c..32d13db93b 100644 --- a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/CreateCommand.php +++ b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/CreateCommand.php @@ -22,7 +22,7 @@ class CreateCommand extends AbstractCommand { /** @var string[] */ - private $createOrder = [self::COLLECTION, self::INDEX]; + private array $createOrder = [self::COLLECTION, self::INDEX]; /** * @return void diff --git a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/DropCommand.php b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/DropCommand.php index e733aff5df..f31b3bdb18 100644 --- a/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/DropCommand.php +++ b/lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/DropCommand.php @@ -19,7 +19,7 @@ class DropCommand extends AbstractCommand { /** @var string[] */ - private $dropOrder = [self::INDEX, self::COLLECTION, self::DB]; + private array $dropOrder = [self::INDEX, self::COLLECTION, self::DB]; /** * @return void diff --git a/lib/Doctrine/ODM/MongoDB/Tools/Console/MetadataFilter.php b/lib/Doctrine/ODM/MongoDB/Tools/Console/MetadataFilter.php index 5e593d4d10..284868871a 100644 --- a/lib/Doctrine/ODM/MongoDB/Tools/Console/MetadataFilter.php +++ b/lib/Doctrine/ODM/MongoDB/Tools/Console/MetadataFilter.php @@ -35,7 +35,7 @@ public static function filter(array $metadatas, $filter): array } /** @var string[] */ - private $_filter = []; + private array $_filter = []; /** * @param string[]|string $filter diff --git a/lib/Doctrine/ODM/MongoDB/Tools/ResolveTargetDocumentListener.php b/lib/Doctrine/ODM/MongoDB/Tools/ResolveTargetDocumentListener.php index f499cfc6a5..31bb5affd9 100644 --- a/lib/Doctrine/ODM/MongoDB/Tools/ResolveTargetDocumentListener.php +++ b/lib/Doctrine/ODM/MongoDB/Tools/ResolveTargetDocumentListener.php @@ -24,11 +24,8 @@ */ class ResolveTargetDocumentListener implements EventSubscriber { - /** - * @var array - * @psalm-var array - */ - private $resolveTargetDocuments = []; + /** @psalm-var array */ + private array $resolveTargetDocuments = []; public function getSubscribedEvents() { diff --git a/lib/Doctrine/ODM/MongoDB/Types/DateType.php b/lib/Doctrine/ODM/MongoDB/Types/DateType.php index 652544cd82..92b6892e7b 100644 --- a/lib/Doctrine/ODM/MongoDB/Types/DateType.php +++ b/lib/Doctrine/ODM/MongoDB/Types/DateType.php @@ -52,7 +52,7 @@ public static function getDateTime($value): DateTimeInterface $value = (float) $value; $seconds = (int) $value; $microseconds = abs(round($value - $seconds, 6)); - $microseconds *= 1000000; + $microseconds *= 1_000_000; $datetime = static::craftDateTime($seconds, (int) $microseconds); } elseif (is_string($value)) { diff --git a/lib/Doctrine/ODM/MongoDB/Types/Type.php b/lib/Doctrine/ODM/MongoDB/Types/Type.php index da5206c2bd..d6f2b4636d 100644 --- a/lib/Doctrine/ODM/MongoDB/Types/Type.php +++ b/lib/Doctrine/ODM/MongoDB/Types/Type.php @@ -52,13 +52,13 @@ abstract class Type public const DECIMAL128 = 'decimal128'; /** @var Type[] Map of already instantiated type objects. One instance per type (flyweight). */ - private static $typeObjects = []; + private static array $typeObjects = []; /** * @var string[] The map of supported doctrine mapping types. * @psalm-var array */ - private static $typesMap = [ + private static array $typesMap = [ self::ID => Types\IdType::class, self::INTID => Types\IntIdType::class, self::CUSTOMID => Types\CustomIdType::class, diff --git a/lib/Doctrine/ODM/MongoDB/UnitOfWork.php b/lib/Doctrine/ODM/MongoDB/UnitOfWork.php index b740682e9c..6c8584d9e7 100644 --- a/lib/Doctrine/ODM/MongoDB/UnitOfWork.php +++ b/lib/Doctrine/ODM/MongoDB/UnitOfWork.php @@ -100,10 +100,9 @@ final class UnitOfWork implements PropertyChangedListener * Since all classes in a hierarchy must share the same identifier set, * we always take the root class name of the hierarchy. * - * @var array * @psalm-var array> */ - private $identityMap = []; + private array $identityMap = []; /** * Map of all identifiers of managed documents. @@ -111,7 +110,7 @@ final class UnitOfWork implements PropertyChangedListener * * @var array */ - private $documentIdentifiers = []; + private array $documentIdentifiers = []; /** * Map of the original document data of managed documents. @@ -124,25 +123,23 @@ final class UnitOfWork implements PropertyChangedListener * * @var array> */ - private $originalDocumentData = []; + private array $originalDocumentData = []; /** * Map of document changes. Keys are object ids (spl_object_hash). * Filled at the beginning of a commit of the UnitOfWork and cleaned at the end. * - * @var array * @psalm-var array> */ - private $documentChangeSets = []; + private array $documentChangeSets = []; /** * The (cached) states of any known documents. * Keys are object ids (spl_object_hash). * - * @var array * @psalm-var array */ - private $documentStates = []; + private array $documentStates = []; /** * Map of documents that are scheduled for dirty checking at commit time. @@ -151,62 +148,58 @@ final class UnitOfWork implements PropertyChangedListener * object hash. This is only used for documents with a change tracking * policy of DEFERRED_EXPLICIT. * - * @var array * @psalm-var array> */ - private $scheduledForSynchronization = []; + private array $scheduledForSynchronization = []; /** * A list of all pending document insertions. * * @var array */ - private $documentInsertions = []; + private array $documentInsertions = []; /** * A list of all pending document updates. * * @var array */ - private $documentUpdates = []; + private array $documentUpdates = []; /** * A list of all pending document upserts. * * @var array */ - private $documentUpserts = []; + private array $documentUpserts = []; /** * A list of all pending document deletions. * * @var array */ - private $documentDeletions = []; + private array $documentDeletions = []; /** * All pending collection deletions. * - * @var array * @psalm-var array> */ - private $collectionDeletions = []; + private array $collectionDeletions = []; /** * All pending collection updates. * - * @var array * @psalm-var array> */ - private $collectionUpdates = []; + private array $collectionUpdates = []; /** * A list of documents related to collections scheduled for update or deletion * - * @var array * @psalm-var array>> */ - private $hasScheduledCollections = []; + private array $hasScheduledCollections = []; /** * List of collections visited during changeset calculation on a commit-phase of a UnitOfWork. @@ -215,71 +208,57 @@ final class UnitOfWork implements PropertyChangedListener * * @psalm-var array>> */ - private $visitedCollections = []; + private array $visitedCollections = []; /** * The DocumentManager that "owns" this UnitOfWork instance. - * - * @var DocumentManager */ - private $dm; + private DocumentManager $dm; /** * The EventManager used for dispatching events. - * - * @var EventManager */ - private $evm; + private EventManager $evm; /** * Additional documents that are scheduled for removal. * * @var array */ - private $orphanRemovals = []; + private array $orphanRemovals = []; /** * The HydratorFactory used for hydrating array Mongo documents to Doctrine object documents. - * - * @var HydratorFactory */ - private $hydratorFactory; + private HydratorFactory $hydratorFactory; /** * The document persister instances used to persist document instances. * - * @var array * @psalm-var array */ - private $persisters = []; + private array $persisters = []; /** * The collection persister instance used to persist changes to collections. - * - * @var Persisters\CollectionPersister|null */ - private $collectionPersister; + private ?CollectionPersister $collectionPersister = null; /** * The persistence builder instance used in DocumentPersisters. - * - * @var PersistenceBuilder|null */ - private $persistenceBuilder; + private ?PersistenceBuilder $persistenceBuilder = null; /** * Array of parent associations between embedded documents. * - * @var array * @psalm-var array */ - private $parentAssociations = []; + private array $parentAssociations = []; - /** @var LifecycleEventManager */ - private $lifecycleEventManager; + private LifecycleEventManager $lifecycleEventManager; - /** @var ReflectionService */ - private $reflectionService; + private ReflectionService $reflectionService; /** * Array of embedded documents known to UnitOfWork. We need to hold them to prevent spl_object_hash @@ -288,10 +267,9 @@ final class UnitOfWork implements PropertyChangedListener * * @var array */ - private $embeddedDocumentsRegistry = []; + private array $embeddedDocumentsRegistry = []; - /** @var int */ - private $commitsInProgress = 0; + private int $commitsInProgress = 0; /** * Initializes a new UnitOfWork instance, bound to the given DocumentManager. diff --git a/lib/Doctrine/ODM/MongoDB/Utility/LifecycleEventManager.php b/lib/Doctrine/ODM/MongoDB/Utility/LifecycleEventManager.php index 8bf418bf16..a2a70ca5e3 100644 --- a/lib/Doctrine/ODM/MongoDB/Utility/LifecycleEventManager.php +++ b/lib/Doctrine/ODM/MongoDB/Utility/LifecycleEventManager.php @@ -23,14 +23,11 @@ */ final class LifecycleEventManager { - /** @var DocumentManager */ - private $dm; + private DocumentManager $dm; - /** @var EventManager */ - private $evm; + private EventManager $evm; - /** @var UnitOfWork */ - private $uow; + private UnitOfWork $uow; public function __construct(DocumentManager $dm, UnitOfWork $uow, EventManager $evm) { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 26f5e01638..5781adc4fe 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -6,6 +6,7 @@ convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" + failOnRisky="true" stopOnFailure="false" bootstrap="tests/bootstrap.php" > diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Events/PreUpdateEventArgsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Events/PreUpdateEventArgsTest.php index 6dea28379a..b06d831899 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Events/PreUpdateEventArgsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Events/PreUpdateEventArgsTest.php @@ -32,9 +32,6 @@ public function testChangeSetIsUpdated(): void $this->assertEquals('Changed', $a->getBody()); } - /** - * @doesNotPerformAssertions - */ public function testCollectionsAreInChangeSet(): void { $listener = new CollectionsAreInChangeSetListener($this); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomCollectionsTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomCollectionsTest.php index 29f3bf02d6..30abbeebd9 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomCollectionsTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/CustomCollectionsTest.php @@ -174,9 +174,6 @@ public function testModifyingCollectionInChangeTrackingNotifyDocument(): void $this->assertEquals($f1->getId(), $profile->getImages()[1]->getId()); } - /** - * @doesNotPerformAssertions - */ public function testMethodWithVoidReturnType(): void { $d = new DocumentWithCustomCollection(); @@ -184,6 +181,7 @@ public function testMethodWithVoidReturnType(): void $this->dm->flush(); $d = $this->dm->find(get_class($d), $d->id); + $this->assertInstanceOf(MyEmbedsCollection::class, $d->coll); $d->coll->nothingReally(); } } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php b/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php index b8ad1e0d34..90ec697195 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php @@ -382,9 +382,6 @@ public function testDeleteDocumentIndexes(array $expectedWriteOptions, ?int $max $this->schemaManager->deleteDocumentIndexes(CmsArticle::class, $maxTimeMs, $writeConcern); } - /** - * @doesNotPerformAssertions - */ public function testUpdateValidators(): void { $dbCommands = [];