diff --git a/cli-config.doctrine_dbal.php.dist b/cli-config.doctrine_dbal.php.dist index 7d66902a8..1c68c8a7b 100644 --- a/cli-config.doctrine_dbal.php.dist +++ b/cli-config.doctrine_dbal.php.dist @@ -7,16 +7,17 @@ * Add instances of commands for eventual implementation specific commands to this array. */ -$extraCommands = array(); +$extraCommands = []; $extraCommands[] = new \Jackalope\Tools\Console\Command\InitDoctrineDbalCommand(); -$params = array( +$params = [ 'driver' => 'pdo_mysql', 'host' => '127.0.0.1', 'user' => 'root', 'password' => '', 'dbname' => 'phpcr_odm_tests', -); + 'charset' => 'utf8mb4', +]; $dbConn = \Doctrine\DBAL\DriverManager::getConnection($params); @@ -31,7 +32,7 @@ if (isset($argv[1]) && $argv[1] != 'help' ) { $factory = new \Jackalope\RepositoryFactoryDoctrineDBAL(); - $repository = $factory->getRepository(array('jackalope.doctrine_dbal_connection' => $dbConn)); + $repository = $factory->getRepository(['jackalope.doctrine_dbal_connection' => $dbConn]); $credentials = new \PHPCR\SimpleCredentials(null, null); $session = $repository->login($credentials, $workspace); @@ -44,11 +45,11 @@ if (isset($argv[1]) $dm = \Doctrine\ODM\PHPCR\DocumentManager::create($session, $config); - $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array( + $helperSet = new \Symfony\Component\Console\Helper\HelperSet([ 'phpcr' => new \PHPCR\Util\Console\Helper\PhpcrHelper($session), 'phpcr_console_dumper' => new \PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper(), 'dm' => new \Doctrine\ODM\PHPCR\Tools\Console\Helper\DocumentManagerHelper(null, $dm), - )); + ]); if (class_exists('Symfony\Component\Console\Helper\QuestionHelper')) { $helperSet->set(new \Symfony\Component\Console\Helper\QuestionHelper(), 'question'); @@ -57,7 +58,7 @@ if (isset($argv[1]) } } elseif (isset($argv[1]) && $argv[1] == 'jackalope:init:dbal') { // special case: the init command needs the db connection, but a session is impossible if the db is not yet initialized - $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array( + $helperSet = new \Symfony\Component\Console\Helper\HelperSet([ 'connection' => new \Jackalope\Tools\Console\Helper\DoctrineDbalHelper($dbConn) - )); + ]); } diff --git a/cli-config.jackrabbit.php.dist b/cli-config.jackrabbit.php.dist index 85876f9d5..5be8bda18 100644 --- a/cli-config.jackrabbit.php.dist +++ b/cli-config.jackrabbit.php.dist @@ -7,7 +7,7 @@ * Add instances of commands for eventual implementation specific commands to this array. */ -$extraCommands = array(); +$extraCommands = []; $extraCommands[] = new \Jackalope\Tools\Console\Command\JackrabbitCommand(); if (! isset($argv[1]) @@ -19,9 +19,9 @@ if (! isset($argv[1]) return; } -$params = array( +$params = [ 'jackalope.jackrabbit_uri' => 'http://127.0.0.1:8080/server/', -); +]; $workspace = 'default'; $user = 'admin'; @@ -42,11 +42,11 @@ $config->setMetadataDriverImpl($driver); $dm = \Doctrine\ODM\PHPCR\DocumentManager::create($session, $config); -$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array( +$helperSet = new \Symfony\Component\Console\Helper\HelperSet([ 'phpcr' => new \PHPCR\Util\Console\Helper\PhpcrHelper($session), 'phpcr_console_dumper' => new \PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper(), 'dm' => new \Doctrine\ODM\PHPCR\Tools\Console\Helper\DocumentManagerHelper(null, $dm), -)); +]); if (class_exists('Symfony\Component\Console\Helper\QuestionHelper')) { $helperSet->set(new \Symfony\Component\Console\Helper\QuestionHelper(), 'question'); diff --git a/docs/en/cookbook/custom_documentclass_mapper.rst b/docs/en/cookbook/custom_documentclass_mapper.rst index 36340a4d3..bb4d67892 100644 --- a/docs/en/cookbook/custom_documentclass_mapper.rst +++ b/docs/en/cookbook/custom_documentclass_mapper.rst @@ -62,9 +62,9 @@ custom mapper:: /* prepare the doctrine configuration */ $config = new \Doctrine\ODM\PHPCR\Configuration(); - $map = array( + $map = [ 'standard-templating-kit:pages/stkSection' => \Sandbox\MagnoliaBundle\Document\Section::class, - ); + ]; $mapper = new MagnoliaDocumentClassMapper($map); $config->setDocumentClassMapper($mapper); @@ -125,18 +125,18 @@ of instantiating the default one. An example from the `symfony cmf sandbox`_ $container ->register('doctrine.odm_configuration', '%doctrine_phpcr.odm.configuration.class%') - ->addMethodCall('setDocumentClassMapper', array( + ->addMethodCall('setDocumentClassMapper', [ new Reference('sandbox_magnolia.odm_mapper'), - )) + ]) ; $container ->setDefinition('sandbox_amgnolia.odm_mapper', new Definition( MagnoliaDocumentClassMapper::class, - array( - array( + [ + [ 'standard-templating-kit:pages/stkSection' => Section::class, - ), - ), + ], + ], )); .. _`symfony cmf sandbox`: https://github.com/symfony-cmf/cmf-sandbox/tree/magnolia_integration diff --git a/docs/en/reference/installation-configuration.rst b/docs/en/reference/installation-configuration.rst index 7c366ddd6..13af2e3cd 100644 --- a/docs/en/reference/installation-configuration.rst +++ b/docs/en/reference/installation-configuration.rst @@ -82,6 +82,7 @@ Bootstrap will roughly look like this when using mysql as storage backend:: 'user' => $user, 'password' => $pass, 'dbname' => 'phpcr_odm_tutorial', + 'charset' => 'utf8mb4', // only when using MySQL ]; // Bootstrap Doctrine DBAL @@ -253,6 +254,7 @@ A complete configuration could look like this:: 'user' => $user, 'password' => $pass, 'dbname' => 'phpcr_odm_tutorial', + 'charset' => 'utf8mb4', ]; $dbConn = \Doctrine\DBAL\DriverManager::getConnection($params); $parameters = ['jackalope.doctrine_dbal_connection' => $dbConn]; diff --git a/docs/en/reference/introduction.rst b/docs/en/reference/introduction.rst index fcf7117f9..cc70ea9ad 100644 --- a/docs/en/reference/introduction.rst +++ b/docs/en/reference/introduction.rst @@ -100,6 +100,7 @@ your project root directory:: 'user' => 'root', 'password' => '', 'dbname' => 'phpcr_odm_tutorial', + 'charset' => 'utf8mb4', ]; $workspace = 'default'; diff --git a/lib/Doctrine/ODM/PHPCR/ChildrenCollection.php b/lib/Doctrine/ODM/PHPCR/ChildrenCollection.php index 427f64883..4afdcd56c 100644 --- a/lib/Doctrine/ODM/PHPCR/ChildrenCollection.php +++ b/lib/Doctrine/ODM/PHPCR/ChildrenCollection.php @@ -36,7 +36,7 @@ class ChildrenCollection extends PersistentCollection * @param int $fetchDepth Optional fetch depth, -1 to not override * @param string|null $locale The locale to use during the loading of this collection */ - public function __construct(DocumentManagerInterface $dm, object $document, array|string $filter = null, int $fetchDepth = -1, string $locale = null) + public function __construct(DocumentManagerInterface $dm, object $document, array|string|null $filter = null, int $fetchDepth = -1, ?string $locale = null) { parent::__construct($dm); $this->document = $document; diff --git a/lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php b/lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php index 65346c171..ea5de65ff 100644 --- a/lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php +++ b/lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php @@ -133,7 +133,7 @@ public function createPhpcrQueryBuilder(): PhpcrQueryBuilder return $this->wrapped->createPhpcrQueryBuilder(); } - public function getDocumentsByPhpcrQuery(QueryInterface $query, string $className = null, string $primarySelector = null): Collection + public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): Collection { return $this->wrapped->getDocumentsByPhpcrQuery($query, $className, $primarySelector); } @@ -168,17 +168,17 @@ public function reorder(object $document, string $srcName, string $targetName, b $this->wrapped->reorder($document, $srcName, $targetName, $before); } - public function getChildren(object $document, array|string $filter = null, int $fetchDepth = -1, string $locale = null): ChildrenCollection + public function getChildren(object $document, array|string|null $filter = null, int $fetchDepth = -1, ?string $locale = null): ChildrenCollection { return $this->wrapped->getChildren($document, $filter, $fetchDepth, $locale); } - public function getReferrers(object $document, string $type = null, string $name = null, string $locale = null, string $refClass = null): ReferrersCollection + public function getReferrers(object $document, ?string $type = null, ?string $name = null, ?string $locale = null, ?string $refClass = null): ReferrersCollection { return $this->wrapped->getReferrers($document, $type, $name, $locale, $refClass); } - public function flush(object|array $document = null): void + public function flush(object|array|null $document = null): void { $this->wrapped->flush($document); } diff --git a/lib/Doctrine/ODM/PHPCR/DocumentClassMapper.php b/lib/Doctrine/ODM/PHPCR/DocumentClassMapper.php index fe07d7b93..b72765abb 100644 --- a/lib/Doctrine/ODM/PHPCR/DocumentClassMapper.php +++ b/lib/Doctrine/ODM/PHPCR/DocumentClassMapper.php @@ -13,7 +13,7 @@ */ class DocumentClassMapper implements DocumentClassMapperInterface { - private function expandClassName(DocumentManagerInterface $dm, string $className = null): ?string + private function expandClassName(DocumentManagerInterface $dm, ?string $className = null): ?string { if (null === $className) { return null; @@ -26,7 +26,7 @@ private function expandClassName(DocumentManagerInterface $dm, string $className return $className; } - public function getClassName(DocumentManagerInterface $dm, NodeInterface $node, string $className = null): string + public function getClassName(DocumentManagerInterface $dm, NodeInterface $node, ?string $className = null): string { $className = $this->expandClassName($dm, $className); diff --git a/lib/Doctrine/ODM/PHPCR/DocumentClassMapperInterface.php b/lib/Doctrine/ODM/PHPCR/DocumentClassMapperInterface.php index 32688edcb..3a9e5dcc3 100644 --- a/lib/Doctrine/ODM/PHPCR/DocumentClassMapperInterface.php +++ b/lib/Doctrine/ODM/PHPCR/DocumentClassMapperInterface.php @@ -20,7 +20,7 @@ interface DocumentClassMapperInterface * @throws ClassMismatchException if $node represents a class that is not * a descendant of $className */ - public function getClassName(DocumentManagerInterface $dm, NodeInterface $node, string $className = null): string; + public function getClassName(DocumentManagerInterface $dm, NodeInterface $node, ?string $className = null): string; /** * Write any relevant meta data into the node to be able to map back to a class name later. diff --git a/lib/Doctrine/ODM/PHPCR/DocumentManager.php b/lib/Doctrine/ODM/PHPCR/DocumentManager.php index 8dc0953e1..18d9001fd 100644 --- a/lib/Doctrine/ODM/PHPCR/DocumentManager.php +++ b/lib/Doctrine/ODM/PHPCR/DocumentManager.php @@ -61,7 +61,7 @@ class DocumentManager implements DocumentManagerInterface private LocaleChooserInterface $localeChooserStrategy; private ValueConverter $valueConverter; - public function __construct(SessionInterface $session, Configuration $config = null, EventManager $evm = null) + public function __construct(SessionInterface $session, ?Configuration $config = null, ?EventManager $evm = null) { $this->session = $session; $this->config = $config ?: new Configuration(); @@ -136,7 +136,7 @@ public function getPhpcrSession(): SessionInterface /** * Factory method to create a Document Manager. */ - public static function create(SessionInterface $session, Configuration $config = null, EventManager $evm = null): DocumentManager + public static function create(SessionInterface $session, ?Configuration $config = null, ?EventManager $evm = null): DocumentManager { return new self($session, $config, $evm); } @@ -342,7 +342,7 @@ public function createPhpcrQueryBuilder(): PhpcrQueryBuilder return new PhpcrQueryBuilder($qm->getQOMFactory()); } - public function getDocumentsByPhpcrQuery(QueryInterface $query, string $className = null, string $primarySelector = null): Collection + public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): Collection { $this->errorIfClosed(); @@ -504,14 +504,14 @@ public function refresh($document): void $this->unitOfWork->refresh($document); } - public function getChildren(object $document, array|string $filter = null, int $fetchDepth = -1, string $locale = null): ChildrenCollection + public function getChildren(object $document, array|string|null $filter = null, int $fetchDepth = -1, ?string $locale = null): ChildrenCollection { $this->errorIfClosed(); return new ChildrenCollection($this, $document, $filter, $fetchDepth, $locale); } - public function getReferrers(object $document, string $type = null, string $name = null, string $locale = null, $refClass = null): ReferrersCollection + public function getReferrers(object $document, ?string $type = null, ?string $name = null, ?string $locale = null, $refClass = null): ReferrersCollection { $this->errorIfClosed(); @@ -530,7 +530,7 @@ public function getReferrers(object $document, string $type = null, string $name * @throws InvalidArgumentException if $document is neither null nor a * document or an array of documents */ - public function flush(object|array $document = null): void + public function flush(object|array|null $document = null): void { if (null !== $document && !is_object($document) && !is_array($document)) { throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given'); diff --git a/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php b/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php index d960882c0..34192d5c3 100644 --- a/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php +++ b/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php @@ -236,7 +236,7 @@ public function createPhpcrQueryBuilder(): PhpcrQueryBuilder; * @param string|null $className document class * @param string|null $primarySelector name of the selector for the document to return in case of a join query */ - public function getDocumentsByPhpcrQuery(QueryInterface $query, string $className = null, string $primarySelector = null): Collection; + public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): Collection; /** * Bind the translatable fields of the document in the specified locale. @@ -331,7 +331,7 @@ public function reorder(object $document, string $srcName, string $targetName, b * * @throws InvalidArgumentException if $document is not an object */ - public function getChildren(object $document, array|string $filter = null, int $fetchDepth = -1, string $locale = null): ChildrenCollection; + public function getChildren(object $document, array|string|null $filter = null, int $fetchDepth = -1, ?string $locale = null): ChildrenCollection; /** * Get the documents that refer a given document using an optional name. @@ -353,7 +353,7 @@ public function getChildren(object $document, array|string $filter = null, int $ * * @throws InvalidArgumentException if $document is not an object */ - public function getReferrers(object $document, string $type = null, string $name = null, string $locale = null, string $refClass = null): ReferrersCollection; + public function getReferrers(object $document, ?string $type = null, ?string $name = null, ?string $locale = null, ?string $refClass = null): ReferrersCollection; /** * Gets a reference to the document identified by the given type and identifier @@ -480,7 +480,7 @@ public function getUnitOfWork(): UnitOfWork; * @throws InvalidArgumentException if $document is neither null nor a * document or an array of documents */ - public function flush(object|array $document = null): void; + public function flush(object|array|null $document = null): void; /** * Closes the DocumentManager. All entities that are currently managed diff --git a/lib/Doctrine/ODM/PHPCR/DocumentRepository.php b/lib/Doctrine/ODM/PHPCR/DocumentRepository.php index 584f18117..cb0b8e428 100644 --- a/lib/Doctrine/ODM/PHPCR/DocumentRepository.php +++ b/lib/Doctrine/ODM/PHPCR/DocumentRepository.php @@ -81,7 +81,7 @@ public function findAll(): Collection * * @return Collection the objects matching the criteria */ - public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): Collection + public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): Collection { $qb = $this->createQueryBuilder('a'); @@ -199,7 +199,7 @@ public function getClassMetadata(): ClassMetadata * * @see \PHPCR\PropertyType */ - public function quote(string $val, int $type = null): string + public function quote(string $val, ?int $type = null): string { return $this->dm->quote($val, $type); } diff --git a/lib/Doctrine/ODM/PHPCR/Id/AssignedIdGenerator.php b/lib/Doctrine/ODM/PHPCR/Id/AssignedIdGenerator.php index 8c73aef4b..8216265f3 100644 --- a/lib/Doctrine/ODM/PHPCR/Id/AssignedIdGenerator.php +++ b/lib/Doctrine/ODM/PHPCR/Id/AssignedIdGenerator.php @@ -15,7 +15,7 @@ class AssignedIdGenerator extends IdGenerator * * {@inheritdoc} */ - public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, object $parent = null): string + public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, ?object $parent = null): string { if (!$class->identifier || !$id = $class->getFieldValue($document, $class->identifier)) { throw new IdException('ID could not be read from the document instance using the AssignedIdGenerator.'); diff --git a/lib/Doctrine/ODM/PHPCR/Id/AutoIdGenerator.php b/lib/Doctrine/ODM/PHPCR/Id/AutoIdGenerator.php index 9dbffb774..9912cfd42 100644 --- a/lib/Doctrine/ODM/PHPCR/Id/AutoIdGenerator.php +++ b/lib/Doctrine/ODM/PHPCR/Id/AutoIdGenerator.php @@ -17,7 +17,7 @@ class AutoIdGenerator extends ParentIdGenerator * * {@inheritdoc} */ - public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, object $parent = null): string + public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, ?object $parent = null): string { if (null === $parent) { $parent = $class->parentMapping ? $class->getFieldValue($document, $class->parentMapping) : null; diff --git a/lib/Doctrine/ODM/PHPCR/Id/IdException.php b/lib/Doctrine/ODM/PHPCR/Id/IdException.php index a852d043a..952d2b3c1 100644 --- a/lib/Doctrine/ODM/PHPCR/Id/IdException.php +++ b/lib/Doctrine/ODM/PHPCR/Id/IdException.php @@ -55,7 +55,7 @@ public static function parentIdCouldNotBeDetermined(object $document, string $pa return new self($message); } - public static function illegalName(object $document, string $fieldName, string $nodeName, \Throwable $previous = null): self + public static function illegalName(object $document, string $fieldName, string $nodeName, ?\Throwable $previous = null): self { $message = sprintf( 'Nodename property "%s" of document "%s" contains the illegal PHPCR value "%s".', diff --git a/lib/Doctrine/ODM/PHPCR/Id/IdGenerator.php b/lib/Doctrine/ODM/PHPCR/Id/IdGenerator.php index ec2dc5bd5..7f06922e8 100644 --- a/lib/Doctrine/ODM/PHPCR/Id/IdGenerator.php +++ b/lib/Doctrine/ODM/PHPCR/Id/IdGenerator.php @@ -44,5 +44,5 @@ public static function create(int $generatorType): IdGenerator /** * Generate the actual id, to be overwritten by extending classes. */ - abstract public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, object $parent = null): string; + abstract public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, ?object $parent = null): string; } diff --git a/lib/Doctrine/ODM/PHPCR/Id/ParentIdGenerator.php b/lib/Doctrine/ODM/PHPCR/Id/ParentIdGenerator.php index 73c6034bd..baaef0e06 100644 --- a/lib/Doctrine/ODM/PHPCR/Id/ParentIdGenerator.php +++ b/lib/Doctrine/ODM/PHPCR/Id/ParentIdGenerator.php @@ -16,7 +16,7 @@ class ParentIdGenerator extends IdGenerator * * {@inheritdoc} */ - public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, object $parent = null): string + public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, ?object $parent = null): string { if (null === $parent) { $parent = $class->parentMapping ? $class->getFieldValue($document, $class->parentMapping) : null; diff --git a/lib/Doctrine/ODM/PHPCR/Id/RepositoryIdGenerator.php b/lib/Doctrine/ODM/PHPCR/Id/RepositoryIdGenerator.php index 790636a31..9566f628c 100644 --- a/lib/Doctrine/ODM/PHPCR/Id/RepositoryIdGenerator.php +++ b/lib/Doctrine/ODM/PHPCR/Id/RepositoryIdGenerator.php @@ -13,7 +13,7 @@ class RepositoryIdGenerator extends IdGenerator * * {@inheritdoc} */ - public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, object $parent = null): string + public function generate(object $document, ClassMetadata $class, DocumentManagerInterface $dm, ?object $parent = null): string { if (null === $parent) { $parent = $class->parentMapping ? $class->getFieldValue($document, $class->parentMapping) : null; diff --git a/lib/Doctrine/ODM/PHPCR/Id/RepositoryIdInterface.php b/lib/Doctrine/ODM/PHPCR/Id/RepositoryIdInterface.php index 0d97da1e9..ecb996058 100644 --- a/lib/Doctrine/ODM/PHPCR/Id/RepositoryIdInterface.php +++ b/lib/Doctrine/ODM/PHPCR/Id/RepositoryIdInterface.php @@ -7,5 +7,5 @@ */ interface RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string; + public function generateId(object $document, ?object $parent = null): string; } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php index 3524eb36a..e838fe125 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Child.php @@ -7,14 +7,14 @@ #[\Attribute(\Attribute::TARGET_PROPERTY)] final class Child implements MappingAttribute { - public array|null $cascade; + public ?array $cascade; /** * @param string[]|string $cascade */ public function __construct( - public null|string $nodeName = null, - array|string $cascade = null, + public ?string $nodeName = null, + array|string|null $cascade = null, ) { $this->cascade = null === $cascade ? null : (array) $cascade; } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php index 7202a55a6..82840a2b9 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Children.php @@ -7,18 +7,18 @@ #[\Attribute(\Attribute::TARGET_PROPERTY)] final class Children implements MappingAttribute { - public array|null $filter; - public array|null $cascade; + public ?array $filter; + public ?array $cascade; /** * @param string[]|string $filter * @param string[]|string $cascade */ public function __construct( - array|string $filter = null, + array|string|null $filter = null, public int $fetchDepth = -1, public bool $ignoreUntranslated = true, - array|string $cascade = null, + array|string|null $cascade = null, ) { $this->filter = null === $filter ? null : (array) $filter; $this->cascade = null === $cascade ? null : (array) $cascade; diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php index 08d79ae12..5952e0b9c 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Document.php @@ -7,20 +7,20 @@ #[\Attribute(\Attribute::TARGET_CLASS)] class Document implements MappingAttribute { - public array|null $mixins; - public array|null $childClasses; + public ?array $mixins; + public ?array $childClasses; public function __construct( - public null|string $nodeType = null, - public null|string $repositoryClass = null, - public null|string $translator = null, - string|array $mixins = null, - public bool|null $inheritMixins = null, - public null|string $versionable = null, - public null|bool $referenceable = null, - public null|bool $uniqueNodeType = null, - string|array $childClasses = null, - public bool|null $isLeaf = null, + public ?string $nodeType = null, + public ?string $repositoryClass = null, + public ?string $translator = null, + string|array|null $mixins = null, + public ?bool $inheritMixins = null, + public ?string $versionable = null, + public ?bool $referenceable = null, + public ?bool $uniqueNodeType = null, + string|array|null $childClasses = null, + public ?bool $isLeaf = null, ) { $this->mixins = null === $mixins ? null : (array) $mixins; $this->childClasses = null === $childClasses ? null : (array) $childClasses; diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php index c2b31b45c..ce9d30583 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Field.php @@ -8,10 +8,10 @@ class Field implements MappingAttribute { public function __construct( - public null|string $property = null, + public ?string $property = null, public string $type = 'undefined', public bool $multivalue = false, - public null|string $assoc = null, + public ?string $assoc = null, public bool $nullable = false, public bool $translated = false, ) { diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php index db48afcbb..7052597a9 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Id.php @@ -10,7 +10,7 @@ final class Id implements MappingAttribute public function __construct( public bool $id = true, public string $type = 'string', - public null|string $strategy = null, + public ?string $strategy = null, ) { } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php index 4ec5371a5..b91029af2 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/MixedReferrers.php @@ -8,7 +8,7 @@ final class MixedReferrers implements MappingAttribute { public function __construct( - public null|string $referenceType = null + public ?string $referenceType = null ) { } } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php index a2e9d25c5..f0c0ab7cd 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/ParentDocument.php @@ -12,10 +12,10 @@ #[\Attribute(\Attribute::TARGET_PROPERTY)] final class ParentDocument implements MappingAttribute { - public array|null $cascade; + public ?array $cascade; public function __construct( - string|array $cascade = null + string|array|null $cascade = null ) { $this->cascade = null === $cascade ? null : (array) $cascade; } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php index 6b011b877..e5619958f 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Reference.php @@ -6,7 +6,7 @@ abstract class Reference implements MappingAttribute { - public array|null $cascade; + public ?array $cascade; /** * @param string[]|string $cascade @@ -15,10 +15,10 @@ public function __construct( /** * The PHPCR property name to use. */ - public null|string $property = null, - public null|string $targetDocument = null, + public ?string $property = null, + public ?string $targetDocument = null, public string $strategy = 'weak', - array|string $cascade = null + array|string|null $cascade = null ) { $this->cascade = null === $cascade ? null : (array) $cascade; } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php index 04d2d2f33..9b8bdd921 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Referrers.php @@ -7,7 +7,7 @@ #[\Attribute(\Attribute::TARGET_PROPERTY)] final class Referrers implements MappingAttribute { - public array|null $cascade; + public ?array $cascade; /** * @param string[]|string $cascade @@ -15,7 +15,7 @@ final class Referrers implements MappingAttribute public function __construct( public string $referencedBy, public string $referringDocument, - array|string $cascade = null + array|string|null $cascade = null ) { $this->cascade = null === $cascade ? null : (array) $cascade; } diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php index 9a16e8891..5e9d9832a 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Attributes/Uuid.php @@ -9,7 +9,7 @@ public function __construct( string $property = 'jcr:uuid', string $type = 'string', bool $multivalue = false, - string $assoc = null, + ?string $assoc = null, bool $nullable = false, ) { parent::__construct($property, $type, $multivalue, $assoc, $nullable, false); diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php index 11f8c29d3..df152de10 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php @@ -680,7 +680,7 @@ public function getNamespace(): string return $this->namespace; } - public function mapId(array $mapping, self $inherited = null): void + public function mapId(array $mapping, ?self $inherited = null): void { if (true === ($mapping['id'] ?? false)) { $mapping['type'] = 'string'; @@ -693,21 +693,21 @@ public function mapId(array $mapping, self $inherited = null): void $this->validateAndCompleteFieldMapping($mapping, $inherited, false, false); } - public function mapNode(array $mapping, self $inherited = null): void + public function mapNode(array $mapping, ?self $inherited = null): void { $mapping['type'] = 'node'; $this->validateAndCompleteFieldMapping($mapping, $inherited, false); $this->node = $mapping['fieldName']; } - public function mapNodename(array $mapping, self $inherited = null): void + public function mapNodename(array $mapping, ?self $inherited = null): void { $mapping['type'] = 'nodename'; $this->validateAndCompleteFieldMapping($mapping, $inherited, false, false); $this->nodename = $mapping['fieldName']; } - public function mapParentDocument(array $mapping, self $inherited = null): void + public function mapParentDocument(array $mapping, ?self $inherited = null): void { if (empty($mapping['cascade'])) { $mapping['cascade'] = 0; @@ -717,7 +717,7 @@ public function mapParentDocument(array $mapping, self $inherited = null): void $this->parentMapping = $mapping['fieldName']; } - public function mapChild(array $mapping, self $inherited = null): void + public function mapChild(array $mapping, ?self $inherited = null): void { if (empty($mapping['cascade'])) { $mapping['cascade'] = 0; @@ -730,7 +730,7 @@ public function mapChild(array $mapping, self $inherited = null): void $this->childMappings[$mapping['fieldName']] = $mapping['fieldName']; } - public function mapChildren(array $mapping, self $inherited = null): void + public function mapChildren(array $mapping, ?self $inherited = null): void { if (empty($mapping['cascade'])) { $mapping['cascade'] = 0; @@ -749,7 +749,7 @@ public function mapChildren(array $mapping, self $inherited = null): void $this->childrenMappings[$mapping['fieldName']] = $mapping['fieldName']; } - public function mapReferrers(array $mapping, self $inherited = null): void + public function mapReferrers(array $mapping, ?self $inherited = null): void { if (empty($mapping['referencedBy'])) { throw MappingException::referrerWithoutReferencedBy($this->name, $mapping['fieldName']); @@ -772,7 +772,7 @@ public function mapReferrers(array $mapping, self $inherited = null): void $this->referrersMappings[$mapping['fieldName']] = $mapping['fieldName']; } - public function mapMixedReferrers(array $mapping, self $inherited = null): void + public function mapMixedReferrers(array $mapping, ?self $inherited = null): void { if (!(array_key_exists('referenceType', $mapping) && in_array($mapping['referenceType'], [null, 'weak', 'hard'], true))) { throw new MappingException(sprintf( @@ -797,28 +797,28 @@ public function mapMixedReferrers(array $mapping, self $inherited = null): void $this->mixedReferrersMappings[$mapping['fieldName']] = $mapping['fieldName']; } - public function mapLocale(array $mapping, self $inherited = null): void + public function mapLocale(array $mapping, ?self $inherited = null): void { $mapping['type'] = 'locale'; $mapping = $this->validateAndCompleteFieldMapping($mapping, $inherited, false, false); $this->localeMapping = $mapping['fieldName']; } - public function mapDepth(array $mapping, self $inherited = null): void + public function mapDepth(array $mapping, ?self $inherited = null): void { $mapping['type'] = 'depth'; $mapping = $this->validateAndCompleteFieldMapping($mapping, $inherited, false, false); $this->depthMapping = $mapping['fieldName']; } - public function mapVersionName(array $mapping, self $inherited = null): void + public function mapVersionName(array $mapping, ?self $inherited = null): void { $mapping['type'] = 'versionname'; $mapping = $this->validateAndCompleteFieldMapping($mapping, $inherited, false, false); $this->versionNameField = $mapping['fieldName']; } - public function mapVersionCreated(array $mapping, self $inherited = null): void + public function mapVersionCreated(array $mapping, ?self $inherited = null): void { $mapping['type'] = 'versioncreated'; $mapping = $this->validateAndCompleteFieldMapping($mapping, $inherited, false, false); @@ -837,7 +837,7 @@ public function mapLifecycleCallbacks(array $mapping): void * * @throws MappingException */ - private function validateAndCompleteFieldMapping(array $mapping, self $inherited = null, bool $isField = true, $phpcrLabel = 'property'): array + private function validateAndCompleteFieldMapping(array $mapping, ?self $inherited = null, bool $isField = true, $phpcrLabel = 'property'): array { if ($inherited) { if (!array_key_exists('inherited', $mapping)) { @@ -916,7 +916,7 @@ private function validateAndCompleteFieldMapping(array $mapping, self $inherited return $mapping; } - private function validateAndCompleteAssociationMapping(array $mapping, self $inherited = null, bool|string $phpcrLabel = 'property'): array + private function validateAndCompleteAssociationMapping(array $mapping, ?self $inherited = null, bool|string $phpcrLabel = 'property'): array { $mapping = $this->validateAndCompleteFieldMapping($mapping, $inherited, false, $phpcrLabel); if ($inherited) { @@ -1063,14 +1063,14 @@ private function determineIdStrategy(): void )); } - public function mapManyToOne(array $mapping, self $inherited = null): void + public function mapManyToOne(array $mapping, ?self $inherited = null): void { $mapping['type'] = self::MANY_TO_ONE; $mapping = $this->validateAndCompleteAssociationMapping($mapping, $inherited); $this->referenceMappings[$mapping['fieldName']] = $mapping['fieldName']; } - public function mapManyToMany(array $mapping, self $inherited = null): void + public function mapManyToMany(array $mapping, ?self $inherited = null): void { $mapping['type'] = self::MANY_TO_MANY; $mapping = $this->validateAndCompleteAssociationMapping($mapping, $inherited); @@ -1360,7 +1360,7 @@ public function isNullable(string $fieldName): bool * * @param array $mapping the mapping information */ - public function mapField(array $mapping, self $inherited = null): void + public function mapField(array $mapping, ?self $inherited = null): void { $parentMapping = array_key_exists('fieldName', $mapping) && array_key_exists($mapping['fieldName'], $this->mappings) ? $this->mappings[$mapping['fieldName']] @@ -1629,7 +1629,7 @@ public function getFieldMapping(string $fieldName): array * * @param mixed[]|null $arguments the arguments to pass to the callback */ - public function invokeLifecycleCallbacks(string $lifecycleEvent, object $document, array $arguments = null): void + public function invokeLifecycleCallbacks(string $lifecycleEvent, object $document, ?array $arguments = null): void { foreach ($this->lifecycleCallbacks[$lifecycleEvent] as $callback) { if (null !== $arguments) { diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php index 1a6832d81..b7d169ca1 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/Driver/AttributeDriver.php @@ -82,12 +82,12 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad $classAttributes = $this->reader->getClassAttributes($reflectionClass); // Evaluate document attribute - if (array_key_exists(ODM\Document::class, $classAttributes)) { - $documentAttribute = $classAttributes[ODM\Document::class]; - \assert($documentAttribute instanceof ODM\Document); - } elseif (isset($classAttributes[ODM\MappedSuperclass::class])) { - $documentAttribute = $classAttributes[ODM\MappedSuperclass::class]; - \assert($documentAttribute instanceof ODM\MappedSuperclass); + if (array_key_exists(Document::class, $classAttributes)) { + $documentAttribute = $classAttributes[Document::class]; + \assert($documentAttribute instanceof Document); + } elseif (isset($classAttributes[MappedSuperclass::class])) { + $documentAttribute = $classAttributes[MappedSuperclass::class]; + \assert($documentAttribute instanceof MappedSuperclass); $metadata->isMappedSuperclass = true; } else { throw MappingException::classIsNotAValidDocument($className); diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php b/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php index 8c1ff5b82..ffcd97a0f 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/MappingException.php @@ -32,7 +32,7 @@ public static function classHasNoField(string $documentClass, string $fieldName) return new self("Invalid mapping: The class '$documentClass' does not have a field named '$fieldName'"); } - public static function illegalChildName(string $documentClass, string $fieldName, string $nodeName, \Throwable $previous = null): self + public static function illegalChildName(string $documentClass, string $fieldName, string $nodeName, ?\Throwable $previous = null): self { return new self("Invalid mapping: The field '$fieldName' of '$documentClass' is configured to the illegal PHPCR node name '$nodeName'.", 0, $previous); } diff --git a/lib/Doctrine/ODM/PHPCR/PersistentCollection.php b/lib/Doctrine/ODM/PHPCR/PersistentCollection.php index b5a48287a..312e53596 100644 --- a/lib/Doctrine/ODM/PHPCR/PersistentCollection.php +++ b/lib/Doctrine/ODM/PHPCR/PersistentCollection.php @@ -186,7 +186,7 @@ public function isEmpty(): bool return $this->collection->isEmpty(); } - public function key(): int|null|string + public function key(): int|string|null { $this->initialize(); diff --git a/lib/Doctrine/ODM/PHPCR/Proxy/ProxyFactory.php b/lib/Doctrine/ODM/PHPCR/Proxy/ProxyFactory.php index e60d0ee65..77f820a33 100644 --- a/lib/Doctrine/ODM/PHPCR/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ODM/PHPCR/Proxy/ProxyFactory.php @@ -139,7 +139,7 @@ private function createInitializer(PhpcrClassMetadata $classMetadata): \Closure * * @throws UnexpectedValueException */ - private function createCloner(PhpcrClassMetadata $classMetadata, \ReflectionProperty $reflectionId = null): \Closure + private function createCloner(PhpcrClassMetadata $classMetadata, ?\ReflectionProperty $reflectionId = null): \Closure { $className = $classMetadata->getName(); $documentManager = $this->documentManager; diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/AbstractNode.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/AbstractNode.php index 777ce3b30..24377767f 100644 --- a/lib/Doctrine/ODM/PHPCR/Query/Builder/AbstractNode.php +++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/AbstractNode.php @@ -64,7 +64,7 @@ abstract class AbstractNode private ?AbstractNode $parent; - public function __construct(AbstractNode $parent = null) + public function __construct(?AbstractNode $parent = null) { $this->parent = $parent; } diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterBase.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterBase.php index 6e8874bb0..6411e35f6 100644 --- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterBase.php +++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterBase.php @@ -3,7 +3,6 @@ namespace Doctrine\ODM\PHPCR\Query\Builder; use Doctrine\ODM\PHPCR\Exception\InvalidArgumentException; -use Doctrine\ODM\PHPCR\Query\Builder\AbstractNode as QBConstants; use PHPCR\Query\QOM\BindVariableValueInterface; use PHPCR\Query\QOM\ChildNodeInterface; use PHPCR\Query\QOM\ChildNodeJoinConditionInterface; @@ -234,11 +233,11 @@ public function walkWhereOr(WhereOr $whereOr): ConstraintInterface protected function walkSourceJoin(SourceJoin $node): JoinInterface { - $left = $this->dispatch($node->getChildOfType(QBConstants::NT_SOURCE_JOIN_LEFT)); + $left = $this->dispatch($node->getChildOfType(AbstractNode::NT_SOURCE_JOIN_LEFT)); \assert($left instanceof SourceInterface); - $right = $this->dispatch($node->getChildOfType(QBConstants::NT_SOURCE_JOIN_RIGHT)); + $right = $this->dispatch($node->getChildOfType(AbstractNode::NT_SOURCE_JOIN_RIGHT)); \assert($right instanceof SourceInterface); - $cond = $this->dispatch($node->getChildOfType(QBConstants::NT_SOURCE_JOIN_CONDITION_FACTORY)); + $cond = $this->dispatch($node->getChildOfType(AbstractNode::NT_SOURCE_JOIN_CONDITION_FACTORY)); \assert($cond instanceof JoinConditionInterface); return $this->qomf()->join($left, $right, $node->getJoinType(), $cond); @@ -391,10 +390,10 @@ protected function walkConstraintChild(ConstraintChild $node): ChildNodeInterfac protected function walkConstraintComparison(ConstraintComparison $node): ComparisonInterface { $dynOp = $node->getChildOfType( - QBConstants::NT_OPERAND_DYNAMIC + AbstractNode::NT_OPERAND_DYNAMIC ); $statOp = $node->getChildOfType( - QBConstants::NT_OPERAND_STATIC + AbstractNode::NT_OPERAND_STATIC ); $phpcrDynOp = $this->dispatch($dynOp); @@ -412,7 +411,7 @@ protected function walkConstraintComparison(ConstraintComparison $node): Compari protected function walkConstraintNot(ConstraintNot $node): ConstraintInterface { $con = $node->getChildOfType( - QBConstants::NT_CONSTRAINT + AbstractNode::NT_CONSTRAINT ); $phpcrCon = $this->dispatch($con); @@ -464,7 +463,7 @@ protected function walkOperandDynamicName(OperandDynamicName $node): NodeNameInt protected function walkOperandDynamicLowerCase(OperandDynamicLowerCase $node): LowerCaseInterface { $child = $node->getChildOfType( - QBConstants::NT_OPERAND_DYNAMIC + AbstractNode::NT_OPERAND_DYNAMIC ); $phpcrChild = $this->dispatch($child); @@ -478,7 +477,7 @@ protected function walkOperandDynamicLowerCase(OperandDynamicLowerCase $node): L protected function walkOperandDynamicUpperCase(OperandDynamicUpperCase $node): UpperCaseInterface { $child = $node->getChildOfType( - QBConstants::NT_OPERAND_DYNAMIC + AbstractNode::NT_OPERAND_DYNAMIC ); $phpcrChild = $this->dispatch($child); @@ -513,7 +512,7 @@ protected function walkOrderBy(OrderBy $node): array foreach ($orderings as $ordering) { \assert($ordering instanceof Ordering); $dynOp = $ordering->getChildOfType( - QBConstants::NT_OPERAND_DYNAMIC + AbstractNode::NT_OPERAND_DYNAMIC ); $phpcrDynOp = $this->dispatch($dynOp); diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterPhpcr.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterPhpcr.php index 144864d34..75480f8f0 100644 --- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterPhpcr.php +++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterPhpcr.php @@ -56,7 +56,7 @@ class ConverterPhpcr extends ConverterBase * Used to keep track of which sources are used with translated fields, to * tell the translation strategy to update if needed. * - * @var array keys are the alias, value is true + * @var array keys are the alias, value is true */ private array $aliasWithTranslatedFields; @@ -290,7 +290,7 @@ protected function walkOperandStaticLiteral(OperandStaticLiteral $node): Literal { $value = $node->getValue(); - if ($field = $node->getParent()?->getChildOfType(AbstractNode::NT_OPERAND_DYNAMIC)) { + if ($field = $node->getParent()?->getChildOfType(QBConstants::NT_OPERAND_DYNAMIC)) { if ($field instanceof OperandDynamicField) { $meta = $this->aliasMetadata[$field->getAlias()]; $fieldMapping = $meta->getFieldMapping($field->getField()); diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/QueryBuilder.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/QueryBuilder.php index 7ae48abe6..fff396332 100644 --- a/lib/Doctrine/ODM/PHPCR/Query/Builder/QueryBuilder.php +++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/QueryBuilder.php @@ -28,7 +28,7 @@ * * @author Daniel Leech */ -class QueryBuilder extends AbstractNode +class QueryBuilder extends QBConstants { private ?ConverterInterface $converter = null; private int $firstResult = 0; @@ -156,7 +156,7 @@ public function orWhere($void = null): WhereOr * * @factoryMethod From */ - public function from(string $primaryAlias = null): From + public function from(?string $primaryAlias = null): From { $this->primaryAlias = $primaryAlias; diff --git a/lib/Doctrine/ODM/PHPCR/Query/Query.php b/lib/Doctrine/ODM/PHPCR/Query/Query.php index 09ea27499..d29bad155 100644 --- a/lib/Doctrine/ODM/PHPCR/Query/Query.php +++ b/lib/Doctrine/ODM/PHPCR/Query/Query.php @@ -124,7 +124,7 @@ public function setDocumentClass(string $documentClass): self * * @throws QueryException if $hydrationMode is not known */ - public function execute(array $parameters = null, int $hydrationMode = null) + public function execute(?array $parameters = null, ?int $hydrationMode = null) { if (!empty($parameters)) { $this->setParameters($parameters); @@ -195,7 +195,7 @@ public function getPhpcrNodeResult() * * @throws QueryException if more than one result found */ - public function getOneOrNullResult(int $hydrationMode = null) + public function getOneOrNullResult(?int $hydrationMode = null) { $result = $this->execute(null, $hydrationMode); @@ -219,7 +219,7 @@ public function getOneOrNullResult(int $hydrationMode = null) * * @throws QueryException if no result or more than one result found */ - public function getSingleResult(int $hydrationMode = null) + public function getSingleResult(?int $hydrationMode = null) { $result = $this->getOneOrNullResult($hydrationMode); diff --git a/lib/Doctrine/ODM/PHPCR/ReferenceManyCollection.php b/lib/Doctrine/ODM/PHPCR/ReferenceManyCollection.php index 72eb84cd4..12172b07f 100644 --- a/lib/Doctrine/ODM/PHPCR/ReferenceManyCollection.php +++ b/lib/Doctrine/ODM/PHPCR/ReferenceManyCollection.php @@ -33,7 +33,7 @@ class ReferenceManyCollection extends PersistentCollection * @param string|null $locale The locale to use during the loading of this collection * @param string $referenceType Identifiers used for reference nodes in this collection, either path or default uuid */ - public function __construct(DocumentManagerInterface $dm, object $document, string $property, array $referencedNodes, ?string $targetDocument, string $locale = null, string $referenceType = self::REFERENCE_TYPE_UUID) + public function __construct(DocumentManagerInterface $dm, object $document, string $property, array $referencedNodes, ?string $targetDocument, ?string $locale = null, string $referenceType = self::REFERENCE_TYPE_UUID) { parent::__construct($dm); $this->document = $document; diff --git a/lib/Doctrine/ODM/PHPCR/ReferrersCollection.php b/lib/Doctrine/ODM/PHPCR/ReferrersCollection.php index 9cde025a7..443b4e572 100644 --- a/lib/Doctrine/ODM/PHPCR/ReferrersCollection.php +++ b/lib/Doctrine/ODM/PHPCR/ReferrersCollection.php @@ -32,7 +32,7 @@ class ReferrersCollection extends PersistentCollection * @param string|null $locale the locale to use * @param string|null $refClass class the referrer document must be instanceof */ - public function __construct(DocumentManagerInterface $dm, object $document, string $type = null, string $name = null, string $locale = null, string $refClass = null) + public function __construct(DocumentManagerInterface $dm, object $document, ?string $type = null, ?string $name = null, ?string $locale = null, ?string $refClass = null) { parent::__construct($dm); $this->document = $document; @@ -51,7 +51,7 @@ public function __construct(DocumentManagerInterface $dm, object $document, stri * @param string|null $refClass class the referrer document must be instanceof * @param bool $forceOverwrite If to force the database to be forced to the state of the collection */ - public static function createFromCollection(DocumentManagerInterface $dm, object $document, $collection, string $type = null, string $name = null, string $refClass = null, bool $forceOverwrite = false): self + public static function createFromCollection(DocumentManagerInterface $dm, object $document, $collection, ?string $type = null, ?string $name = null, ?string $refClass = null, bool $forceOverwrite = false): self { $referrerCollection = new self($dm, $document, $type, $name, null, $refClass); $referrerCollection->initializeFromCollection($collection, $forceOverwrite); diff --git a/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/DocumentConvertTranslationCommand.php b/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/DocumentConvertTranslationCommand.php index 80d783d41..b716f7786 100644 --- a/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/DocumentConvertTranslationCommand.php +++ b/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/DocumentConvertTranslationCommand.php @@ -24,7 +24,7 @@ class DocumentConvertTranslationCommand extends Command { private ?TranslationConverter $translationConverter; - public function __construct($name = null, TranslationConverter $translationConverter = null) + public function __construct($name = null, ?TranslationConverter $translationConverter = null) { parent::__construct($name); $this->translationConverter = $translationConverter; diff --git a/lib/Doctrine/ODM/PHPCR/Tools/Console/Helper/DocumentManagerHelper.php b/lib/Doctrine/ODM/PHPCR/Tools/Console/Helper/DocumentManagerHelper.php index f193117e0..bb1c45efa 100644 --- a/lib/Doctrine/ODM/PHPCR/Tools/Console/Helper/DocumentManagerHelper.php +++ b/lib/Doctrine/ODM/PHPCR/Tools/Console/Helper/DocumentManagerHelper.php @@ -13,7 +13,7 @@ final class DocumentManagerHelper extends PhpcrHelper { private ?DocumentManagerInterface $dm; - public function __construct(SessionInterface $session = null, DocumentManagerInterface $dm = null) + public function __construct(?SessionInterface $session = null, ?DocumentManagerInterface $dm = null) { if (!$session && $dm) { $session = $dm->getPhpcrSession(); diff --git a/lib/Doctrine/ODM/PHPCR/Tools/Helper/PrefetchHelper.php b/lib/Doctrine/ODM/PHPCR/Tools/Helper/PrefetchHelper.php index 0acee973f..7fe750826 100644 --- a/lib/Doctrine/ODM/PHPCR/Tools/Helper/PrefetchHelper.php +++ b/lib/Doctrine/ODM/PHPCR/Tools/Helper/PrefetchHelper.php @@ -23,7 +23,7 @@ class PrefetchHelper /** * @param NodeInterface[] $nodes */ - public function prefetch(DocumentManagerInterface $dm, iterable $nodes, string $locale = null): void + public function prefetch(DocumentManagerInterface $dm, iterable $nodes, ?string $locale = null): void { if (0 === count($nodes)) { return; @@ -68,7 +68,7 @@ public function prefetchReferences(ClassMetadata $class, NodeInterface $node): v * * @param NodeInterface $node the node to prefetch parent and children for */ - public function prefetchHierarchy(ClassMetadata $class, NodeInterface $node, string $locale = null): void + public function prefetchHierarchy(ClassMetadata $class, NodeInterface $node, ?string $locale = null): void { $prefetch = $this->collectPrefetchHierarchy($class, $node, $locale); if (count($prefetch)) { @@ -112,7 +112,7 @@ public function collectPrefetchReferences(ClassMetadata $class, NodeInterface $n * * @return string[] list of absolute paths to nodes that should be prefetched */ - public function collectPrefetchHierarchy(ClassMetadata $class, NodeInterface $node, string $locale = null): array + public function collectPrefetchHierarchy(ClassMetadata $class, NodeInterface $node, ?string $locale = null): array { $prefetch = []; if ($class->parentMapping && $node->getDepth() > 0) { diff --git a/lib/Doctrine/ODM/PHPCR/Tools/Test/QueryBuilderTester.php b/lib/Doctrine/ODM/PHPCR/Tools/Test/QueryBuilderTester.php index af6b4e46c..637817fae 100644 --- a/lib/Doctrine/ODM/PHPCR/Tools/Test/QueryBuilderTester.php +++ b/lib/Doctrine/ODM/PHPCR/Tools/Test/QueryBuilderTester.php @@ -83,7 +83,7 @@ public function getNode(string $path): AbstractNode * Note that paths here do not include indexes. They need to be * inferred mentally. */ - public function dumpPaths(AbstractNode $node = null): string + public function dumpPaths(?AbstractNode $node = null): string { $children = []; $paths = []; @@ -127,7 +127,7 @@ public function getPath(AbstractNode $node): string * * @return AbstractNode[] */ - public function getAllNodes(AbstractNode $node = null): array + public function getAllNodes(?AbstractNode $node = null): array { $nodes = []; if (!$node) { diff --git a/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php b/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php index 24dc11ea9..dee7e12b7 100644 --- a/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php +++ b/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php @@ -84,7 +84,7 @@ public function setFallbackLocales(string $locale, array $order, bool $replace): $this->localePreference[$locale] = $order; } - public function getFallbackLocales(?object $document, ClassMetadata $metadata, string $forLocale = null): array + public function getFallbackLocales(?object $document, ClassMetadata $metadata, ?string $forLocale = null): array { if (is_null($forLocale)) { return $this->localePreference[$this->getLocale()]; diff --git a/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooserInterface.php b/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooserInterface.php index 44744ee1f..c977ddc0e 100644 --- a/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooserInterface.php +++ b/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooserInterface.php @@ -64,7 +64,7 @@ public function setFallbackLocales(string $locale, array $order, bool $replace): * * @throws MissingTranslationException */ - public function getFallbackLocales(?object $document, ClassMetadata $metadata, string $forLocale = null): array; + public function getFallbackLocales(?object $document, ClassMetadata $metadata, ?string $forLocale = null): array; /** * Get the locale of the current session. diff --git a/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/AttributeTranslationStrategy.php b/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/AttributeTranslationStrategy.php index a4155ea3d..dbba0565a 100644 --- a/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/AttributeTranslationStrategy.php +++ b/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/AttributeTranslationStrategy.php @@ -174,7 +174,7 @@ public function getTranslatedPropertyPath(string $alias, string $propertyName, s public function alterQueryForTranslation( QueryObjectModelFactoryInterface $qomf, SourceInterface &$selector, - ConstraintInterface &$constraint = null, + ?ConstraintInterface &$constraint, string $alias, string $locale ): void { diff --git a/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/ChildTranslationStrategy.php b/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/ChildTranslationStrategy.php index 63bfe789a..e5346e612 100644 --- a/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/ChildTranslationStrategy.php +++ b/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/ChildTranslationStrategy.php @@ -128,7 +128,7 @@ public function getTranslatedPropertyPath(string $alias, string $propertyName, s public function alterQueryForTranslation( QueryObjectModelFactoryInterface $qomf, SourceInterface &$selector, - ConstraintInterface &$constraint = null, + ?ConstraintInterface &$constraint, string $alias, string $locale ): void { diff --git a/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/NonTranslatedStrategy.php b/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/NonTranslatedStrategy.php index 6301fc4a6..2762fb4b9 100644 --- a/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/NonTranslatedStrategy.php +++ b/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/NonTranslatedStrategy.php @@ -88,7 +88,7 @@ public function getTranslatedPropertyPath(string $alias, string $propertyName, s public function alterQueryForTranslation( QueryObjectModelFactoryInterface $qomf, SourceInterface &$selector, - ConstraintInterface &$constraint = null, + ?ConstraintInterface &$constraint, string $alias, string $locale ): void { diff --git a/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/TranslationStrategyInterface.php b/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/TranslationStrategyInterface.php index c3c4978d7..e2493984f 100644 --- a/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/TranslationStrategyInterface.php +++ b/lib/Doctrine/ODM/PHPCR/Translation/TranslationStrategy/TranslationStrategyInterface.php @@ -107,7 +107,7 @@ public function getTranslatedPropertyPath(string $alias, string $propertyName, s public function alterQueryForTranslation( QueryObjectModelFactoryInterface $qomf, SourceInterface &$selector, - ConstraintInterface &$constraint = null, + ?ConstraintInterface &$constraint, string $alias, string $locale ): void; diff --git a/lib/Doctrine/ODM/PHPCR/UnitOfWork.php b/lib/Doctrine/ODM/PHPCR/UnitOfWork.php index 6a8571323..0509b5ba1 100644 --- a/lib/Doctrine/ODM/PHPCR/UnitOfWork.php +++ b/lib/Doctrine/ODM/PHPCR/UnitOfWork.php @@ -273,7 +273,7 @@ public function getOrCreateDocument(?string $className, NodeInterface $node, arr * * @param \Iterator|array $nodes * - * @throws Exception\InvalidArgumentException + * @throws InvalidArgumentException * @throws PHPCRException */ public function getOrCreateDocuments(?string $className, iterable $nodes, array $hints = []): array @@ -553,7 +553,7 @@ public function getOrCreateDocuments(?string $className, iterable $nodes, array /** * Get the existing document or proxy or create a new one for this PHPCR Node. */ - public function getOrCreateProxyFromNode(NodeInterface $node, string $locale = null): object + public function getOrCreateProxyFromNode(NodeInterface $node, ?string $locale = null): object { $targetId = $node->getPath(); $className = $this->documentClassMapper->getClassName($this->dm, $node); @@ -565,7 +565,7 @@ public function getOrCreateProxyFromNode(NodeInterface $node, string $locale = n * Get the existing document or proxy for this id of this class, or create * a new one. */ - public function getOrCreateProxy(string $targetId, string $className, string $locale = null): object + public function getOrCreateProxy(string $targetId, string $className, ?string $locale = null): object { $document = $this->getDocumentById($targetId); @@ -1085,7 +1085,7 @@ private function getChildNodename(string $parentId, string $nodename, object $ch } /** - * @throws Exception\InvalidArgumentException + * @throws InvalidArgumentException * @throws PHPCRException */ private function computeAssociationChanges(object $document, ClassMetadata $class, string $oid, bool $isNew, array $changeSet, string $assocType): void @@ -1514,7 +1514,7 @@ public function computeChangeSet(ClassMetadata $class, object $document): void * * @return object the child instance (if we are replacing a child this can be a different instance than was originally provided) */ - private function computeChildChanges(array $mapping, object $child, string $parentId, string $nodename, object $parent = null): object + private function computeChildChanges(array $mapping, object $child, string $parentId, string $nodename, ?object $parent = null): object { $targetClass = $this->dm->getClassMetadata(get_class($child)); $state = $this->getDocumentState($child); @@ -1608,7 +1608,7 @@ private function computeReferrerChanges(array $mapping, object $referrer): void * * @param int|null $overrideIdGenerator type of the id generator if not the default */ - public function persistNew(ClassMetadata $class, object $document, int $overrideIdGenerator = null, object $parent = null): void + public function persistNew(ClassMetadata $class, object $document, ?int $overrideIdGenerator = null, ?object $parent = null): void { if ($invoke = $this->eventListenersInvoker->getSubscribedSystems($class, Event::prePersist)) { $this->eventListenersInvoker->invoke( @@ -1710,7 +1710,7 @@ private function cascadeMergeCollection(Collection $managedCol, array $mapping): /** * @param array|null $assoc Information for association when necessary */ - private function doMerge(object $document, array &$visited, object $prevManagedCopy = null, array $assoc = null): object + private function doMerge(object $document, array &$visited, ?object $prevManagedCopy = null, ?array $assoc = null): object { $oid = \spl_object_hash($document); if (array_key_exists($oid, $visited)) { @@ -2945,7 +2945,7 @@ public function getDocumentId($document, bool $throw = true): ?string * Try to determine the document id first by looking into the document, * but if not mapped, look into the document id cache. */ - public function determineDocumentId(object $document, ClassMetadata $metadata = null): ?string + public function determineDocumentId(object $document, ?ClassMetadata $metadata = null): ?string { if (!$metadata) { $metadata = $this->dm->getClassMetadata(get_class($document)); @@ -3182,7 +3182,7 @@ protected function doLoadDatabaseTranslation(object $document, ClassMetadata $me * If the document is not translatable, this method returns immediately * and without error. */ - public function doLoadTranslation(object $document, ClassMetadata $metadata, string $locale = null, bool $fallback = false, bool $refresh = false): void + public function doLoadTranslation(object $document, ClassMetadata $metadata, ?string $locale = null, bool $fallback = false, bool $refresh = false): void { if (!$this->isDocumentTranslatable($metadata)) { return; @@ -3398,7 +3398,7 @@ private function setLocale(object $document, ClassMetadata $metadata, ?string $l * * @return string|null the current locale of $document or null if it is not translatable */ - public function getCurrentLocale(object $document, ClassMetadata $metadata = null): ?string + public function getCurrentLocale(object $document, ?ClassMetadata $metadata = null): ?string { if (null === $metadata) { $metadata = $this->dm->getClassMetadata(get_class($document)); @@ -3434,7 +3434,7 @@ public function isDocumentTranslatable(ClassMetadata $metadata): bool && 0 !== count($metadata->translatableFields); } - private static function objToStr(object $obj, DocumentManagerInterface $dm = null) + private static function objToStr(object $obj, ?DocumentManagerInterface $dm = null) { $string = method_exists($obj, '__toString') ? (string) $obj @@ -3547,7 +3547,7 @@ private function getReferenceManyCollectionTypeFromMetadata(array $referenceFiel * * @return int previous fetch depth value */ - public function setFetchDepth(int $fetchDepth = null): int + public function setFetchDepth(?int $fetchDepth = null): int { if (!$this->useFetchDepth || !method_exists($this->session, 'getSessionOption') diff --git a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php index 6fb458139..330fd014e 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsAddress.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsAddress.php @@ -65,7 +65,7 @@ public function setUser(CmsUser $user) class CmsAddressRepository extends DocumentRepository implements RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string + public function generateId(object $document, ?object $parent = null): string { return '/functional/'.$document->city.'_'.$document->zip; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsArticlePerson.php b/tests/Doctrine/Tests/Models/CMS/CmsArticlePerson.php index 2e096bb3c..883e07715 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsArticlePerson.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsArticlePerson.php @@ -57,7 +57,7 @@ public function getName() class CmsArticlePersonRepository extends DocumentRepository implements RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string + public function generateId(object $document, ?object $parent = null): string { return '/functional/'.$document->name; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsItem.php b/tests/Doctrine/Tests/Models/CMS/CmsItem.php index 04331fa66..c1deffe22 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsItem.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsItem.php @@ -53,7 +53,7 @@ public function getName() class CmsItemRepository extends DocumentRepository implements RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string + public function generateId(object $document, ?object $parent = null): string { return '/functional/'.$document->name; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsPage.php b/tests/Doctrine/Tests/Models/CMS/CmsPage.php index 4ff24f1c0..c6dc3e492 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsPage.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsPage.php @@ -82,7 +82,7 @@ public function removeItem($item) class CmsPageRepository extends DocumentRepository implements RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string + public function generateId(object $document, ?object $parent = null): string { return '/functional/'.$document->title; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsPageTranslatable.php b/tests/Doctrine/Tests/Models/CMS/CmsPageTranslatable.php index 537292a91..868a0bf0c 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsPageTranslatable.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsPageTranslatable.php @@ -95,7 +95,7 @@ public function getLocale() class CmsPageTranslatableRepository extends DocumentRepository implements RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string + public function generateId(object $document, ?object $parent = null): string { return '/functional/'.$document->title; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsProfile.php b/tests/Doctrine/Tests/Models/CMS/CmsProfile.php index 348b4269c..45f05f13d 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsProfile.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsProfile.php @@ -54,7 +54,7 @@ public function getUser() class CmsProfileRepository extends DocumentRepository implements RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string + public function generateId(object $document, ?object $parent = null): string { return '/functional/'.$document->user->username.'/'.$document->data; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsTeamUser.php b/tests/Doctrine/Tests/Models/CMS/CmsTeamUser.php index 33470242b..b1c0bf361 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsTeamUser.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsTeamUser.php @@ -23,7 +23,7 @@ public function setParentDocument($parent) class CmsTeamUserRepository extends DocumentRepository implements RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string + public function generateId(object $document, ?object $parent = null): string { return $document->parent->id.'/'.$document->username; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUser.php b/tests/Doctrine/Tests/Models/CMS/CmsUser.php index 15ece8cb7..7d801a25b 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsUser.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsUser.php @@ -108,7 +108,7 @@ public function getProfiles() class CmsUserRepository extends DocumentRepository implements RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string + public function generateId(object $document, ?object $parent = null): string { return '/functional/'.$document->username; } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUserTranslatable.php b/tests/Doctrine/Tests/Models/CMS/CmsUserTranslatable.php index ef331c26c..9db1bc0a3 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsUserTranslatable.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsUserTranslatable.php @@ -96,7 +96,7 @@ public function getGroups() class CmsUserTranslatableRepository extends DocumentRepository implements RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string + public function generateId(object $document, ?object $parent = null): string { return '/functional/'.$document->username; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/DocumentClassMapperTest.php b/tests/Doctrine/Tests/ODM/PHPCR/DocumentClassMapperTest.php index 4fb9d62c2..13c99475c 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/DocumentClassMapperTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/DocumentClassMapperTest.php @@ -14,7 +14,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class DocumentClassMapperTest extends Testcase +class DocumentClassMapperTest extends TestCase { private const CLASS_GENERIC = Generic::class; private const CLASS_TEST_1 = 'Test\Class1'; diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php index b8c786946..738a1d49a 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php @@ -169,7 +169,7 @@ public function testGetUuuidAfterPersist(): void public function testExistingUuuid(): void { - $testUuid = UuidHelper::generateUUID(); + $testUuid = UUIDHelper::generateUUID(); $newUser = new UserWithUuid(); $newUser->username = 'test'; @@ -722,7 +722,7 @@ class User6 extends User5 class User3Repository extends DocumentRepository implements RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string + public function generateId(object $document, ?object $parent = null): string { return '/functional/'.$document->username; } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildrenTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildrenTest.php index cc129e38b..12ede9a21 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildrenTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Hierarchy/ChildrenTest.php @@ -727,7 +727,7 @@ public function __construct() class ChildrenTestObjRepository extends DocumentRepository implements RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string + public function generateId(object $document, ?object $parent = null): string { if ($document->id) { return $document->id; diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AttributeMappingTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AttributeMappingTest.php index d6e422012..2a91ea4de 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AttributeMappingTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Mapping/AttributeMappingTest.php @@ -309,7 +309,7 @@ class RepositoryIdStrategy } class Repository extends DocumentRepository implements RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string + public function generateId(object $document, ?object $parent = null): string { return '/functional/'.str_replace(' ', '-', $document->title); } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DocumentRepository.php b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DocumentRepository.php index 392bd2dd6..05789a977 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DocumentRepository.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/DocumentRepository.php @@ -10,7 +10,7 @@ */ class DocumentRepository extends BaseDocumentRepository implements RepositoryIdInterface { - public function generateId(object $document, object $parent = null): string + public function generateId(object $document, ?object $parent = null): string { return '/functional/'.rand(); } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php b/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php index fd511af10..9da2c2101 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/PHPCRFunctionalTestCase.php @@ -21,7 +21,7 @@ abstract class PHPCRFunctionalTestCase extends TestCase */ private $sessions = []; - public function createDocumentManager(array $paths = null): DocumentManager + public function createDocumentManager(?array $paths = null): DocumentManager { if (empty($paths)) { $paths = [__DIR__.'/../../Models']; diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Query/QueryTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Query/QueryTest.php index 7863bc64d..d3a3c5642 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Query/QueryTest.php @@ -14,7 +14,7 @@ /** * @group unit */ -class QueryTest extends Testcase +class QueryTest extends TestCase { /** * @var QueryInterface&MockObject @@ -120,9 +120,15 @@ public function testExecuteParameters(): void { $this->phpcrQuery ->method('bindValue') - ->withConsecutive(['foo', 'bar'], ['bar', 'foo']) + ->with( + $this->callback(function (string $key): bool { + return 'kfoo' === $key || 'kbar' === $key; + }), $this->callback(function (string $value): bool { + return 'bar' === $value || 'foo' === $value; + }) + ) ; - $this->query->execute(['foo' => 'bar', 'bar' => 'foo']); + $this->query->execute(['kfoo' => 'bar', 'kbar' => 'foo']); } public function testExecuteMaxResults(): void diff --git a/tests/phpunit_doctrine_dbal.xml.dist b/tests/phpunit_doctrine_dbal.xml.dist index 19bc21242..ec0ce1873 100644 --- a/tests/phpunit_doctrine_dbal.xml.dist +++ b/tests/phpunit_doctrine_dbal.xml.dist @@ -10,6 +10,7 @@ +