Skip to content

Commit

Permalink
Fix parent parameter name mismatch
Browse files Browse the repository at this point in the history
This could lead to problems using named arguments in PHP 8
  • Loading branch information
franmomu committed May 24, 2021
1 parent 0a32d29 commit ebd8d15
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 57 deletions.
90 changes: 45 additions & 45 deletions lib/Doctrine/ODM/MongoDB/DocumentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,18 +443,18 @@ public function createAggregationBuilder(string $documentName): Aggregation\Buil
* NOTE: The persist operation always considers documents that are not yet known to
* this DocumentManager as NEW. Do not pass detached documents to the persist operation.
*
* @param object $document The instance to make managed and persistent.
* @param object $object The instance to make managed and persistent.
*
* @throws InvalidArgumentException When the given $document param is not an object.
* @throws InvalidArgumentException When the given $object param is not an object.
*/
public function persist($document)
public function persist($object)
{
if (! is_object($document)) {
throw new InvalidArgumentException(gettype($document));
if (! is_object($object)) {
throw new InvalidArgumentException(gettype($object));
}

$this->errorIfClosed();
$this->unitOfWork->persist($document);
$this->unitOfWork->persist($object);
}

/**
Expand All @@ -463,36 +463,36 @@ public function persist($document)
* A removed document will be removed from the database at or before transaction commit
* or as a result of the flush operation.
*
* @param object $document The document instance to remove.
* @param object $object The document instance to remove.
*
* @throws InvalidArgumentException When the $document param is not an object.
* @throws InvalidArgumentException When the $object param is not an object.
*/
public function remove($document)
public function remove($object)
{
if (! is_object($document)) {
throw new InvalidArgumentException(gettype($document));
if (! is_object($object)) {
throw new InvalidArgumentException(gettype($object));
}

$this->errorIfClosed();
$this->unitOfWork->remove($document);
$this->unitOfWork->remove($object);
}

/**
* Refreshes the persistent state of a document from the database,
* overriding any local changes that have not yet been persisted.
*
* @param object $document The document to refresh.
* @param object $object The document to refresh.
*
* @throws InvalidArgumentException When the given $document param is not an object.
* @throws InvalidArgumentException When the given $object param is not an object.
*/
public function refresh($document)
public function refresh($object)
{
if (! is_object($document)) {
throw new InvalidArgumentException(gettype($document));
if (! is_object($object)) {
throw new InvalidArgumentException(gettype($object));
}

$this->errorIfClosed();
$this->unitOfWork->refresh($document);
$this->unitOfWork->refresh($object);
}

/**
Expand All @@ -502,40 +502,40 @@ public function refresh($document)
* Documents which previously referenced the detached document will continue to
* reference it.
*
* @param object $document The document to detach.
* @param object $object The document to detach.
*
* @throws InvalidArgumentException When the $document param is not an object.
* @throws InvalidArgumentException When the $object param is not an object.
*/
public function detach($document)
public function detach($object)
{
if (! is_object($document)) {
throw new InvalidArgumentException(gettype($document));
if (! is_object($object)) {
throw new InvalidArgumentException(gettype($object));
}

$this->unitOfWork->detach($document);
$this->unitOfWork->detach($object);
}

/**
* Merges the state of a detached document into the persistence context
* of this DocumentManager and returns the managed copy of the document.
* The document passed to merge will not become associated/managed with this DocumentManager.
*
* @param object $document The detached document to merge into the persistence context.
* @param object $object The detached document to merge into the persistence context.
*
* @return object The managed copy of the document.
*
* @throws LockException
* @throws InvalidArgumentException If the $document param is not an object.
* @throws InvalidArgumentException If the $object param is not an object.
*/
public function merge($document)
public function merge($object)
{
if (! is_object($document)) {
throw new InvalidArgumentException(gettype($document));
if (! is_object($object)) {
throw new InvalidArgumentException(gettype($object));
}

$this->errorIfClosed();

return $this->unitOfWork->merge($document);
return $this->unitOfWork->merge($object);
}

/**
Expand All @@ -560,17 +560,17 @@ public function unlock(object $document): void
/**
* Gets the repository for a document class.
*
* @param string $documentName The name of the Document.
* @psalm-param class-string<T> $documentName
* @param string $className The name of the Document.
* @psalm-param class-string<T> $className
*
* @return ObjectRepository The repository.
* @psalm-return ObjectRepository<T>
*
* @template T of object
*/
public function getRepository($documentName)
public function getRepository($className)
{
return $this->repositoryFactory->getRepository($this, $documentName);
return $this->repositoryFactory->getRepository($this, $className);
}

/**
Expand Down Expand Up @@ -682,11 +682,11 @@ public function find($className, $id, $lockMode = LockMode::NONE, $lockVersion =
* All documents that are currently managed by this DocumentManager become
* detached.
*
* @param string|null $documentName if given, only documents of this type will get detached
* @param string|null $objectName if given, only documents of this type will get detached
*/
public function clear($documentName = null)
public function clear($objectName = null)
{
$this->unitOfWork->clear($documentName);
$this->unitOfWork->clear($objectName);
}

/**
Expand All @@ -703,21 +703,21 @@ public function close()
/**
* Determines whether a document instance is managed in this DocumentManager.
*
* @param object $document
* @param object $object
*
* @return bool TRUE if this DocumentManager currently manages the given document, FALSE otherwise.
*
* @throws InvalidArgumentException When the $document param is not an object.
* @throws InvalidArgumentException When the $object param is not an object.
*/
public function contains($document)
public function contains($object)
{
if (! is_object($document)) {
throw new InvalidArgumentException(gettype($document));
if (! is_object($object)) {
throw new InvalidArgumentException(gettype($object));
}

return $this->unitOfWork->isScheduledForInsert($document) ||
$this->unitOfWork->isInIdentityMap($document) &&
! $this->unitOfWork->isScheduledForDelete($document);
return $this->unitOfWork->isScheduledForInsert($object) ||
$this->unitOfWork->isInIdentityMap($object) &&
! $this->unitOfWork->isScheduledForDelete($object);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -1835,15 +1835,15 @@ public function getAssociationCollectionClass(string $assocName): string
/**
* {@inheritDoc}
*/
public function isAssociationInverseSide($fieldName): bool
public function isAssociationInverseSide($assocName): bool
{
throw new BadMethodCallException(__METHOD__ . '() is not implemented yet.');
}

/**
* {@inheritDoc}
*/
public function getAssociationMappedByTargetField($fieldName)
public function getAssociationMappedByTargetField($assocName)
{
throw new BadMethodCallException(__METHOD__ . '() is not implemented yet.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ public function set($key, $value)
/**
* {@inheritdoc}
*/
public function add($value)
public function add($element)
{
return $this->doAdd($value, false);
return $this->doAdd($element, false);
}

/**
Expand Down
16 changes: 8 additions & 8 deletions lib/Doctrine/ODM/MongoDB/Query/QueryExpressionVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,20 @@ public function walkComparison(Comparison $comparison): Expr
*
* @see ExpressionVisitor::walkCompositeExpression()
*/
public function walkCompositeExpression(CompositeExpression $compositeExpr): Expr
public function walkCompositeExpression(CompositeExpression $expr): Expr
{
if (! isset(self::$compositeMethods[$compositeExpr->getType()])) {
throw new RuntimeException('Unknown composite ' . $compositeExpr->getType());
if (! isset(self::$compositeMethods[$expr->getType()])) {
throw new RuntimeException('Unknown composite ' . $expr->getType());
}

$method = self::$compositeMethods[$compositeExpr->getType()];
$expr = $this->builder->expr();
$method = self::$compositeMethods[$expr->getType()];
$outputExpr = $this->builder->expr();

foreach ($compositeExpr->getExpressionList() as $child) {
$expr->{$method}($this->dispatch($child));
foreach ($expr->getExpressionList() as $child) {
$outputExpr->{$method}($this->dispatch($child));
}

return $expr;
return $outputExpr;
}

/**
Expand Down

0 comments on commit ebd8d15

Please sign in to comment.